Skip to content

Commit 209bdd2

Browse files
author
Thordata
committed
chore(release): bump version to v1.2.0
1 parent f6b75a0 commit 209bdd2

File tree

4 files changed

+82
-105
lines changed

4 files changed

+82
-105
lines changed

README.md

Lines changed: 78 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -2,163 +2,140 @@
22

33
<div align="center">
44

5-
**Official Node.js/TypeScript Client for Thordata APIs**
5+
<img src="https://img.shields.io/badge/Thordata-AI%20Infrastructure-blue?style=for-the-badge" alt="Thordata Logo">
66

7-
_Proxy Network • SERP API • Web Unlocker • Web Scraper API_
7+
**The Official Node.js/TypeScript Client for Thordata APIs**
88

9-
[![npm version](https://img.shields.io/npm/v/thordata-js-sdk.svg)](https://www.npmjs.com/package/thordata-js-sdk)
10-
[![License](https://img.shields.io/badge/license-MIT-green)](LICENSE)
9+
*Proxy Network • SERP API • Web Unlocker • Web Scraper API*
10+
11+
[![npm version](https://img.shields.io/npm/v/thordata-js-sdk.svg?style=flat-square)](https://www.npmjs.com/package/thordata-js-sdk)
12+
[![License](https://img.shields.io/badge/license-MIT-green?style=flat-square)](LICENSE)
13+
[![Build Status](https://img.shields.io/github/actions/workflow/status/Thordata/thordata-js-sdk/ci.yml?branch=main&style=flat-square)](https://github.com/Thordata/thordata-js-sdk/actions)
1114

1215
</div>
1316

1417
---
1518

19+
## 📖 Introduction
20+
21+
A fully typed TypeScript SDK for Thordata, optimized for Node.js environments. It provides seamless integration with Thordata's proxy network and scraping APIs.
22+
23+
**Key Features:**
24+
* **🔒 Type-Safe:** Written in TypeScript with complete definitions.
25+
* **🌐 Modern:** Uses `axios` and standard `https-proxy-agent` for reliable connectivity.
26+
* **⚡ Lazy Validation:** Zero-config initialization; only provide credentials for the features you use.
27+
* **🛡️ Proxy Support:** Full support for HTTPS and SOCKS5h protocols with authentication.
28+
29+
---
30+
1631
## 📦 Installation
1732

1833
```bash
1934
npm install thordata-js-sdk
35+
# or
36+
yarn add thordata-js-sdk
2037
```
2138

39+
---
40+
2241
## 🔐 Configuration
2342

24-
Set environment variables:
43+
We recommend using `dotenv` to manage credentials.
2544

2645
```bash
27-
export THORDATA_SCRAPER_TOKEN="your_token"
28-
export THORDATA_PUBLIC_TOKEN="your_public_token"
29-
export THORDATA_PUBLIC_KEY="your_public_key"
46+
# .env file
47+
THORDATA_SCRAPER_TOKEN=your_token
48+
THORDATA_RESIDENTIAL_USERNAME=your_username
49+
THORDATA_RESIDENTIAL_PASSWORD=your_password
50+
THORDATA_PROXY_HOST=vpnXXXX.pr.thordata.net
3051
```
3152

53+
---
54+
3255
## 🚀 Quick Start
3356

57+
### 1. SERP Search
58+
3459
```typescript
35-
import { Thordata } from "thordata-js-sdk";
60+
import { ThordataClient, Engine } from "thordata-js-sdk";
3661

37-
// Initialize (reads from env vars)
38-
const client = new Thordata();
62+
const client = new ThordataClient({}); // Auto-loads from env
3963

40-
async function main() {
41-
// SERP Search
42-
const results = await client.serpSearch({
43-
query: "nodejs",
44-
engine: "google",
64+
async function search() {
65+
const result = await client.serpSearch({
66+
query: "SpaceX launch",
67+
engine: Engine.GOOGLE_NEWS,
4568
country: "us",
69+
num: 5
4670
});
47-
console.log(results.organic?.[0]?.title);
71+
72+
console.log(result.news_results);
4873
}
4974

50-
main();
75+
search();
5176
```
5277

53-
## 📚 Core Features
78+
### 2. Universal Scrape (Web Unlocker)
5479

55-
### 🌐 Proxy Network
80+
```typescript
81+
async function scrape() {
82+
const html = await client.universalScrape({
83+
url: "https://www.g2.com/products/thordata",
84+
jsRender: true,
85+
waitFor: ".reviews-list",
86+
country: "us"
87+
});
88+
89+
console.log("Page HTML length:", html.length);
90+
}
91+
```
5692

57-
Build proxy URLs for `axios`, `fetch`, `puppeteer`, etc.
93+
### 3. Using the Proxy Network
5894

5995
```typescript
6096
import { Thordata } from "thordata-js-sdk";
6197

62-
// Create proxy config
63-
const proxy = Thordata.Proxy.residentialFromEnv().country("jp").city("tokyo").sticky(30); // 30 min session
98+
// Create a targeted proxy config
99+
const proxy = Thordata.Proxy.residentialFromEnv()
100+
.country("gb")
101+
.city("london")
102+
.sticky(10); // 10 minutes session
64103

65-
// Get URL string
66-
console.log(proxy.toProxyUrl());
104+
const client = new Thordata();
67105

68-
// Use with internal client
69-
const response = await client.request("https://httpbin.org/ip", { proxy });
106+
// Request uses the proxy automatically
107+
const response = await client.request("https://ipinfo.io/json", { proxy });
70108
console.log(response);
71109
```
72110

73-
### 🔍 SERP API
74-
75-
```typescript
76-
import { Engine } from "thordata-js-sdk";
77-
78-
const news = await client.serpSearch({
79-
query: "SpaceX",
80-
engine: Engine.GOOGLE_NEWS,
81-
num: 20,
82-
country: "us",
83-
language: "en",
84-
});
85-
```
86-
87-
### 🔓 Universal Scraping API (Web Unlocker)
111+
---
88112

89-
```typescript
90-
const html = await client.universalScrape({
91-
url: "https://example.com/spa",
92-
jsRender: true,
93-
waitFor: ".loaded-content",
94-
blockResources: "image,media",
95-
});
96-
```
113+
## ⚙️ Advanced Usage
97114

98-
### 🕷️ Web Scraper API (Tasks)
115+
### Task Management (Async)
99116

100117
```typescript
101-
// 1. Create Task
118+
// Create a scraping task
102119
const taskId = await client.createScraperTask({
103-
fileName: "task_1",
120+
fileName: "task_001",
104121
spiderId: "universal",
105122
spiderName: "universal",
106-
parameters: { url: "https://example.com" },
123+
parameters: { url: "https://example.com" }
107124
});
108125

109-
// 2. Wait
126+
console.log(`Task ${taskId} created. Waiting...`);
127+
128+
// Poll for completion
110129
const status = await client.waitForTask(taskId);
111130

112-
// 3. Download
113131
if (status === "ready") {
114-
const url = await client.getTaskResult(taskId);
115-
console.log(url);
116-
}
117-
```
118-
119-
### 📊 Account Management
120-
121-
```typescript
122-
// Usage Stats
123-
const stats = await client.getUsageStatistics("2024-01-01", "2024-01-31");
124-
125-
// Manage Whitelist
126-
await client.addWhitelistIp("1.2.3.4");
127-
128-
// Check ISP Proxies
129-
const servers = await client.listProxyServers(1); // 1=ISP
130-
```
131-
132-
## ⚙️ Advanced Usage
133-
134-
### Error Handling
135-
136-
The SDK throws typed errors for better control.
137-
138-
```typescript
139-
import { ThordataRateLimitError, ThordataAuthError } from "thordata-js-sdk";
140-
141-
try {
142-
await client.serpSearch({ ... });
143-
} catch (e) {
144-
if (e instanceof ThordataRateLimitError) {
145-
console.log(`Rate limited! Retry after ${e.retryAfter}s`);
146-
} else if (e instanceof ThordataAuthError) {
147-
console.log("Check your tokens!");
148-
}
132+
const downloadUrl = await client.getTaskResult(taskId);
133+
console.log("Result:", downloadUrl);
149134
}
150135
```
151136

152-
### Configuration Options
153-
154-
```typescript
155-
const client = new ThordataClient({
156-
scraperToken: "...",
157-
timeoutMs: 60000,
158-
maxRetries: 3, // Auto-retry on 429/5xx
159-
});
160-
```
137+
---
161138

162139
## 📄 License
163140

164-
MIT License
141+
MIT License.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"type": "module",
33
"name": "thordata-js-sdk",
4-
"version": "1.1.0",
4+
"version": "1.2.0",
55
"description": "Official JavaScript/TypeScript SDK for Thordata (SERP, Universal, Web Scraper).",
66
"main": "./dist/index.js",
77
"types": "./dist/index.d.ts",

sdk-spec

Submodule sdk-spec updated 1 file

0 commit comments

Comments
 (0)