@crawlora-org/sdk 1.2.0-sdk.12 → 1.2.0-sdk.14

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/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## v1.2.0-sdk.14
4
+
5
+ - Aligned the promoted SDK beta tag with the Python and Go SDKs.
6
+ - Added explicit coverage for request-level header overrides.
7
+
8
+ ## v1.2.0-sdk.13
9
+
10
+ - Updated the published npmjs package homepage to `https://crawlora.net`.
11
+
3
12
  ## v1.2.0-sdk.12
4
13
 
5
14
  - Added tag/manual CI/CD workflows for npmjs publishing and GitHub Packages
package/README.md CHANGED
@@ -1,96 +1,154 @@
1
1
  # Crawlora JavaScript SDK
2
2
 
3
- JavaScript and TypeScript SDK for the public Crawlora API. It works in Node.js
4
- 18+ and modern runtimes with `fetch`.
3
+ Official JavaScript and TypeScript client for the public Crawlora API. Use it
4
+ to call Crawlora scraping, search, marketplace, media, maps, finance, and usage
5
+ endpoints with a small `fetch`-based client and generated TypeScript types.
5
6
 
6
- Website: [crawlora.net](https://crawlora.net)
7
+ - Runtime: Node.js 18+ or any modern runtime with `fetch`
8
+ - Auth: `x-api-key`
9
+ - Default API base URL: `https://api.crawlora.net/api/v1`
10
+ - Reference: [operations](docs/operations.md) and [recipes](docs/recipes.md)
7
11
 
8
12
  ## Install
9
13
 
14
+ Install the latest published npm package:
15
+
16
+ ```sh
17
+ npm install @crawlora-org/sdk
18
+ ```
19
+
20
+ For reproducible builds, pin a published package version:
21
+
10
22
  ```sh
11
- npm install @crawlora-org/sdk@latest
23
+ npm install @crawlora-org/sdk@VERSION
12
24
  ```
13
25
 
14
- For reproducible builds, pin the current package version:
26
+ ## API Key
27
+
28
+ Create or sign in to your Crawlora account at [crawlora.net](https://crawlora.net),
29
+ then create an API key in the dashboard.
15
30
 
16
31
  ```sh
17
- npm install @crawlora-org/sdk@1.2.0-sdk.12
32
+ read -r CRAWLORA_API_KEY
33
+ export CRAWLORA_API_KEY
18
34
  ```
19
35
 
20
- ## Usage
36
+ ## First Request
21
37
 
22
38
  ```js
23
39
  import { CrawloraClient } from "@crawlora-org/sdk";
24
40
 
25
- const crawlora = new CrawloraClient({ apiKey: process.env.CRAWLORA_API_KEY });
26
- const result = await crawlora.bing.search({ q: "coffee shops", count: 10 });
27
- console.log(result);
41
+ const crawlora = new CrawloraClient({
42
+ apiKey: process.env.CRAWLORA_API_KEY
43
+ });
44
+
45
+ const response = await crawlora.bing.search({
46
+ q: "coffee shops",
47
+ count: 10
48
+ });
49
+
50
+ console.log(response.data?.results?.[0]);
28
51
  ```
29
52
 
30
- Generated TypeScript declarations cover operation ids, endpoint groups,
31
- parameter objects, enum values, request options, and response aliases.
32
- Dynamic calls infer parameter and response types from literal operation ids:
53
+ Endpoint groups are generated from the public API contract, so common calls are
54
+ available as methods such as `crawlora.bing.search(...)`,
55
+ `crawlora.youtube.transcript(...)`, and `crawlora.google.mapSearch(...)`.
56
+
57
+ ## Typed Dynamic Calls
58
+
59
+ You can also call by operation id. Literal operation ids infer parameter and
60
+ response types in TypeScript:
33
61
 
34
62
  ```ts
35
- const result = await crawlora.request("bing-search", { q: "coffee shops" });
36
- result.data?.results?.[0]?.title;
63
+ const response = await crawlora.request("bing-search", {
64
+ q: "coffee shops",
65
+ count: 10
66
+ });
67
+
68
+ response.data?.results?.[0]?.title;
37
69
  ```
38
70
 
71
+ Generated declarations include operation ids, endpoint groups, request
72
+ parameters, enum values, response aliases, and request options.
73
+
39
74
  ## Configuration
40
75
 
41
76
  ```js
42
77
  const crawlora = new CrawloraClient({
43
78
  apiKey: process.env.CRAWLORA_API_KEY,
44
79
  baseUrl: "https://api.crawlora.net/api/v1",
80
+ timeout: 30_000,
45
81
  retries: 2,
46
82
  retryDelay: 250,
47
- headers: { "x-client": "example" }
83
+ headers: {
84
+ "x-client": "my-app"
85
+ }
48
86
  });
49
87
  ```
50
88
 
51
- Per-request options support headers, timeout, abort signals, and response mode:
89
+ Per-request options can override headers, timeout, abort signal, and response
90
+ mode:
52
91
 
53
92
  ```js
54
- const text = await crawlora.youtube.transcript(
55
- { id: "VIDEO_ID", format: "text" },
56
- { responseType: "text", timeout: 10000 }
93
+ const controller = new AbortController();
94
+
95
+ const response = await crawlora.bing.search(
96
+ { q: "coffee shops" },
97
+ {
98
+ timeout: 10_000,
99
+ signal: controller.signal,
100
+ headers: { "x-request-id": "search-001" }
101
+ }
57
102
  );
58
103
  ```
59
104
 
60
- Failed API calls throw `CrawloraError` with `status`, optional API `code`,
61
- parsed `body`, and the original `response` when available.
105
+ ## Text Responses
62
106
 
63
- ## Reference
107
+ Most endpoints return JSON. Endpoints that support alternate text output, such
108
+ as YouTube transcripts, can opt into text mode:
64
109
 
65
- - [Operation reference](docs/operations.md)
66
- - [Usage recipes](docs/recipes.md)
110
+ ```js
111
+ const transcript = await crawlora.youtube.transcript(
112
+ { id: "VIDEO_ID", format: "text" },
113
+ { responseType: "text" }
114
+ );
67
115
 
68
- ## Examples
116
+ console.log(transcript);
117
+ ```
69
118
 
70
- Runnable examples live under `examples/`:
119
+ ## Errors
71
120
 
72
- ```sh
73
- CRAWLORA_API_KEY=... npm run example:bing-search
74
- CRAWLORA_API_KEY=... CRAWLORA_YOUTUBE_VIDEO_ID=... npm run example:youtube-transcript
121
+ Failed API calls throw `CrawloraError`:
122
+
123
+ ```js
124
+ import { CrawloraClient, CrawloraError } from "@crawlora-org/sdk";
125
+
126
+ try {
127
+ await crawlora.bing.search({ q: "coffee shops" });
128
+ } catch (error) {
129
+ if (error instanceof CrawloraError) {
130
+ console.error(error.status, error.code, error.body);
131
+ }
132
+ throw error;
133
+ }
75
134
  ```
76
135
 
77
- Each example also accepts `CRAWLORA_BASE_URL` for staging or local API testing.
78
- The examples exit without making a request when the required live environment
79
- variables are not set. `npm run smoke:live` runs all live examples in sequence.
136
+ The error includes `status`, optional API `code`, parsed `body`, the original
137
+ `response` when available, and a parser or transport `cause` when relevant.
80
138
 
81
- ## Versioning
139
+ ## Examples
82
140
 
83
- This SDK is published to npmjs and mirrored to GitHub Packages. The package
84
- `latest` dist-tag and the moving Git tag named `latest` track the current
85
- promoted beta. Explicit package versions and Git beta tags such as
86
- `1.2.0-sdk.12` / `v1.2.0-sdk.12` remain available for reproducible builds. Pin
87
- an explicit version in production applications and upgrade intentionally.
141
+ Runnable examples live under `examples/` and skip cleanly when required
142
+ environment variables are missing:
88
143
 
89
- GitHub Packages installs require a project `.npmrc` that maps the
90
- `@crawlora-org` scope to `https://npm.pkg.github.com` and a GitHub token that
91
- can read packages.
144
+ ```sh
145
+ npm run example:bing-search
146
+ npm run example:youtube-transcript
147
+ ```
148
+
149
+ Set `CRAWLORA_BASE_URL` to point examples at a staging or local API.
92
150
 
93
- ## Package Name
151
+ ## Package Notes
94
152
 
95
153
  The npm package name is `@crawlora-org/sdk`:
96
154
 
@@ -98,11 +156,10 @@ The npm package name is `@crawlora-org/sdk`:
98
156
  import { CrawloraClient } from "@crawlora-org/sdk";
99
157
  ```
100
158
 
101
- The package names `crawlora` and `@crawlora/sdk` are not used by this repository
102
- because they already exist on npm and point to a different package source.
103
-
104
- ## Optional Live Smoke Test
159
+ The package names `crawlora` and `@crawlora/sdk` are not used by this
160
+ repository because they already exist on npm and point to different package
161
+ sources.
105
162
 
106
- Default tests use mock `fetch` implementations. The programs under `examples/`
107
- can be used as optional live smoke tests when `CRAWLORA_API_KEY` is available.
108
- Live calls are not part of default CI.
163
+ This SDK is published to npmjs and may also be mirrored to GitHub Packages. Pin
164
+ an explicit published version for production applications and upgrade
165
+ intentionally.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crawlora-org/sdk",
3
- "version": "1.2.0-sdk.12",
3
+ "version": "1.2.0-sdk.14",
4
4
  "description": "JavaScript and TypeScript SDK for the public Crawlora API.",
5
5
  "keywords": [
6
6
  "crawlora",
@@ -8,7 +8,7 @@
8
8
  "web-scraping",
9
9
  "api-client"
10
10
  ],
11
- "homepage": "https://github.com/Crawlora-org/crawlora-typescript-sdk#readme",
11
+ "homepage": "https://crawlora.net",
12
12
  "bugs": {
13
13
  "url": "https://github.com/Crawlora-org/crawlora-typescript-sdk/issues"
14
14
  },
package/src/client.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { operations, groups } from "./operations.js";
2
2
 
3
3
  const DEFAULT_BASE_URL = "https://api.crawlora.net/api/v1";
4
- export const VERSION = "1.2.0-sdk.12";
4
+ export const VERSION = "1.2.0-sdk.14";
5
5
  const DEFAULT_USER_AGENT = `crawlora-js-sdk/${VERSION}`;
6
6
 
7
7
  export class CrawloraError extends Error {