@@ -11,27 +11,30 @@ npm install @brightdata/sdk
1111```
1212
1313## Quick start
14+
1415### 1. [ Signup] ( https://brightdata.com/cp ) and get your API key
1516
1617### 2. Initialize the Client
1718
1819Create a file named pizzaSearch.mjs with the follwing content:
20+
1921``` javascript
2022import { bdclient } from ' @brightdata/sdk' ;
2123
2224const client = new bdclient ({
23- apiKey: ' [your_api_key_here]' // can also be defined as BRIGHTDATA_API_KEY env variable
25+ apiKey: ' [your_api_key_here]' , // can also be defined as BRIGHTDATA_API_KEY env variable
2426});
2527```
2628
2729### 3. Launch your first request
2830
2931Add our search function:
32+
3033``` javascript
3134import { bdclient } from ' @brightdata/sdk' ;
3235
3336const client = new bdclient ({
34- apiKey: ' [your_api_key_here]' // can also be defined as BRIGHTDATA_API_KEY env variable
37+ apiKey: ' [your_api_key_here]' , // can also be defined as BRIGHTDATA_API_KEY env variable
3538});
3639const result = await client .search (' pizza restaurants' );
3740console .log (result);
@@ -54,8 +57,7 @@ node pizzaSearch.mjs
5457- ** Dual build** : Both ESM and CommonJS supported
5558- ** TypeScript** : Fully typed for different combinations of input and output data
5659
57- ## Usage
58-
60+ ## Usage
5961
6062### Scrape websites
6163
@@ -134,6 +136,21 @@ const filePath = await client.saveResults(data, {
134136console .log (` Content saved to: ${ filePath} ` );
135137```
136138
139+ ### Trigger dataset snapshot collection
140+
141+ ``` javascript
142+ const res = await client .datasets .linkedin .discoverCompanyPosts ([
143+ { url: ' https://www.linkedin.com/company/bright-data' },
144+ ]);
145+
146+ // it will poll if snapshot is ready, and once it is - download it
147+ const filePath = await client .datasets .snapshot .download (res .snapshot_id , {
148+ filename: ' ./brd_posts.jsonl' ,
149+ format: ' jsonl' ,
150+ });
151+ console .log (` Content saved to: ${ filePath} ` );
152+ ```
153+
137154## Configuration
138155
139156### API Key
@@ -185,50 +202,51 @@ const client = new bdclient({
185202### Key Methods
186203
187204### scrape(url, options)
205+
188206Scrapes a single URL or array of URLs using the Web Unlocker.
189207
190208** Parameters:**
191209
192- | Name | Type | Description | Default |
193- | ------------------------ | ----------------------------------------| ----------------------------------------------------------------- | ----------- |
194- | ` url ` | ` string ` | ; ` string[] ` | Single URL string or array of URLs | — |
195- | ` options.zone ` | ` string ` | Zone identifier (auto-configured if ` null ` ) | — |
196- | ` options.format ` | ` "json" ` | ; ` "raw" ` | Response format | ` "raw" ` |
197- | ` options.method ` | ` string ` | HTTP method | ` "GET" ` |
198- | ` options.country ` | ` string ` | Two-letter country code | ` "" ` |
199- | ` options.dataFormat ` | ` "markdown" ` | ; ` "screenshot" ` | ; ` "html" ` | Returned content format | ` "html" ` |
200- | ` options.concurrency ` | ` number ` | Max parallel workers | ` 10 ` |
201- | ` options.timeout ` | ` number ` (ms) | Request timeout | ` 30000 ` |
210+ | Name | Type | Description | Default |
211+ | --------------------- | -------------------------------------------------- | ------------------------------------------- | -------- |
212+ | ` url ` | ` string ` | ; ` string[] ` | Single URL string or array of URLs | — |
213+ | ` options.zone ` | ` string ` | Zone identifier (auto-configured if ` null ` ) | — |
214+ | ` options.format ` | ` "json" ` | ; ` "raw" ` | Response format | ` "raw" ` |
215+ | ` options.method ` | ` string ` | HTTP method | ` "GET" ` |
216+ | ` options.country ` | ` string ` | Two-letter country code | ` "" ` |
217+ | ` options.dataFormat ` | ` "markdown" ` | ; ` "screenshot" ` | ; ` "html" ` | Returned content format | ` "html" ` |
218+ | ` options.concurrency ` | ` number ` | Max parallel workers | ` 10 ` |
219+ | ` options.timeout ` | ` number ` (ms) | Request timeout | ` 30000 ` |
202220
203221### search(query, options)
204222
205223Searches using the SERP API
206224
207225** Parameters:**
208226
209- | Name | Type | Description | Default |
210- | -------------------------- | --------------------------------------------------| ----------------------------------------------- | ------------- |
211- | ` query ` | ` string ` | ; ` string[] ` | Search query string or array of queries | — |
212- | ` options.searchEngine ` | ` "google" ` | ; ` "bing" ` | ; ` "yandex" ` | Search engine | ` "google" ` |
213- | ` options.zone ` | ` string ` | Zone identifier (auto-configured if ` null ` ) | — |
214- | ` options.format ` | ` "json" ` | ; ` "raw" ` | Response format | ` "raw" ` |
215- | ` options.method ` | ` string ` | HTTP method | ` "GET" ` |
216- | ` options.country ` | ` string ` | Two-letter country code | ` "" ` |
217- | ` options.dataFormat ` | ` "markdown" ` | ; ` "screenshot" ` | ; ` "html" ` | Returned content format | ` "html" ` |
218- | ` options.concurrency ` | ` number ` | Max parallel workers | ` 10 ` |
219- | ` options.timeout ` | ` number ` (ms) | Request timeout | ` 30000 ` |
227+ | Name | Type | Description | Default |
228+ | ---------------------- | -------------------------------------------------- | ------------------------------------------- | ---------- |
229+ | ` query ` | ` string ` | ; ` string[] ` | Search query string or array of queries | — |
230+ | ` options.searchEngine ` | ` "google" ` | ; ` "bing" ` | ; ` "yandex" ` | Search engine | ` "google" ` |
231+ | ` options.zone ` | ` string ` | Zone identifier (auto-configured if ` null ` ) | — |
232+ | ` options.format ` | ` "json" ` | ; ` "raw" ` | Response format | ` "raw" ` |
233+ | ` options.method ` | ` string ` | HTTP method | ` "GET" ` |
234+ | ` options.country ` | ` string ` | Two-letter country code | ` "" ` |
235+ | ` options.dataFormat ` | ` "markdown" ` | ; ` "screenshot" ` | ; ` "html" ` | Returned content format | ` "html" ` |
236+ | ` options.concurrency ` | ` number ` | Max parallel workers | ` 10 ` |
237+ | ` options.timeout ` | ` number ` (ms) | Request timeout | ` 30000 ` |
220238
221239### saveResults(content, options)
222240
223241Save content to local file.
224242
225243** Parameters:**
226244
227- | Name | Type | Description | Default |
228- | -------------------- | --------------------------------------------- | ------------------------------------------------- | --------- |
229- | ` content ` | ` any ` | Content to save | — |
230- | ` options.filename ` | ` string ` | Output filename (auto-generated if ` null ` ) | — |
231- | ` options.format ` | ` string ` (` "json" ` , ` "csv" ` , ` "txt" ` ) | File format | ` "json" ` |
245+ | Name | Type | Description | Default |
246+ | ------------------ | ------------------------------------- | ------------------------------------------ | -------- |
247+ | ` content ` | ` any ` | Content to save | — |
248+ | ` options.filename ` | ` string ` | Output filename (auto-generated if ` null ` ) | — |
249+ | ` options.format ` | ` string ` (` "json" ` , ` "csv" ` , ` "txt" ` ) | File format | ` "json" ` |
232250
233251### listZones()
234252
@@ -252,6 +270,7 @@ try {
252270 }
253271}
254272```
273+
255274## Development
256275
257276For development installation:
0 commit comments