python-sdk-best-practices
Installation
SKILL.md
Bright Data Python SDK - Best Practices for Coding Agents
You are writing code that uses the brightdata-sdk Python package. Follow these rules precisely.
Installation
pip install brightdata-sdk
Critical Rules
- Always use context managers. The client MUST be used with
async with(orwithfor sync). Forgetting this causesRuntimeError: BrightDataClient not initialized. - Async is the default. The primary client is
BrightDataClient(async). UseSyncBrightDataClientonly when you cannot use async. - Never use SyncBrightDataClient inside async functions. It raises
RuntimeError. UseBrightDataClientinstead. - Token auto-loads from environment. Set
BRIGHTDATA_API_TOKENenv var or passtoken=param. Do not hardcode tokens. - All scraper methods are awaitable. Every call on the async client must be
awaited.