11# 🌐 ScrapeGraph JavaScript SDK
22
33[ ![ npm version] ( https://badge.fury.io/js/scrapegraph-js.svg )] ( https://badge.fury.io/js/scrapegraph-js )
4- [ ![ TypeScript Support] ( https://img.shields.io/badge/TypeScript-Ready-blue.svg )] ( https://www.typescriptlang.org/ )
54[ ![ License] ( https://img.shields.io/badge/License-MIT-blue.svg )] ( https://opensource.org/licenses/MIT )
65[ ![ Build Status] ( https://github.com/ScrapeGraphAI/scrapegraph-sdk/actions/workflows/ci.yml/badge.svg )] ( https://github.com/ScrapeGraphAI/scrapegraph-sdk/actions )
76[ ![ Documentation Status] ( https://img.shields.io/badge/docs-latest-brightgreen.svg )] ( https://docs.scrapegraphai.com )
@@ -11,8 +10,7 @@ Official JavaScript/TypeScript SDK for the ScrapeGraph AI API - Smart web scrapi
1110## 🚀 Features
1211
1312- ✨ Smart web scraping with AI
14- - 🔄 Fully asynchronous design
15- - 📊 TypeScript-ready with strongly typed responses
13+ - 🔄 Fully asynchronous design
1614- 🔍 Detailed error handling
1715- ⚡ Automatic retries and logging
1816- 🔐 Secure API authentication
@@ -23,7 +21,11 @@ Install the package using npm or yarn:
2321
2422``` bash
2523# Using npm
26- npm install scrapegraph-js
24+ npm i scrapegraph-js
25+
26+ # Using yarn
27+ yarn add scrapegraph-js
28+ ```
2729
2830
2931## 🔧 Quick Start
@@ -34,6 +36,7 @@ npm install scrapegraph-js
3436
3537``` javascript
3638import { smartScraper } from ' scrapegraph-js' ;
39+ import ' dotenv/config' ;
3740
3841// Initialize variables
3942const apiKey = process .env .SGAI_APIKEY ; // Set your API key as an environment variable
@@ -75,26 +78,8 @@ const prompt = 'Extract the main heading and description.';
7578
7679#### Scraping with Custom Output Schema
7780
78- ` ` ` typescript
79- import { smartScraper } from ' scrapegraph-js' ;
80-
81- interface WebsiteData {
82- title: string;
83- description: string;
84- }
85-
86- const apiKey = ' your-api-key' ;
87- const url = ' https://example.com' ;
88- const prompt = ' Extract the title and description.' ;
89-
90- (async () => {
91- try {
92- const response = await smartScraper< WebsiteData>( apiKey, url, prompt) ;
93- console.log(response.result.title, response.result.description);
94- } catch (error) {
95- console.error(' Error:' , error);
96- }
97- })();
81+ ``` javascript
82+ // TODO
9883```
9984
10085### Checking API Credits
0 commit comments