@mrscraper/sdk 1.0.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 MrScraper
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,387 @@
1
+ ---
2
+ name: MrScraper Node SDK
3
+ description: Run AI-powered, unblockable web scraping, data extraction with natural language using MrScraper Node SDK
4
+ tags: [scraping, data-extraction, web-crawling, stealth-browser, web-automation]
5
+ homepage: https://mrscraper.com/
6
+ support_email: support@mrscraper.com
7
+ ---
8
+
9
+ # @mrscraper/sdk
10
+ ![](./mrscraper.jpeg)
11
+
12
+ Official Node.js SDK for the [MrScraper](https://mrscraper.com) API.
13
+
14
+ Scrape any data from any websites.
15
+ Unblock pages, create and scale AI scrapers, manual scrapers, and retrieve results synchronously and asynchronously.
16
+ It is stealth, reliable, and scalable.
17
+ Every action is mirrored on our platform https://app.mrscraper.com
18
+
19
+ [![npm version](https://img.shields.io/npm/v/@mrscraper/sdk)](https://www.npmjs.com/package/@mrscraper/sdk)
20
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](./LICENSE)
21
+
22
+ ## Table of Contents
23
+
24
+ - [Installation](#installation)
25
+ - [Requirements](#requirements)
26
+ - [Authentication](#authentication)
27
+ - [Quick Start](#quick-start)
28
+ - [Error Handling](#error-handling)
29
+ - [API Reference](#api-reference)
30
+ - [fetchHtml](#fetchhtml)
31
+ - [createAiScraper](#createaiscraper)
32
+ - [rerunAiScraper](#rerunaiscraper)
33
+ - [bulkRerunAiScraper](#bulkrerunaiscraper)
34
+ - [rerunManualScraper](#rerunmanualscraper)
35
+ - [bulkRerunManualScraper](#bulkrerunmanualscraper)
36
+ - [getAllResults](#getallresults)
37
+ - [getResultById](#getresultbyid)
38
+ - [TypeScript](#typescript)
39
+ - [License](#license)
40
+
41
+ ---
42
+
43
+ ## Installation
44
+
45
+ ```bash
46
+ npm install @mrscraper/sdk
47
+ ```
48
+
49
+ ## Requirements
50
+
51
+ - Node.js >= 18
52
+
53
+ ## Authentication
54
+
55
+ Get your API token from your [MrScraper dashboard](https://app.mrscraper.com) and set it as an environment variable:
56
+
57
+ ```bash
58
+ export MRSCRAPER_API_TOKEN=your_token_here
59
+ ```
60
+
61
+ Every function also accepts an optional `token` parameter to override the environment variable on a per-call basis.
62
+
63
+ ---
64
+
65
+ ## Quick Start
66
+
67
+ ```typescript
68
+ import { fetchHtml, createAiScraper, getResultById, MrScraperError } from "@mrscraper/sdk";
69
+
70
+ try {
71
+ // 1. Fetch raw HTML of a page
72
+ const html = await fetchHtml({ url: "https://example.com" });
73
+ console.log(html);
74
+
75
+ // 2. Create an AI scraper and get its result
76
+ const scraper = await createAiScraper({
77
+ url: "https://example.com/products",
78
+ message: "Extract all product names and prices",
79
+ agent: "listing",
80
+ });
81
+ console.log(scraper);
82
+ } catch (err) {
83
+ if (err instanceof MrScraperError) {
84
+ console.error(`[${err.status ?? "network"}] ${err.message}`);
85
+ } else {
86
+ throw err;
87
+ }
88
+ }
89
+ ```
90
+
91
+ ---
92
+
93
+ ## Error Handling
94
+
95
+ All functions throw a `MrScraperError` on failure — whether the error comes from the API (4xx/5xx), a network issue, or a timeout. You never need to check a return value; just wrap calls in `try/catch`.
96
+
97
+ ```typescript
98
+ import { MrScraperError } from "@mrscraper/sdk";
99
+
100
+ try {
101
+ const html = await fetchHtml({ url: "https://example.com" });
102
+ } catch (err) {
103
+ if (err instanceof MrScraperError) {
104
+ console.error(err.message); // Human-readable error message
105
+ console.error(err.status); // HTTP status code, or undefined for network errors
106
+ }
107
+ }
108
+ ```
109
+
110
+ **`MrScraperError` properties:**
111
+
112
+ | Property | Type | Description |
113
+ |----------|------|-------------|
114
+ | `message` | `string` | Human-readable description of the error |
115
+ | `status` | `number \| undefined` | HTTP status code (e.g. `401`, `429`, `500`). `undefined` for network/timeout errors |
116
+ | `name` | `string` | Always `"MrScraperError"` |
117
+
118
+ ---
119
+
120
+ ## API Reference
121
+
122
+ ### `fetchHtml`
123
+
124
+ Fetches the raw HTML (or JSON) of any URL through MrScraper's Fetch endpoint.
125
+
126
+ ```typescript
127
+ const html = await fetchHtml({
128
+ url: "https://example.com", // required
129
+ timeout: 120, // optional – seconds (1–600), default: 120
130
+ geoCode: "US", // optional – 2-letter country code, default: "US"
131
+ blockResources: false, // optional – block images/CSS/fonts, default: false
132
+ token: "your_token", // optional – overrides MRSCRAPER_API_TOKEN
133
+ });
134
+ ```
135
+
136
+ **Options:**
137
+
138
+ | Parameter | Type | Required | Default | Description |
139
+ |-----------|------|----------|---------|-------------|
140
+ | `url` | `string` | Yes | — | The URL to fetch |
141
+ | `timeout` | `number` | No | `120` | Request timeout in seconds (1–600) |
142
+ | `geoCode` | `string` | No | `"US"` | Two-letter ISO country code for geo-targeting |
143
+ | `blockResources` | `boolean` | No | `false` | Block images, fonts, and CSS to speed up the request |
144
+ | `token` | `string` | No | — | Overrides the `MRSCRAPER_API_TOKEN` environment variable |
145
+
146
+ **Returns:** `Promise<string>` — the raw HTML (or JSON string) of the page.
147
+
148
+ ---
149
+
150
+ ### `createAiScraper`
151
+
152
+ Creates a new AI scraper. Supports three agent types:
153
+
154
+ - **`general`** — extracts structured data based on your natural-language `message`
155
+ - **`listing`** — optimised for list/collection pages (products, jobs, articles, etc.)
156
+ - **`map`** — crawls a site to discover and map all URLs
157
+
158
+ ```typescript
159
+ // General / listing agent
160
+ const scraper = await createAiScraper({
161
+ url: "https://example.com/products",
162
+ message: "Extract all product names and prices",
163
+ agent: "listing", // "general" | "listing" | "map", default: "general"
164
+ proxyCountry: "US", // optional
165
+ });
166
+
167
+ // Map agent
168
+ const scraper = await createAiScraper({
169
+ url: "https://example.com",
170
+ agent: "map",
171
+ maxDepth: 2, // optional – default: 2
172
+ maxPages: 50, // optional – default: 50
173
+ limit: 1000, // optional – default: 1000
174
+ includePatterns: "/blog", // optional
175
+ excludePatterns: "/admin", // optional
176
+ });
177
+ ```
178
+
179
+ **Options:**
180
+
181
+ | Parameter | Type | Required | Default | Description |
182
+ |-----------|------|----------|---------|-------------|
183
+ | `url` | `string` | Yes | — | Starting URL to scrape |
184
+ | `message` | `string` | No | `""` | Natural-language instructions (general/listing agents) |
185
+ | `agent` | `"general" \| "listing" \| "map"` | No | `"general"` | Agent type |
186
+ | `proxyCountry` | `string \| null` | No | — | Two-letter proxy country code (general/listing) |
187
+ | `maxDepth` | `number` | No | `2` | Max crawl depth, 0–5 (map agent) |
188
+ | `maxPages` | `number` | No | `50` | Max pages to crawl, 1–1000 (map agent) |
189
+ | `limit` | `number` | No | `1000` | Max results to return, 1–100000 (map agent) |
190
+ | `includePatterns` | `string` | No | `""` | URL patterns to include (map agent) |
191
+ | `excludePatterns` | `string` | No | `""` | URL patterns to exclude (map agent) |
192
+ | `token` | `string` | No | — | Overrides the `MRSCRAPER_API_TOKEN` environment variable |
193
+
194
+ **Returns:** `Promise<unknown>` — the API response object.
195
+
196
+ ---
197
+
198
+ ### `rerunAiScraper`
199
+
200
+ Reruns an existing AI scraper on a new URL.
201
+
202
+ ```typescript
203
+ const result = await rerunAiScraper({
204
+ scraperId: "your-scraper-id", // required
205
+ url: "https://example.com/new-page", // required
206
+ maxDepth: 2, // optional
207
+ maxPages: 50, // optional
208
+ limit: 1000, // optional
209
+ includePatterns: "", // optional
210
+ excludePatterns: "", // optional
211
+ });
212
+ ```
213
+
214
+ **Options:**
215
+
216
+ | Parameter | Type | Required | Default | Description |
217
+ |-----------|------|----------|---------|-------------|
218
+ | `scraperId` | `string` | Yes | — | ID of the AI scraper to rerun |
219
+ | `url` | `string` | Yes | — | New URL to scrape |
220
+ | `maxDepth` | `number` | No | `2` | Max crawl depth (0–5) |
221
+ | `maxPages` | `number` | No | `50` | Max pages (1–1000) |
222
+ | `limit` | `number` | No | `1000` | Max results (1–100000) |
223
+ | `includePatterns` | `string` | No | `""` | URL patterns to include |
224
+ | `excludePatterns` | `string` | No | `""` | URL patterns to exclude |
225
+ | `token` | `string` | No | — | Overrides the `MRSCRAPER_API_TOKEN` environment variable |
226
+
227
+ **Returns:** `Promise<unknown>` — the API response object.
228
+
229
+ ---
230
+
231
+ ### `bulkRerunAiScraper`
232
+
233
+ Reruns an AI scraper on multiple URLs at once.
234
+
235
+ ```typescript
236
+ const result = await bulkRerunAiScraper({
237
+ scraperId: "your-scraper-id",
238
+ urls: [
239
+ "https://example.com/page1",
240
+ "https://example.com/page2",
241
+ ],
242
+ });
243
+ ```
244
+
245
+ **Options:**
246
+
247
+ | Parameter | Type | Required | Description |
248
+ |-----------|------|----------|-------------|
249
+ | `scraperId` | `string` | Yes | ID of the AI scraper to rerun |
250
+ | `urls` | `string[]` | Yes | List of URLs to scrape |
251
+ | `token` | `string` | No | Overrides the `MRSCRAPER_API_TOKEN` environment variable |
252
+
253
+ **Returns:** `Promise<unknown>` — the API response object.
254
+
255
+ ---
256
+
257
+ ### `rerunManualScraper`
258
+
259
+ Reruns a manual (dashboard-configured) scraper on a URL.
260
+
261
+ ```typescript
262
+ const result = await rerunManualScraper({
263
+ scraperId: "your-scraper-id",
264
+ url: "https://example.com/target",
265
+ });
266
+ ```
267
+
268
+ **Options:**
269
+
270
+ | Parameter | Type | Required | Description |
271
+ |-----------|------|----------|-------------|
272
+ | `scraperId` | `string` | Yes | ID of the manual scraper to rerun |
273
+ | `url` | `string` | Yes | URL to scrape |
274
+ | `token` | `string` | No | Overrides the `MRSCRAPER_API_TOKEN` environment variable |
275
+
276
+ **Returns:** `Promise<unknown>` — the API response object.
277
+
278
+ ---
279
+
280
+ ### `bulkRerunManualScraper`
281
+
282
+ Reruns a manual scraper on multiple URLs at once.
283
+
284
+ ```typescript
285
+ const result = await bulkRerunManualScraper({
286
+ scraperId: "your-scraper-id",
287
+ urls: [
288
+ "https://example.com/a",
289
+ "https://example.com/b",
290
+ ],
291
+ });
292
+ ```
293
+
294
+ **Options:**
295
+
296
+ | Parameter | Type | Required | Description |
297
+ |-----------|------|----------|-------------|
298
+ | `scraperId` | `string` | Yes | ID of the manual scraper to rerun |
299
+ | `urls` | `string[]` | Yes | List of URLs to scrape |
300
+ | `token` | `string` | No | Overrides the `MRSCRAPER_API_TOKEN` environment variable |
301
+
302
+ **Returns:** `Promise<unknown>` — the API response object.
303
+
304
+ ---
305
+
306
+ ### `getAllResults`
307
+
308
+ Lists scraping results with sorting, pagination, search, and date range filters. All options are optional.
309
+
310
+ ```typescript
311
+ const results = await getAllResults({
312
+ sortField: "updatedAt", // default
313
+ sortOrder: "DESC", // default
314
+ pageSize: 10, // default
315
+ page: 1, // default
316
+ search: "example.com", // optional
317
+ dateRangeColumn: "createdAt", // optional
318
+ startAt: "2024-01-01T00:00:00Z", // optional – ISO 8601
319
+ endAt: "2024-12-31T23:59:59Z", // optional – ISO 8601
320
+ });
321
+ ```
322
+
323
+ **Options:**
324
+
325
+ | Parameter | Type | Default | Description |
326
+ |-----------|------|---------|-------------|
327
+ | `sortField` | `SortField` | `"updatedAt"` | Field to sort by |
328
+ | `sortOrder` | `"ASC" \| "DESC"` | `"DESC"` | Sort direction |
329
+ | `pageSize` | `number` | `10` | Results per page (1–500) |
330
+ | `page` | `number` | `1` | Page number (1-based) |
331
+ | `search` | `string` | — | Full-text search query |
332
+ | `dateRangeColumn` | `string` | — | Column to filter by date range |
333
+ | `startAt` | `string` | — | Start of date range (ISO 8601) |
334
+ | `endAt` | `string` | — | End of date range (ISO 8601) |
335
+ | `token` | `string` | — | Overrides the `MRSCRAPER_API_TOKEN` environment variable |
336
+
337
+ **`SortField` values:** `"createdAt"` `"updatedAt"` `"id"` `"type"` `"url"` `"status"` `"error"` `"tokenUsage"` `"runtime"`
338
+
339
+ **Returns:** `Promise<unknown>` — paginated list of results.
340
+
341
+ ---
342
+
343
+ ### `getResultById`
344
+
345
+ Fetches a single scraping result by its ID.
346
+
347
+ ```typescript
348
+ const result = await getResultById({ resultId: "your-result-id" });
349
+ console.log(result);
350
+ ```
351
+
352
+ **Options:**
353
+
354
+ | Parameter | Type | Required | Description |
355
+ |-----------|------|----------|-------------|
356
+ | `resultId` | `string` | Yes | ID of the result to fetch |
357
+ | `token` | `string` | No | Overrides the `MRSCRAPER_API_TOKEN` environment variable |
358
+
359
+ **Returns:** `Promise<unknown>` — the result object.
360
+
361
+ ---
362
+
363
+ ## TypeScript
364
+
365
+ All option interfaces and shared types are exported for use in your own code:
366
+
367
+ ```typescript
368
+ import type {
369
+ FetchHtmlOptions,
370
+ CreateAiScraperOptions,
371
+ RerunAiScraperOptions,
372
+ BulkRerunAiScraperOptions,
373
+ RerunManualScraperOptions,
374
+ BulkRerunManualScraperOptions,
375
+ GetAllResultsOptions,
376
+ GetResultByIdOptions,
377
+ ScraperAgent,
378
+ SortField,
379
+ SortOrder,
380
+ } from "@mrscraper/sdk";
381
+ ```
382
+
383
+ ---
384
+
385
+ ## License
386
+
387
+ MIT — see [LICENSE](./LICENSE)
package/dist/api.d.ts ADDED
@@ -0,0 +1,151 @@
1
+ export declare class MrScraperError extends Error {
2
+ /** HTTP status code, if the error came from the API. Undefined for network/timeout errors. */
3
+ readonly status: number | undefined;
4
+ constructor(message: string, status?: number);
5
+ }
6
+ export type ScraperAgent = "general" | "listing" | "map";
7
+ export type SortField = "createdAt" | "updatedAt" | "id" | "type" | "url" | "status" | "error" | "tokenUsage" | "runtime";
8
+ export type SortOrder = "ASC" | "DESC";
9
+ export interface FetchHtmlOptions {
10
+ /** The URL to fetch. */
11
+ url: string;
12
+ /** Request timeout in seconds (1–600). Defaults to 120. */
13
+ timeout?: number;
14
+ /** Two-letter ISO country code for geo-targeting. Defaults to "US". */
15
+ geoCode?: string;
16
+ /** Block images/fonts/css to speed up the request. Defaults to false. */
17
+ blockResources?: boolean;
18
+ /** Override the global MRSCRAPER_API_TOKEN for this call. */
19
+ token?: string;
20
+ }
21
+ /**
22
+ * Fetch the raw HTML (or JSON) of any URL through MrScraper's Fetch endpoint.
23
+ * Throws {@link MrScraperError} on API or network errors.
24
+ */
25
+ export declare function fetchHtml<T = string>(options: FetchHtmlOptions): Promise<T>;
26
+ export interface CreateAiScraperOptions {
27
+ /** The starting URL to scrape. */
28
+ url: string;
29
+ /** Natural-language instructions for the AI (general/listing agents). */
30
+ message?: string;
31
+ /** Scraper agent type. Defaults to "general". */
32
+ agent?: ScraperAgent;
33
+ /** Two-letter proxy country code (general/listing agents). */
34
+ proxyCountry?: string | null;
35
+ /** Maximum crawl depth for map agent (0–5). Defaults to 2. */
36
+ maxDepth?: number;
37
+ /** Maximum pages for map agent (1–1000). Defaults to 50. */
38
+ maxPages?: number;
39
+ /** Maximum results for map agent (1–100000). Defaults to 1000. */
40
+ limit?: number;
41
+ /** URL patterns to include (map agent). */
42
+ includePatterns?: string;
43
+ /** URL patterns to exclude (map agent). */
44
+ excludePatterns?: string;
45
+ /** Override the global MRSCRAPER_API_TOKEN for this call. */
46
+ token?: string;
47
+ }
48
+ /**
49
+ * Create a new AI scraper (general, listing, or map).
50
+ * Throws {@link MrScraperError} on API or network errors.
51
+ */
52
+ export declare function createAiScraper<T = unknown>(options: CreateAiScraperOptions): Promise<T>;
53
+ export interface RerunAiScraperOptions {
54
+ /** The ID of the AI scraper to rerun. */
55
+ scraperId: string;
56
+ /** New URL to scrape. */
57
+ url: string;
58
+ /** Maximum crawl depth (0–5). Defaults to 2. */
59
+ maxDepth?: number;
60
+ /** Maximum pages (1–1000). Defaults to 50. */
61
+ maxPages?: number;
62
+ /** Maximum results (1–100000). Defaults to 1000. */
63
+ limit?: number;
64
+ /** URL patterns to include. */
65
+ includePatterns?: string;
66
+ /** URL patterns to exclude. */
67
+ excludePatterns?: string;
68
+ /** Override the global MRSCRAPER_API_TOKEN for this call. */
69
+ token?: string;
70
+ }
71
+ /**
72
+ * Rerun an existing AI scraper on a new URL.
73
+ * Throws {@link MrScraperError} on API or network errors.
74
+ */
75
+ export declare function rerunAiScraper<T = unknown>(options: RerunAiScraperOptions): Promise<T>;
76
+ export interface BulkRerunAiScraperOptions {
77
+ /** The ID of the AI scraper to rerun. */
78
+ scraperId: string;
79
+ /** List of URLs to scrape. */
80
+ urls: string[];
81
+ /** Override the global MRSCRAPER_API_TOKEN for this call. */
82
+ token?: string;
83
+ }
84
+ /**
85
+ * Rerun an AI scraper on multiple URLs at once.
86
+ * Throws {@link MrScraperError} on API or network errors.
87
+ */
88
+ export declare function bulkRerunAiScraper<T = unknown>(options: BulkRerunAiScraperOptions): Promise<T>;
89
+ export interface RerunManualScraperOptions {
90
+ /** The ID of the manual scraper to rerun. */
91
+ scraperId: string;
92
+ /** URL to scrape. */
93
+ url: string;
94
+ /** Override the global MRSCRAPER_API_TOKEN for this call. */
95
+ token?: string;
96
+ }
97
+ /**
98
+ * Rerun a manual (dashboard-configured) scraper on a URL.
99
+ * Throws {@link MrScraperError} on API or network errors.
100
+ */
101
+ export declare function rerunManualScraper<T = unknown>(options: RerunManualScraperOptions): Promise<T>;
102
+ export interface BulkRerunManualScraperOptions {
103
+ /** The ID of the manual scraper to rerun. */
104
+ scraperId: string;
105
+ /** List of URLs to scrape. */
106
+ urls: string[];
107
+ /** Override the global MRSCRAPER_API_TOKEN for this call. */
108
+ token?: string;
109
+ }
110
+ /**
111
+ * Rerun a manual scraper on multiple URLs at once.
112
+ * Throws {@link MrScraperError} on API or network errors.
113
+ */
114
+ export declare function bulkRerunManualScraper<T = unknown>(options: BulkRerunManualScraperOptions): Promise<T>;
115
+ export interface GetAllResultsOptions {
116
+ /** Field to sort by. Defaults to "updatedAt". */
117
+ sortField?: SortField;
118
+ /** Sort direction. Defaults to "DESC". */
119
+ sortOrder?: SortOrder;
120
+ /** Number of results per page (1–500). Defaults to 10. */
121
+ pageSize?: number;
122
+ /** Page number (1-based). Defaults to 1. */
123
+ page?: number;
124
+ /** Full-text search query. */
125
+ search?: string;
126
+ /** Column to use for date range filtering. */
127
+ dateRangeColumn?: string;
128
+ /** Start of date range (ISO 8601). */
129
+ startAt?: string;
130
+ /** End of date range (ISO 8601). */
131
+ endAt?: string;
132
+ /** Override the global MRSCRAPER_API_TOKEN for this call. */
133
+ token?: string;
134
+ }
135
+ /**
136
+ * List scraping results with sorting, pagination, search, and date filters.
137
+ * Throws {@link MrScraperError} on API or network errors.
138
+ */
139
+ export declare function getAllResults<T = unknown>(options?: GetAllResultsOptions): Promise<T>;
140
+ export interface GetResultByIdOptions {
141
+ /** The ID of the result to fetch. */
142
+ resultId: string;
143
+ /** Override the global MRSCRAPER_API_TOKEN for this call. */
144
+ token?: string;
145
+ }
146
+ /**
147
+ * Fetch a single scraping result by its ID.
148
+ * Throws {@link MrScraperError} on API or network errors.
149
+ */
150
+ export declare function getResultById<T = unknown>(options: GetResultByIdOptions): Promise<T>;
151
+ //# sourceMappingURL=api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAMA,qBAAa,cAAe,SAAQ,KAAK;IACvC,8FAA8F;IAC9F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C,GAAG,OAAO,EAC7C,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,CAAC,CAAC,CAgBZ"}
package/dist/api.js ADDED
@@ -0,0 +1,218 @@
1
+ import { URL, URLSearchParams } from "node:url";
2
+ // ---------------------------------------------------------------------------
3
+ // Error class
4
+ // ---------------------------------------------------------------------------
5
+ export class MrScraperError extends Error {
6
+ /** HTTP status code, if the error came from the API. Undefined for network/timeout errors. */
7
+ status;
8
+ constructor(message, status) {
9
+ super(message);
10
+ this.name = "MrScraperError";
11
+ this.status = status;
12
+ }
13
+ }
14
+ // ---------------------------------------------------------------------------
15
+ // Internal helpers
16
+ // ---------------------------------------------------------------------------
17
+ function requireToken(explicitToken) {
18
+ const token = explicitToken ?? process.env.MRSCRAPER_API_TOKEN;
19
+ if (!token) {
20
+ throw new MrScraperError("Missing API token. Pass it as an argument or set the MRSCRAPER_API_TOKEN environment variable. Get your token at https://app.mrscraper.com.");
21
+ }
22
+ return token;
23
+ }
24
+ async function request(url, init, timeoutMs) {
25
+ const controller = new AbortController();
26
+ const t = setTimeout(() => controller.abort(), timeoutMs);
27
+ try {
28
+ const res = await fetch(url, { ...init, signal: controller.signal });
29
+ const contentType = res.headers.get("content-type")?.toLowerCase() ?? "";
30
+ const data = contentType.includes("application/json")
31
+ ? await res.json()
32
+ : await res.text();
33
+ if (res.status === 401) {
34
+ throw new MrScraperError("Unauthorized or invalid API token.", 401);
35
+ }
36
+ if (!res.ok) {
37
+ const message = typeof data === "string" ? data : JSON.stringify(data);
38
+ throw new MrScraperError(message, res.status);
39
+ }
40
+ return data;
41
+ }
42
+ catch (e) {
43
+ if (e instanceof MrScraperError)
44
+ throw e;
45
+ throw new MrScraperError(e?.message ?? String(e));
46
+ }
47
+ finally {
48
+ clearTimeout(t);
49
+ }
50
+ }
51
+ /**
52
+ * Fetch the raw HTML (or JSON) of any URL through MrScraper's Fetch endpoint.
53
+ * Throws {@link MrScraperError} on API or network errors.
54
+ */
55
+ export async function fetchHtml(options) {
56
+ const token = requireToken(options.token);
57
+ const timeoutSecs = options.timeout ?? 120;
58
+ const params = new URLSearchParams({
59
+ token,
60
+ timeout: String(timeoutSecs),
61
+ geoCode: options.geoCode ?? "US",
62
+ url: options.url,
63
+ blockResources: String(!!options.blockResources),
64
+ });
65
+ const base = new URL("https://api.mrscraper.com/");
66
+ base.search = params.toString();
67
+ return request(base.toString(), {}, (timeoutSecs + 30) * 1000);
68
+ }
69
+ /**
70
+ * Create a new AI scraper (general, listing, or map).
71
+ * Throws {@link MrScraperError} on API or network errors.
72
+ */
73
+ export async function createAiScraper(options) {
74
+ const token = requireToken(options.token);
75
+ const agent = options.agent ?? "general";
76
+ const body = agent === "map"
77
+ ? {
78
+ url: options.url,
79
+ agent,
80
+ maxDepth: options.maxDepth ?? 2,
81
+ maxPages: options.maxPages ?? 50,
82
+ limit: options.limit ?? 1000,
83
+ includePatterns: options.includePatterns ?? "",
84
+ excludePatterns: options.excludePatterns ?? "",
85
+ }
86
+ : {
87
+ url: options.url,
88
+ message: options.message ?? "",
89
+ agent,
90
+ proxyCountry: options.proxyCountry ?? null,
91
+ };
92
+ return request("https://api.app.mrscraper.com/api/v1/scrapers-ai", {
93
+ method: "POST",
94
+ headers: {
95
+ "content-type": "application/json",
96
+ accept: "application/json",
97
+ "x-api-token": token,
98
+ },
99
+ body: JSON.stringify(body),
100
+ }, 600_000);
101
+ }
102
+ /**
103
+ * Rerun an existing AI scraper on a new URL.
104
+ * Throws {@link MrScraperError} on API or network errors.
105
+ */
106
+ export async function rerunAiScraper(options) {
107
+ const token = requireToken(options.token);
108
+ return request("https://api.app.mrscraper.com/api/v1/scrapers-ai-rerun", {
109
+ method: "POST",
110
+ headers: {
111
+ "content-type": "application/json",
112
+ accept: "application/json",
113
+ "x-api-token": token,
114
+ },
115
+ body: JSON.stringify({
116
+ scraperId: options.scraperId,
117
+ url: options.url,
118
+ maxDepth: options.maxDepth ?? 2,
119
+ maxPages: options.maxPages ?? 50,
120
+ limit: options.limit ?? 1000,
121
+ includePatterns: options.includePatterns ?? "",
122
+ excludePatterns: options.excludePatterns ?? "",
123
+ }),
124
+ }, 600_000);
125
+ }
126
+ /**
127
+ * Rerun an AI scraper on multiple URLs at once.
128
+ * Throws {@link MrScraperError} on API or network errors.
129
+ */
130
+ export async function bulkRerunAiScraper(options) {
131
+ const token = requireToken(options.token);
132
+ return request("https://api.app.mrscraper.com/api/v1/scrapers-ai-rerun/bulk", {
133
+ method: "POST",
134
+ headers: {
135
+ "content-type": "application/json",
136
+ accept: "application/json",
137
+ "x-api-token": token,
138
+ },
139
+ body: JSON.stringify({ scraperId: options.scraperId, urls: options.urls }),
140
+ }, 600_000);
141
+ }
142
+ /**
143
+ * Rerun a manual (dashboard-configured) scraper on a URL.
144
+ * Throws {@link MrScraperError} on API or network errors.
145
+ */
146
+ export async function rerunManualScraper(options) {
147
+ const token = requireToken(options.token);
148
+ return request("https://api.app.mrscraper.com/api/v1/scrapers-manual-rerun", {
149
+ method: "POST",
150
+ headers: {
151
+ "content-type": "application/json",
152
+ accept: "application/json",
153
+ "x-api-token": token,
154
+ },
155
+ body: JSON.stringify({ scraperId: options.scraperId, url: options.url }),
156
+ }, 600_000);
157
+ }
158
+ /**
159
+ * Rerun a manual scraper on multiple URLs at once.
160
+ * Throws {@link MrScraperError} on API or network errors.
161
+ */
162
+ export async function bulkRerunManualScraper(options) {
163
+ const token = requireToken(options.token);
164
+ return request("https://api.app.mrscraper.com/api/v1/scrapers-manual-rerun/bulk", {
165
+ method: "POST",
166
+ headers: {
167
+ "content-type": "application/json",
168
+ accept: "application/json",
169
+ "x-api-token": token,
170
+ },
171
+ body: JSON.stringify({ scraperId: options.scraperId, urls: options.urls }),
172
+ }, 600_000);
173
+ }
174
+ /**
175
+ * List scraping results with sorting, pagination, search, and date filters.
176
+ * Throws {@link MrScraperError} on API or network errors.
177
+ */
178
+ export async function getAllResults(options = {}) {
179
+ const token = requireToken(options.token);
180
+ const params = new URLSearchParams({
181
+ sortField: options.sortField ?? "updatedAt",
182
+ sortOrder: options.sortOrder ?? "DESC",
183
+ pageSize: String(options.pageSize ?? 10),
184
+ page: String(options.page ?? 1),
185
+ });
186
+ if (options.search)
187
+ params.set("search", options.search);
188
+ if (options.dateRangeColumn)
189
+ params.set("dateRangeColumn", options.dateRangeColumn);
190
+ if (options.startAt)
191
+ params.set("startAt", options.startAt);
192
+ if (options.endAt)
193
+ params.set("endAt", options.endAt);
194
+ const url = `https://api.app.mrscraper.com/api/v1/results?${params.toString()}`;
195
+ return request(url, {
196
+ method: "GET",
197
+ headers: {
198
+ accept: "application/json",
199
+ "x-api-token": token,
200
+ },
201
+ }, 600_000);
202
+ }
203
+ /**
204
+ * Fetch a single scraping result by its ID.
205
+ * Throws {@link MrScraperError} on API or network errors.
206
+ */
207
+ export async function getResultById(options) {
208
+ const token = requireToken(options.token);
209
+ const url = `https://api.app.mrscraper.com/api/v1/results/${encodeURIComponent(options.resultId)}`;
210
+ return request(url, {
211
+ method: "GET",
212
+ headers: {
213
+ accept: "application/json",
214
+ "x-api-token": token,
215
+ },
216
+ }, 600_000);
217
+ }
218
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEhD,8EAA8E;AAC9E,cAAc;AACd,8EAA8E;AAE9E,MAAM,OAAO,cAAe,SAAQ,KAAK;IACvC,8FAA8F;IAC9E,MAAM,CAAqB;IAE3C,YAAY,OAAe,EAAE,MAAe;QAC1C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAC7B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAqBD,8EAA8E;AAC9E,mBAAmB;AACnB,8EAA8E;AAE9E,SAAS,YAAY,CAAC,aAAsB;IAC1C,MAAM,KAAK,GA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gDAAgD,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAC;IAEhF,OAAO,OAAO,CACZ,GAAG,EACH;QACE,MAAM,EAAE,KAAK;QACb,OAAO,EAAE;YACP,MAAM,EAAE,kBAAkB;YAC1B,aAAa,EAAE,KAAK;SACrB;KACF,EACD,OAAO,CACR,CAAC;AACJ,CAAC;AAaD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,OAA6B;IAE7B,MAAM,KAAK,GAAG,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAE1C,MAAM,GAAG,GAAG,gDAAgD,kBAAkB,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;IAEnG,OAAO,OAAO,CACZ,GAAG,EACH;QACE,MAAM,EAAE,KAAK;QACb,OAAO,EAAE;YACP,MAAM,EAAE,kBAAkB;YAC1B,aAAa,EAAE,KAAK;SACrB;KACF,EACD,OAAO,CACR,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { MrScraperError, fetchHtml, createAiScraper, rerunAiScraper, bulkRerunAiScraper, rerunManualScraper, bulkRerunManualScraper, getAllResults, getResultById, } from "./api.js";
2
+ export type { ScraperAgent, SortField, SortOrder, FetchHtmlOptions, CreateAiScraperOptions, RerunAiScraperOptions, BulkRerunAiScraperOptions, RerunManualScraperOptions, BulkRerunManualScraperOptions, GetAllResultsOptions, GetResultByIdOptions, } from "./api.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,SAAS,EACT,eAAe,EACf,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,sBAAsB,EACtB,aAAa,EACb,aAAa,GACd,MAAM,UAAU,CAAC;AAElB,YAAY,EACV,YAAY,EACZ,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,sBAAsB,EACtB,qBAAqB,EACrB,yBAAyB,EACzB,yBAAyB,EACzB,6BAA6B,EAC7B,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,UAAU,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { MrScraperError, fetchHtml, createAiScraper, rerunAiScraper, bulkRerunAiScraper, rerunManualScraper, bulkRerunManualScraper, getAllResults, getResultById, } from "./api.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,SAAS,EACT,eAAe,EACf,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,sBAAsB,EACtB,aAAa,EACb,aAAa,GACd,MAAM,UAAU,CAAC"}
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@mrscraper/sdk",
3
+ "version": "1.0.0",
4
+ "description": "Official Node.js SDK for the MrScraper API – fetch pages, run AI scrapers, rerun manual scrapers, and retrieve results.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./dist/index.js",
12
+ "types": "./dist/index.d.ts"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "README.md",
18
+ "LICENSE"
19
+ ],
20
+ "scripts": {
21
+ "build": "tsc -p tsconfig.json",
22
+ "clean": "rm -rf dist",
23
+ "prepublishOnly": "npm run clean && npm run build"
24
+ },
25
+ "devDependencies": {
26
+ "@types/node": "^25.3.3",
27
+ "dotenv": "^17.3.1",
28
+ "typescript": "^5.6.0"
29
+ },
30
+ "engines": {
31
+ "node": ">=18"
32
+ },
33
+ "keywords": [
34
+ "mrscraper",
35
+ "scraper",
36
+ "web-scraping",
37
+ "scraping",
38
+ "sdk",
39
+ "api-client"
40
+ ],
41
+ "repository": {
42
+ "type": "git",
43
+ "url": "https://github.com/mrscraper-com/sdk-node.git"
44
+ },
45
+ "homepage": "https://mrscraper.com"
46
+ }