@openserp/sdk 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -48
- package/package.json +28 -4
package/README.md
CHANGED
|
@@ -4,9 +4,37 @@
|
|
|
4
4
|
[](https://www.npmjs.com/package/@openserp/sdk)
|
|
5
5
|
[](https://github.com/karust/openserp/blob/master/LICENSE)
|
|
6
6
|
|
|
7
|
+
```bash
|
|
8
|
+
npm install @openserp/sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Cloud:
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { OpenSERP } from "@openserp/sdk";
|
|
15
|
+
|
|
16
|
+
const client = new OpenSERP({ apiKey: process.env.OPENSERP_KEY });
|
|
17
|
+
const { results } = await client.search({ engine: "google", text: "openserp" });
|
|
18
|
+
|
|
19
|
+
console.log(results[0]?.title, results[0]?.url);
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Self-hosted:
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import { OpenSERP } from "@openserp/sdk";
|
|
26
|
+
|
|
27
|
+
const client = new OpenSERP({ baseUrl: "http://localhost:7000" });
|
|
28
|
+
const { results } = await client.search({ engine: "bing", text: "openserp" });
|
|
29
|
+
|
|
30
|
+
console.log(results[0]?.title, results[0]?.url);
|
|
31
|
+
```
|
|
32
|
+
|
|
7
33
|
Universal TypeScript / JavaScript SDK for the **OpenSERP** multi-engine SERP API — Google, Bing, Yandex, Baidu, DuckDuckGo, and Ecosia results in a single call. Works against the self-hosted [open source server](https://github.com/karust/openserp) and against [OpenSERP Cloud](https://openserp.org/cloud) with the same code.
|
|
8
34
|
|
|
9
|
-
Use it for AI grounding, RAG pipelines, LLM tool use, SEO
|
|
35
|
+
Use it for AI grounding, RAG pipelines, LLM tool use, agent tool use, LangChain / LlamaIndex integrations, SEO rank tracking, competitor analysis, and search-powered automations. Open-source alternative to SerpAPI, DataForSEO, ScrapingBee, Bright Data SERP, Oxylabs SERP, and Zenserp.
|
|
36
|
+
|
|
37
|
+
> Also available for Python: [`openserp`](https://pypi.org/project/openserp/) ([source](https://github.com/karust/openserp/tree/master/integrations/sdk-python)).
|
|
10
38
|
|
|
11
39
|
> **Alpha — the API may change before `1.0.0`.** Pin a version in production.
|
|
12
40
|
|
|
@@ -22,7 +50,6 @@ Use it for AI grounding, RAG pipelines, LLM tool use, SEO monitoring, competitor
|
|
|
22
50
|
- [Telemetry](#telemetry)
|
|
23
51
|
- [Error handling](#error-handling)
|
|
24
52
|
- [Retry hook](#retry-hook)
|
|
25
|
-
- [Edge runtimes](#edge-runtimes)
|
|
26
53
|
- [Use cases](#use-cases)
|
|
27
54
|
- [Development](#development)
|
|
28
55
|
|
|
@@ -162,11 +189,7 @@ await client.enginesStatus();
|
|
|
162
189
|
await client.enginesCapabilities();
|
|
163
190
|
```
|
|
164
191
|
|
|
165
|
-
The backend is inferred from `baseUrl` and `apiKey`.
|
|
166
|
-
|
|
167
|
-
```ts
|
|
168
|
-
client.config.backend = "oss";
|
|
169
|
-
```
|
|
192
|
+
The backend is inferred from `baseUrl` and `apiKey`. Pass `backend: "oss"` or `backend: "cloud"` to the constructor to override.
|
|
170
193
|
|
|
171
194
|
## Telemetry
|
|
172
195
|
|
|
@@ -204,65 +227,41 @@ try {
|
|
|
204
227
|
The SDK does not apply a retry policy. Provide a hook when you want one:
|
|
205
228
|
|
|
206
229
|
```ts
|
|
207
|
-
|
|
208
|
-
baseUrl: "http://localhost:7000",
|
|
209
|
-
retry: (err, attempt) => {
|
|
210
|
-
return err instanceof SERPError && err.status >= 500 && attempt < 2;
|
|
211
|
-
},
|
|
212
|
-
});
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
## Edge runtimes
|
|
230
|
+
import { OpenSERP, SERPError } from "@openserp/sdk";
|
|
216
231
|
|
|
217
|
-
|
|
232
|
+
const RETRYABLE = new Set([408, 429, 500, 502, 503]);
|
|
218
233
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
return Response.json(results);
|
|
234
|
+
const client = new OpenSERP({
|
|
235
|
+
apiKey: process.env.OPENSERP_KEY,
|
|
236
|
+
retry: async (err, attempt) => {
|
|
237
|
+
if (attempt >= 2 || !(err instanceof SERPError) || !RETRYABLE.has(err.status)) {
|
|
238
|
+
return false;
|
|
239
|
+
}
|
|
240
|
+
const wait = Math.min(2 ** attempt * 250, 8_000) + Math.random() * 250;
|
|
241
|
+
await new Promise((r) => setTimeout(r, wait));
|
|
242
|
+
return true;
|
|
229
243
|
},
|
|
230
|
-
};
|
|
231
|
-
```
|
|
232
|
-
|
|
233
|
-
Vercel Edge:
|
|
234
|
-
|
|
235
|
-
```ts
|
|
236
|
-
import { OpenSERP } from "@openserp/sdk";
|
|
237
|
-
|
|
238
|
-
export const runtime = "edge";
|
|
239
|
-
|
|
240
|
-
export async function GET() {
|
|
241
|
-
const client = new OpenSERP({ apiKey: process.env.OPENSERP_KEY });
|
|
242
|
-
return Response.json(await client.search({ engine: "google", text: "openserp" }));
|
|
243
|
-
}
|
|
244
|
+
});
|
|
244
245
|
```
|
|
245
246
|
|
|
246
247
|
## Use cases
|
|
247
248
|
|
|
248
249
|
- **AI grounding / RAG** — feed top-N search results into an LLM prompt (OpenAI, Anthropic, Ollama) for up-to-date answers.
|
|
249
|
-
- **LLM tool use** — expose `client.search` as a tool to your agent
|
|
250
|
+
- **LLM tool use** — expose `client.search` as a tool to your agent.
|
|
250
251
|
- **SEO monitoring** — daily rank tracking across multiple engines and regions, export to Sheets or Notion.
|
|
251
252
|
- **Competitor analysis** — weekly diff of top-10 results for a keyword set.
|
|
252
|
-
- **Automations** — drop the [`n8n-nodes-openserp`](https://www.npmjs.com/package/n8n-nodes-openserp) node into a workflow.
|
|
253
253
|
- **Data pipelines** — stream SERPs to ClickHouse, BigQuery, or a DataFrame for NLP on snippets.
|
|
254
254
|
|
|
255
255
|
## Development
|
|
256
256
|
|
|
257
257
|
```bash
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
corepack pnpm build
|
|
258
|
+
pnpm install
|
|
259
|
+
pnpm test
|
|
260
|
+
pnpm build
|
|
262
261
|
```
|
|
263
262
|
|
|
264
263
|
Regenerate OSS API types after changing `openserp/docs/openapi.yaml`:
|
|
265
264
|
|
|
266
265
|
```bash
|
|
267
|
-
|
|
266
|
+
pnpm generate:types
|
|
268
267
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openserp/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "TypeScript/JavaScript SDK for the OpenSERP self-hosted server and OpenSERP Cloud.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -8,8 +8,7 @@
|
|
|
8
8
|
"homepage": "https://openserp.org",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
|
-
"url": "https://github.com/karust/openserp.git"
|
|
12
|
-
"directory": "integrations/sdk-js"
|
|
11
|
+
"url": "git+https://github.com/karust/openserp.git"
|
|
13
12
|
},
|
|
14
13
|
"bugs": {
|
|
15
14
|
"url": "https://github.com/karust/openserp/issues"
|
|
@@ -17,15 +16,40 @@
|
|
|
17
16
|
"keywords": [
|
|
18
17
|
"openserp",
|
|
19
18
|
"serp",
|
|
19
|
+
"serp-api",
|
|
20
20
|
"search",
|
|
21
|
+
"search-api",
|
|
22
|
+
"google-search",
|
|
23
|
+
"google-search-api",
|
|
21
24
|
"google",
|
|
22
25
|
"bing",
|
|
23
26
|
"yandex",
|
|
24
27
|
"baidu",
|
|
25
28
|
"duckduckgo",
|
|
26
29
|
"ecosia",
|
|
30
|
+
"scraper",
|
|
31
|
+
"scraping",
|
|
32
|
+
"web-scraping",
|
|
33
|
+
"serpapi",
|
|
34
|
+
"serpapi-alternative",
|
|
27
35
|
"seo",
|
|
28
|
-
"
|
|
36
|
+
"rank-tracking",
|
|
37
|
+
"rank-tracker",
|
|
38
|
+
"keyword-research",
|
|
39
|
+
"ai",
|
|
40
|
+
"ai-grounding",
|
|
41
|
+
"rag",
|
|
42
|
+
"llm",
|
|
43
|
+
"llm-tools",
|
|
44
|
+
"agent",
|
|
45
|
+
"agent-tools",
|
|
46
|
+
"tool-use",
|
|
47
|
+
"openai",
|
|
48
|
+
"anthropic",
|
|
49
|
+
"mcp",
|
|
50
|
+
"typescript",
|
|
51
|
+
"nodejs",
|
|
52
|
+
"edge-runtime"
|
|
29
53
|
],
|
|
30
54
|
"sideEffects": false,
|
|
31
55
|
"exports": {
|