Skip to content

Commit d2d7c36

Browse files
author
Thordata
committed
update: README.md
1 parent dfe3119 commit d2d7c36

File tree

2 files changed

+103
-79
lines changed

2 files changed

+103
-79
lines changed

CHANGELOG.md

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,14 @@
11
# Changelog
22

3-
## [0.3.0] - 2025-12-22
3+
All notable changes to this project will be documented in this file.
44

5-
### Breaking Changes
6-
7-
- Environment variable renamed: `THORDATA_TOKEN` -> `THORDATA_SCRAPER_TOKEN`
5+
## [1.0.1] - 2026-01-05
86

97
### Added
10-
11-
- Complete Engine enum with all Google (22), Bing (7), Yandex (2), DuckDuckGo (2) engines
12-
- GoogleTbm enum for tbm parameter
13-
- Continent, Country, ProxyHost, ProxyPort enums
14-
- Location API with string parameter support
15-
- SSL verification option (verifySsl config)
16-
- Comprehensive JSDoc comments
8+
- **User-Agent Standardization**: Updated User-Agent to `thordata-js-sdk/{version} node/{ver} ({platform}/{arch})`.
9+
- **Proxy Expiration**: Added `getProxyExpiration` method to `ThordataClient`.
1710

1811
### Fixed
19-
20-
- Remove self-referencing dependency in package.json
21-
- Move dotenv to devDependencies
22-
- Remove unused zod dependency
23-
- Fix OutputFormat to only support html/png
24-
25-
## [0.2.0] - Previous release
26-
27-
- Initial public release
12+
- **Type Safety**: Improved TypeScript definitions and removed `any` usage in critical paths.
13+
- **Error Handling**: Enhanced `handleAxiosError` to extract detailed error messages from API responses (404/500).
14+
- **Dependencies**: Moved `http-proxy-agent` and `https-proxy-agent` to `dependencies` for proper runtime proxy support.

README.md

Lines changed: 96 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1-
# Thordata JS SDK (Node.js / TypeScript)
1+
# Thordata Node.js SDK
22

3-
Official JavaScript/TypeScript SDK for Thordata APIs.
3+
<div align="center">
4+
5+
**Official Node.js/TypeScript Client for Thordata APIs**
6+
7+
*Proxy Network • SERP API • Web Unlocker • Web Scraper API*
48

59
[![npm version](https://img.shields.io/npm/v/thordata-js-sdk.svg)](https://www.npmjs.com/package/thordata-js-sdk)
610
[![License](https://img.shields.io/badge/license-MIT-green)](LICENSE)
711

8-
Supports:
9-
10-
- **SERP API** (Google / Bing / Yandex)
11-
- **Web Unlocker** (Universal API)
12-
- **Web Scraper API** (Text & Video Tasks)
13-
- **Proxy Network** (Residential / Datacenter / Mobile / ISP)
14-
- **Account Management** (Usage, Users, Whitelist)
12+
</div>
1513

1614
---
1715

@@ -21,110 +19,149 @@ Supports:
2119
npm install thordata-js-sdk
2220
```
2321

24-
---
25-
2622
## 🔐 Configuration
2723

24+
Set environment variables:
25+
2826
```bash
29-
export THORDATA_SCRAPER_TOKEN=your_token
30-
export THORDATA_PUBLIC_TOKEN=your_public_token
31-
export THORDATA_PUBLIC_KEY=your_public_key
27+
export THORDATA_SCRAPER_TOKEN="your_token"
28+
export THORDATA_PUBLIC_TOKEN="your_public_token"
29+
export THORDATA_PUBLIC_KEY="your_public_key"
3230
```
3331

34-
---
35-
3632
## 🚀 Quick Start
3733

3834
```typescript
3935
import { Thordata } from "thordata-js-sdk";
4036

41-
const client = new Thordata(); // Reads from env vars
37+
// Initialize (reads from env vars)
38+
const client = new Thordata();
39+
40+
async function main() {
41+
// SERP Search
42+
const results = await client.serpSearch({
43+
query: "nodejs",
44+
engine: "google",
45+
country: "us"
46+
});
47+
console.log(results.organic?.[0]?.title);
48+
}
4249

43-
// SERP Search
44-
const results = await client.serpSearch({
45-
query: "Thordata SDK",
46-
engine: "google",
47-
country: "us",
48-
});
49-
console.log(results.organic?.[0]?.link);
50+
main();
5051
```
5152

52-
---
53+
## 📚 Core Features
5354

54-
## 📖 Features
55+
### 🌐 Proxy Network
5556

56-
### SERP API
57+
Build proxy URLs for `axios`, `fetch`, `puppeteer`, etc.
5758

5859
```typescript
60+
import { Thordata } from "thordata-js-sdk";
61+
62+
// Create proxy config
63+
const proxy = Thordata.Proxy.residentialFromEnv()
64+
.country("jp")
65+
.city("tokyo")
66+
.sticky(30); // 30 min session
67+
68+
// Get URL string
69+
console.log(proxy.toProxyUrl());
70+
71+
// Use with internal client
72+
const response = await client.request("https://httpbin.org/ip", { proxy });
73+
console.log(response);
74+
```
75+
76+
### 🔍 SERP API
77+
78+
```typescript
79+
import { Engine } from "thordata-js-sdk";
80+
5981
const news = await client.serpSearch({
60-
query: "AI News",
61-
engine: "google_news",
62-
num: 10,
82+
query: "SpaceX",
83+
engine: Engine.GOOGLE_NEWS,
84+
num: 20,
85+
country: "us",
86+
language: "en"
6387
});
6488
```
6589

66-
### Web Unlocker (Universal)
90+
### 🔓 Universal Scraping API (Web Unlocker)
6791

6892
```typescript
6993
const html = await client.universalScrape({
70-
url: "https://example.com",
94+
url: "https://example.com/spa",
7195
jsRender: true,
72-
waitFor: ".content",
96+
waitFor: ".loaded-content",
97+
blockResources: "image,media"
7398
});
7499
```
75100

76-
### Web Scraper API (Async)
101+
### 🕷️ Web Scraper API (Tasks)
77102

78103
```typescript
79-
// Create Task
104+
// 1. Create Task
80105
const taskId = await client.createScraperTask({
81-
fileName: "task1",
106+
fileName: "task_1",
82107
spiderId: "universal",
83108
spiderName: "universal",
84-
parameters: { url: "https://example.com" },
109+
parameters: { url: "https://example.com" }
85110
});
86111

87-
// Video Task (New)
88-
const vidId = await client.createVideoTask({
89-
fileName: "video1",
90-
spiderId: "youtube_video_by-url",
91-
spiderName: "youtube.com",
92-
parameters: { url: "..." },
93-
commonSettings: { resolution: "1080p" },
94-
});
95-
96-
// Wait & Result
112+
// 2. Wait
97113
const status = await client.waitForTask(taskId);
114+
115+
// 3. Download
98116
if (status === "ready") {
99117
const url = await client.getTaskResult(taskId);
100118
console.log(url);
101119
}
102120
```
103121

104-
### Account Management
122+
### 📊 Account Management
105123

106124
```typescript
107125
// Usage Stats
108126
const stats = await client.getUsageStatistics("2024-01-01", "2024-01-31");
109-
console.log("Balance:", stats.traffic_balance);
110127

111-
// Proxy Users
112-
const users = await client.listProxyUsers("residential");
113-
114-
// Whitelist
128+
// Manage Whitelist
115129
await client.addWhitelistIp("1.2.3.4");
130+
131+
// Check ISP Proxies
132+
const servers = await client.listProxyServers(1); // 1=ISP
116133
```
117134

118-
### Proxy Configuration
135+
## ⚙️ Advanced Usage
136+
137+
### Error Handling
138+
139+
The SDK throws typed errors for better control.
119140

120141
```typescript
121-
// Residential Proxy
122-
const proxy = Thordata.Proxy.residentialFromEnv().country("us");
123-
await client.request("https://httpbin.org/ip", { proxy });
142+
import { ThordataRateLimitError, ThordataAuthError } from "thordata-js-sdk";
143+
144+
try {
145+
await client.serpSearch({ ... });
146+
} catch (e) {
147+
if (e instanceof ThordataRateLimitError) {
148+
console.log(`Rate limited! Retry after ${e.retryAfter}s`);
149+
} else if (e instanceof ThordataAuthError) {
150+
console.log("Check your tokens!");
151+
}
152+
}
124153
```
125154

126-
---
155+
### Configuration Options
156+
157+
```typescript
158+
const client = new ThordataClient({
159+
scraperToken: "...",
160+
timeoutMs: 60000,
161+
maxRetries: 3, // Auto-retry on 429/5xx
162+
});
163+
```
127164

128165
## 📄 License
129166

130-
MIT License
167+
MIT License

0 commit comments

Comments
 (0)