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

  1. Always use context managers. The client MUST be used with async with (or with for sync). Forgetting this causes RuntimeError: BrightDataClient not initialized.
  2. Async is the default. The primary client is BrightDataClient (async). Use SyncBrightDataClient only when you cannot use async.
  3. Never use SyncBrightDataClient inside async functions. It raises RuntimeError. Use BrightDataClient instead.
  4. Token auto-loads from environment. Set BRIGHTDATA_API_TOKEN env var or pass token= param. Do not hardcode tokens.
  5. All scraper methods are awaitable. Every call on the async client must be awaited.

Authentication

Related skills

More from brightdata/skills

Installs
47
GitHub Stars
127
First Seen
Mar 15, 2026