{"id":34075264,"url":"https://github.com/brightdata/sdk-python","last_synced_at":"2026-01-07T13:17:14.851Z","repository":{"id":309202096,"uuid":"1033685757","full_name":"brightdata/sdk-python","owner":"brightdata","description":"Bright Data's python SDK, use it to call bright data's scrape and search tools. bypass any Bot-detection or Captcha and extract data from any website in seconds.","archived":false,"fork":false,"pushed_at":"2025-12-02T14:15:49.000Z","size":1022,"stargazers_count":37,"open_issues_count":1,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-04T05:23:21.995Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/brightdata.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-08-07T07:36:51.000Z","updated_at":"2025-12-02T14:15:55.000Z","dependencies_parsed_at":"2025-08-10T15:27:20.729Z","dependency_job_id":"05370996-a74f-4042-b6c3-33c59945eaaf","html_url":"https://github.com/brightdata/sdk-python","commit_stats":null,"previous_names":["brightdata/bright-data-sdk-python","brightdata/sdk-python"],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/brightdata/sdk-python","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brightdata%2Fsdk-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brightdata%2Fsdk-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brightdata%2Fsdk-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brightdata%2Fsdk-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brightdata","download_url":"https://codeload.github.com/brightdata/sdk-python/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brightdata%2Fsdk-python/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27724324,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-14T02:00:11.348Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-12-14T09:11:51.417Z","updated_at":"2026-01-07T13:17:14.831Z","avatar_url":"https://github.com/brightdata.png","language":"Python","readme":"# Bright Data Python SDK\n\nThe official Python SDK for [Bright Data](https://brightdata.com) APIs. Scrape any website, get SERP results, bypass bot detection and CAPTCHAs.\n\n[![Python](https://img.shields.io/badge/python-3.9%2B-blue)](https://www.python.org/)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)\n\n## Installation\n\n```bash\npip install brightdata-sdk\n```\n\n## Configuration\n\nGet your API Token from the [Bright Data Control Panel](https://brightdata.com/cp/api_keys):\n\n```bash\nexport BRIGHTDATA_API_TOKEN=\"your_api_token_here\"\n```\n\n## Quick Start\n\nThis SDK is **async-native**. A sync client is also available (see [Sync Client](#sync-client)).\n\n```python\nimport asyncio\nfrom brightdata import BrightDataClient\n\nasync def main():\n    async with BrightDataClient() as client:\n        result = await client.scrape_url(\"https://example.com\")\n        print(result.data)\n\nasyncio.run(main())\n```\n\n## Usage Examples\n\n### Web Scraping\n\n```python\nasync with BrightDataClient() as client:\n    result = await client.scrape_url(\"https://example.com\")\n    print(result.data)\n```\n\n#### Web Scraping Async Mode\n\nFor non-blocking web scraping, use `mode=\"async\"`. This triggers a request and returns a `response_id`, which the SDK automatically polls until results are ready:\n\n```python\nasync with BrightDataClient() as client:\n    # Triggers request → gets response_id → polls until ready\n    result = await client.scrape_url(\n        url=\"https://example.com\",\n        mode=\"async\",\n        poll_interval=5,    # Check every 5 seconds\n        poll_timeout=180    # Web Unlocker async can take ~2 minutes\n    )\n    print(result.data)\n\n    # Batch scraping multiple URLs concurrently\n    urls = [\"https://example.com\", \"https://example.org\", \"https://example.net\"]\n    results = await client.scrape_url(url=urls, mode=\"async\", poll_timeout=180)\n```\n\n**How it works:**\n1. Sends request to `/unblocker/req` → returns `response_id` immediately\n2. Polls `/unblocker/get_result?response_id=...` until ready or timeout\n3. Returns the scraped data\n\n**When to use async mode:**\n- Batch scraping with many URLs\n- Background processing while continuing other work\n\n**Performance note:** Web Unlocker async mode typically takes ~2 minutes to complete. For faster results on single URLs, use the default sync mode (no `mode` parameter).\n\n### Search Engines (SERP)\n\n```python\nasync with BrightDataClient() as client:\n    result = await client.search.google(query=\"python scraping\", num_results=10)\n    for item in result.data:\n        print(item)\n```\n\n#### SERP Async Mode\n\nFor non-blocking SERP requests, use `mode=\"async\"`:\n\n```python\nasync with BrightDataClient() as client:\n    # Non-blocking - polls for results\n    result = await client.search.google(\n        query=\"python programming\",\n        mode=\"async\",\n        poll_interval=2,   # Check every 2 seconds\n        poll_timeout=30    # Give up after 30 seconds\n    )\n\n    for item in result.data:\n        print(item['title'], item['link'])\n```\n\n**When to use async mode:**\n- Batch operations with many queries\n- Background processing while continuing other work\n- When scraping may take longer than usual\n\n**Note:** Async mode uses the same zones and returns the same data structure as sync mode - no extra configuration needed!\n\n### Web Scraper API\n\nThe SDK includes ready-to-use scrapers for popular websites: Amazon, LinkedIn, Instagram, Facebook, and more.\n\n**Pattern:** `client.scrape.\u003cplatform\u003e.\u003cmethod\u003e(url)`\n\n**Example: Amazon**\n```python\nasync with BrightDataClient() as client:\n    # Product details\n    result = await client.scrape.amazon.products(url=\"https://amazon.com/dp/B0CRMZHDG8\")\n\n    # Reviews\n    result = await client.scrape.amazon.reviews(url=\"https://amazon.com/dp/B0CRMZHDG8\")\n\n    # Sellers\n    result = await client.scrape.amazon.sellers(url=\"https://amazon.com/dp/B0CRMZHDG8\")\n```\n\n**Available scrapers:**\n- `client.scrape.amazon` - products, reviews, sellers\n- `client.scrape.linkedin` - profiles, companies, jobs, posts\n- `client.scrape.instagram` - profiles, posts, comments, reels\n- `client.scrape.facebook` - posts, comments, reels\n\n## Async Usage\n\nRun multiple requests concurrently:\n\n```python\nimport asyncio\nfrom brightdata import BrightDataClient\n\nasync def main():\n    async with BrightDataClient() as client:\n        urls = [\"https://example.com/page1\", \"https://example.com/page2\", \"https://example.com/page3\"]\n        tasks = [client.scrape_url(url) for url in urls]\n        results = await asyncio.gather(*tasks)\n\nasyncio.run(main())\n```\n\n### Manual Trigger/Poll/Fetch\n\nFor long-running scrapes:\n\n```python\nasync with BrightDataClient() as client:\n    # Trigger\n    job = await client.scrape.amazon.products_trigger(url=\"https://amazon.com/dp/B123\")\n\n    # Wait for completion\n    await job.wait(timeout=180)\n\n    # Fetch results\n    data = await job.fetch()\n```\n\n## Sync Client\n\nFor simpler use cases, use `SyncBrightDataClient`:\n\n```python\nfrom brightdata import SyncBrightDataClient\n\nwith SyncBrightDataClient() as client:\n    result = client.scrape_url(\"https://example.com\")\n    print(result.data)\n\n    # All methods work the same\n    result = client.scrape.amazon.products(url=\"https://amazon.com/dp/B123\")\n    result = client.search.google(query=\"python\")\n```\n\nSee [docs/sync_client.md](docs/sync_client.md) for details.\n\n## Troubleshooting\n\n**RuntimeError: SyncBrightDataClient cannot be used inside async context**\n```python\n# Wrong - using sync client in async function\nasync def main():\n    with SyncBrightDataClient() as client:  # Error!\n        ...\n\n# Correct - use async client\nasync def main():\n    async with BrightDataClient() as client:\n        result = await client.scrape_url(\"https://example.com\")\n```\n\n**RuntimeError: BrightDataClient not initialized**\n```python\n# Wrong - forgot context manager\nclient = BrightDataClient()\nresult = await client.scrape_url(\"...\")  # Error!\n\n# Correct - use context manager\nasync with BrightDataClient() as client:\n    result = await client.scrape_url(\"...\")\n```\n\n## License\n\nMIT License\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrightdata%2Fsdk-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrightdata%2Fsdk-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrightdata%2Fsdk-python/lists"}