Skip to content

Commit 3b83491

Browse files
committed
docs: added parameters detail for every functionality
1 parent 76e8656 commit 3b83491

File tree

1 file changed

+38
-25
lines changed

1 file changed

+38
-25
lines changed

Diff for: sdks/javascript.mdx

+38-25
Original file line numberDiff line numberDiff line change
@@ -41,27 +41,30 @@ yarn add scrapegraph-js
4141

4242
## Quick Start
4343

44-
Initialize with your API key:
44+
### Basic example
45+
46+
<Note>
47+
Store your API keys securely in environment variables. Use `.env` files and libraries like `dotenv` to load them into your app.
48+
</Note>
4549

4650
```javascript
4751
import { smartScraper } from 'scrapegraph-js';
52+
import 'dotenv/config';
4853

49-
const apiKey = process.env.SGAI_APIKEY;
54+
// Initialize variables
55+
const apiKey = process.env.SGAI_APIKEY; // Set your API key as an environment variable
5056
const websiteUrl = 'https://example.com';
51-
const prompt = 'Extract the main heading and description';
57+
const prompt = 'What does the company do?';
5258

5359
try {
54-
const response = await smartScraper(apiKey, websiteUrl, prompt);
60+
const response = await smartScraper(apiKey, websiteUrl, prompt); // call SmartScraper function
5561
console.log(response.result);
5662
} catch (error) {
5763
console.error('Error:', error);
5864
}
65+
;
5966
```
6067

61-
<Note>
62-
Store your API keys securely in environment variables. Use `.env` files and libraries like `dotenv` to load them into your app.
63-
</Note>
64-
6568
## Services
6669

6770
### SmartScraper
@@ -76,10 +79,19 @@ const response = await smartScraper(
7679
);
7780
```
7881

82+
#### Parameters
83+
84+
| Parameter | Type | Required | Description |
85+
|-----------|------|----------|-------------|
86+
| apiKey | string | Yes | The ScrapeGraph API Key. |
87+
| websiteUrl | string | Yes | The URL of the webpage that needs to be scraped. |
88+
| prompt | string | Yes | A textual description of what you want to achieve. |
89+
| schema | object | No | The Pydantic or Zod object that describes the structure and format of the response. |
90+
7991
<Accordion title="Basic Schema Example" icon="code">
8092
Define a simple schema using Zod:
8193

82-
```typescript
94+
```javascript
8395
import { z } from 'zod';
8496

8597
const ArticleSchema = z.object({
@@ -108,7 +120,7 @@ console.log(`Published: ${response.result.publishDate}`);
108120
<Accordion title="Advanced Schema Example" icon="code">
109121
Define a complex schema for nested data structures:
110122

111-
```typescript
123+
```javascript
112124
import { z } from 'zod';
113125

114126
const EmployeeSchema = z.object({
@@ -169,10 +181,18 @@ const response = await searchScraper(
169181
);
170182
```
171183

184+
#### Parameters
185+
186+
| Parameter | Type | Required | Description |
187+
|-----------|------|----------|-------------|
188+
| apiKey | string | Yes | The ScrapeGraph API Key. |
189+
| prompt | string | Yes | A textual description of what you want to achieve. |
190+
| schema | object | No | The Pydantic or Zod object that describes the structure and format of the response |
191+
172192
<Accordion title="Basic Schema Example" icon="code">
173193
Define a simple schema using Zod:
174194

175-
```typescript
195+
```javascript
176196
import { z } from 'zod';
177197

178198
const ArticleSchema = z.object({
@@ -199,7 +219,7 @@ console.log(`Published: ${response.result.publishDate}`);
199219
<Accordion title="Advanced Schema Example" icon="code">
200220
Define a complex schema for nested data structures:
201221

202-
```typescript
222+
```javascript
203223
import { z } from 'zod';
204224

205225
const EmployeeSchema = z.object({
@@ -230,19 +250,6 @@ const response = await searchScraper(
230250
'Find the best restaurants in San Francisco',
231251
RestaurantSchema
232252
);
233-
234-
235-
236-
// Access nested data
237-
console.log(`Restaurant: ${response.result.name}`);
238-
console.log('\nAddress:');
239-
response.result.address.forEach(address => {
240-
console.log(`- ${address}`);
241-
});
242-
243-
244-
console.log('\nRating:');
245-
console.log(`- ${response.result.rating}`);
246253
```
247254
</Accordion>
248255

@@ -258,6 +265,12 @@ const response = await markdownify(
258265
'https://example.com'
259266
);
260267
```
268+
#### Parameters
269+
270+
| Parameter | Type | Required | Description |
271+
|-----------|------|----------|-------------|
272+
| apiKey | string | Yes | The ScrapeGraph API Key. |
273+
| websiteUrl | string | Yes | The URL of the webpage to convert to markdown. |
261274

262275
## API Credits
263276

0 commit comments

Comments
 (0)