@openserp/sdk 0.1.1 → 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.
Files changed (2) hide show
  1. package/README.md +46 -16
  2. package/package.json +28 -4
package/README.md CHANGED
@@ -4,9 +4,37 @@
4
4
  [![npm downloads](https://img.shields.io/npm/dm/@openserp/sdk.svg)](https://www.npmjs.com/package/@openserp/sdk)
5
5
  [![license](https://img.shields.io/npm/l/@openserp/sdk.svg)](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 monitoring, competitor analysis, and search-powered automations. Open-source alternative to SerpAPI and DataForSEO.
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`. Override explicitly when needed:
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,10 +227,19 @@ try {
204
227
  The SDK does not apply a retry policy. Provide a hook when you want one:
205
228
 
206
229
  ```ts
230
+ import { OpenSERP, SERPError } from "@openserp/sdk";
231
+
232
+ const RETRYABLE = new Set([408, 429, 500, 502, 503]);
233
+
207
234
  const client = new OpenSERP({
208
- baseUrl: "http://localhost:7000",
209
- retry: (err, attempt) => {
210
- return err instanceof SERPError && err.status >= 500 && attempt < 2;
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;
211
243
  },
212
244
  });
213
245
  ```
@@ -218,20 +250,18 @@ const client = new OpenSERP({
218
250
  - **LLM tool use** — expose `client.search` as a tool to your agent.
219
251
  - **SEO monitoring** — daily rank tracking across multiple engines and regions, export to Sheets or Notion.
220
252
  - **Competitor analysis** — weekly diff of top-10 results for a keyword set.
221
- - **Automations**
222
253
  - **Data pipelines** — stream SERPs to ClickHouse, BigQuery, or a DataFrame for NLP on snippets.
223
254
 
224
255
  ## Development
225
256
 
226
257
  ```bash
227
- corepack enable
228
- corepack pnpm install
229
- corepack pnpm test
230
- corepack pnpm build
258
+ pnpm install
259
+ pnpm test
260
+ pnpm build
231
261
  ```
232
262
 
233
263
  Regenerate OSS API types after changing `openserp/docs/openapi.yaml`:
234
264
 
235
265
  ```bash
236
- corepack pnpm generate:types
266
+ pnpm generate:types
237
267
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openserp/sdk",
3
- "version": "0.1.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
- "ai-grounding"
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": {