Skip to main content

Install the package

Open the terminal and run:
npm install @brightdata/sdk
In your code file, import the package - and launch your first requests:
import { bdclient } from '@brightdata/sdk';

const client = new bdclient({
    apiKey: '[your_api_key_here]' // can also be defined as BRIGHTDATA_API_KEY env variable
});
const result = await client.search('pizza restaurants');

console.log(result);

Launch scrapes and web searches

Try these examples to use Bright Data’s SDK functions from your IDE
import { bdclient } from '@brightdata/sdk';

const client = new bdclient({
    apiKey: '[your_api_key_here]' // can also be defined as BRIGHTDATA_API_KEY env variable
});
const result = await client.search('pizza restaurants');

console.log(result);
const client = new bdclient({
    apiKey: 'string', // Your API key
    autoCreateZones: true, // Auto-create zones if they don't exist
    webUnlockerZone: 'string', // Custom web unlocker zone name
    serpZone: 'string', // Custom SERP zone name
    logLevel: 'INFO', // Log level
    structuredLogging: true, // Use structured JSON logging
    verbose: false, // Enable verbose logging
});
Scrape a single URL or list of URLs using the Web Unlocker API.
NameTypeDescriptionDefault
url`stringstring[]`Single URL string or array of URLs
options.zonestringZone identifier (auto-configured if null)
options.format`“json""raw”`Response format"raw"
options.methodstringHTTP method"GET"
options.countrystringTwo-letter country code""
options.dataFormat`“markdown""screenshot""html”`Returned content format"html"
options.concurrencynumberMax parallel workers10
options.timeoutnumber (ms)Request timeout30000
Parameters:
NameTypeDescriptionDefault
contentanyContent to save
options.filenamestringOutput filename (auto-generated if null)
options.format`“json""csv""txt”`File format

Error handling

Enable VERBOSE in the Client for advenced logging (see Client parameters) Use the listZones() func to check available zones
Create a Bright Data account and copy your API key Go to account settings, and make sure that your API key have admin permissions

Resources

I