$npx -y skills add brightdata/skills --skill bright-data-best-practicesBuild production-ready Bright Data integrations with best practices baked in. Reference documentation for developers using coding assistants (Claude Code, Cursor, etc.) to implement web scraping, search, browser automation, and structured data extraction. Covers Web Unlocker API,
| 1 | # CLI Setup Reference |
| 2 | |
| 3 | Install, authentication, and troubleshooting for the Bright Data CLI (`bdata`) are documented in a single canonical place: |
| 4 | |
| 5 | → [`references/cli-setup.md`](references/cli-setup.md) |
| 6 | |
| 7 | Consult it before any task that shells out to `bdata`. |
| 8 | |
| 9 | # Bright Data APIs |
| 10 | |
| 11 | Bright Data provides infrastructure for web data extraction at scale. Four primary APIs cover different use cases — always pick the most specific tool for the job. |
| 12 | |
| 13 | ## Choosing the Right API |
| 14 | |
| 15 | | Use Case | API | Why | |
| 16 | |----------|-----|-----| |
| 17 | | Scrape any webpage by URL (no interaction) | Web Unlocker | HTTP-based, auto-bypasses bot detection, cheapest | |
| 18 | | Google / Bing / Yandex search results | SERP API | Specialized for SERP extraction, returns structured data | |
| 19 | | Structured data from Amazon, LinkedIn, Instagram, TikTok, etc. | Web Scraper API | Pre-built scrapers, no parsing needed | |
| 20 | | Click, scroll, fill forms, run JS, intercept XHR | Browser API | Full browser automation | |
| 21 | | Puppeteer / Playwright / Selenium automation | Browser API | Connects via CDP/WebDriver | |
| 22 | | Route your own HTTP client through a raw proxy (DC/ISP/Residential/Mobile) | Proxy networks | When you need direct proxy access with your own request logic instead of a managed API — see the `proxy.md` skill | |
| 23 | |
| 24 | ## Authentication Pattern (All APIs) |
| 25 | |
| 26 | All APIs share the same authentication model. The env vars below apply to direct REST API integrations — if you are using the `bdata` CLI, `bdata login` handles all of these automatically (see [`references/cli-setup.md`](references/cli-setup.md)). |
| 27 | |
| 28 | ```bash |
| 29 | export BRIGHTDATA_API_KEY="your-api-key" # From Control Panel > Account Settings |
| 30 | export BRIGHTDATA_UNLOCKER_ZONE="zone-name" # Web Unlocker zone name |
| 31 | export BRIGHTDATA_SERP_ZONE="serp-zone-name" # SERP API zone name |
| 32 | export BROWSER_AUTH="brd-customer-ID-zone-NAME:PASSWORD" # Browser API credentials |
| 33 | ``` |
| 34 | |
| 35 | REST API authentication header for Web Unlocker and SERP API: |
| 36 | ``` |
| 37 | Authorization: Bearer YOUR_API_KEY |
| 38 | ``` |
| 39 | |
| 40 | --- |
| 41 | |
| 42 | ## Web Unlocker API |
| 43 | |
| 44 | HTTP-based scraping proxy. Best for simple page fetches without browser interaction. |
| 45 | |
| 46 | **Endpoint:** `POST https://api.brightdata.com/request` |
| 47 | |
| 48 | ```python |
| 49 | import requests |
| 50 | |
| 51 | response = requests.post( |
| 52 | "https://api.brightdata.com/request", |
| 53 | headers={"Authorization": f"Bearer {API_KEY}"}, |
| 54 | json={ |
| 55 | "zone": "YOUR_ZONE_NAME", |
| 56 | "url": "https://example.com/product/123", |
| 57 | "format": "raw" |
| 58 | } |
| 59 | ) |
| 60 | html = response.text |
| 61 | ``` |
| 62 | |
| 63 | ### Key Parameters |
| 64 | |
| 65 | | Parameter | Type | Description | |
| 66 | |-----------|------|-------------| |
| 67 | | `zone` | string | Zone name (required) | |
| 68 | | `url` | string | Target URL with `http://` or `https://` (required) | |
| 69 | | `format` | string | `"raw"` (HTML) or `"json"` (structured wrapper) (required) | |
| 70 | | `method` | string | HTTP verb, default `"GET"` | |
| 71 | | `country` | string | 2-letter ISO for geo-targeting (e.g., `"us"`, `"de"`) | |
| 72 | | `data_format` | string | Transform: `"markdown"` or `"screenshot"` | |
| 73 | | `async` | boolean | `true` for async mode | |
| 74 | |
| 75 | ### Quick Patterns |
| 76 | |
| 77 | ```python |
| 78 | # Get markdown (best for LLM input) |
| 79 | response = requests.post( |
| 80 | "https://api.brightdata.com/request", |
| 81 | headers={"Authorization": f"Bearer {API_KEY}"}, |
| 82 | json={"zone": ZONE, "url": url, "format": "raw", "data_format": "markdown"} |
| 83 | ) |
| 84 | |
| 85 | # Geo-targeted request |
| 86 | json={"zone": ZONE, "url": url, "format": "raw", "country": "de"} |
| 87 | |
| 88 | # Screenshot for debugging |
| 89 | json={"zone": ZONE, "url": url, "format": "raw", "data_format": "screenshot"} |
| 90 | |
| 91 | # Async for bulk processing |
| 92 | json={"zone": ZONE, "url": url, "format": "raw", "async": True} |
| 93 | ``` |
| 94 | |
| 95 | **Critical rule:** Never use Web Unlocker with Puppeteer, Playwright, Selenium, or anti-detect browsers. Use Browser API instead. |
| 96 | |
| 97 | See **[references/web-unlocker.md](references/web-unlocker.md)** for complete reference including proxy interface, special headers, async flow, features, and billing. |
| 98 | |
| 99 | --- |
| 100 | |
| 101 | ## SERP API |
| 102 | |
| 103 | Structured search engine result extraction for Google, Bing, Yandex, DuckDuckGo. |
| 104 | |
| 105 | **Endpoint:** `POST https://api.brightdata.com/request` (same as Web Unlocker) |
| 106 | |
| 107 | ```python |
| 108 | response = requests.post( |
| 109 | "https://api.brightdata.com/request", |
| 110 | headers={"Authorization": f"Bearer {API_KEY}"}, |
| 111 | json={ |
| 112 | "zone": "YOUR_SERP_ZONE", |
| 113 | "url": "https://www.google.com/search?q=python+web+scraping&brd_json=1&gl=us&hl=en", |
| 114 | "format": "raw" |
| 115 | } |
| 116 | ) |
| 117 | data = response.json() |
| 118 | for result in data.get("organic", []): |
| 119 | print(result["rank"], result["title"], result["link"]) |
| 120 | ``` |
| 121 | |
| 122 | ### Essential Google URL Parameters |
| 123 | |
| 124 | | Parameter | Description | Example | |
| 125 | |-----------|-------------|-------- |