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 search or scrape the internet 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);

Acsses our Linkedin datasets

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

const client = new bdclient({
    apiKey: 'YOUR_API_KEY_HERE',
    logLevel: 'INFO',
    structuredLogging: true,
    verbose: false
});

const res = await client.datasets.linkedin.discoverCompanyPosts([
    { url: 'https://www.linkedin.com/company/bright-data' },
]);

// it will poll if snapshot is ready, and once it is - download it
const filePath = await client.datasets.snapshot.download(res.snapshot_id, {
    filename: './brd_posts.jsonl',
    format: 'jsonl',
});

console.log(`Content saved to: ${filePath}`);
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