minifetch-api 1.2.2 → 1.3.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/README.md CHANGED
@@ -5,20 +5,18 @@
5
5
  </a>
6
6
  </div>
7
7
 
8
- **Fetch & extract data from web pages.** [Minifetch.com](https://minifetch.com) provides composable extraction APIs for humans and AI Agents-- making web pages simple to access.
8
+ **Pay-per-URL SEO audits. Composable toolkit for AI agents and automation pipelines.** [Minifetch.com](https://minifetch.com) is an SEO toolkit of composable extraction primitives. Run them as a full technical audit or call one at a time for a fraction of the price — and a fraction of the LLM tokens. No subscription.
9
9
 
10
- - ✅ **[Sign up](https://minifetch.com/dashboard) for an account and get your first 125-250 fetches for free. 🎉🎉**
11
- - ✅ Always pay-as-you-go at competitive prices.
10
+ - ✅ **[Sign up](https://minifetch.com/dashboard) for an account and get free starter credits. 🎉🎉**
11
+ - ✅ Always pay-per-fetch at competitive prices.
12
12
  - ⛔ No charge for blocked pages (403 errors).
13
13
 
14
14
  ---
15
15
  **👉 [Dashboard](https://minifetch.com/dashboard) | [Full API docs](https://minifetch.com/docs/api) | [LLMs.txt](https://minifetch.com/llms.txt) | Questions? Join our [Discord](https://discord.gg/EM6ET8Dshm)**
16
16
 
17
-
18
-
19
17
  ---
20
18
  **Payments.** Two ways to pay:
21
- 1. Credit card + API key. Get started free - [visit our dashboard to Sign Up](https://minifetch.com/dashboard). Your account will be auto-loaded with 125–250 API calls. Top up with your credit card later.
19
+ 1. Credit card + API key. Get started free - [visit our dashboard to Sign Up](https://minifetch.com/dashboard). Your account will be auto-loaded with 25 free technical SEO page audits. Top up with your credit card later.
22
20
  2. x402. USDC stablecoin micropayments on Coinbase's Base & Solana networks.
23
21
 
24
22
  ## Prerequisites
@@ -36,7 +34,8 @@
36
34
  ```js
37
35
  import Minifetch from "minifetch-api";
38
36
 
39
- // First, initialize the client with your payment choice:
37
+ // First, initialize the client with your payment choice-
38
+ // pick option 1 or 2:
40
39
 
41
40
  // 1. API Key Payments:
42
41
  const client = new Minifetch({
@@ -51,11 +50,11 @@ const client = new Minifetch({
51
50
  privateKey: process.env.BASE_PRIVATE_KEY,
52
51
  });
53
52
 
54
- // Now you're ready to extract data from a url:
53
+ // Now you're ready to call the API methods:
55
54
  try {
56
55
  const url = "example.com";
57
- const response = await client.checkAndExtractUrlPreview(url);
58
- // 200 "ok" responses
56
+ const response = await client.checkAndRunSeoPageAudit(url);
57
+ // 200 "ok" responses:
59
58
  console.log(response);
60
59
  } catch (err) {
61
60
  // No charge for errors or 403 blocked urls!
@@ -63,57 +62,78 @@ try {
63
62
  }
64
63
  ```
65
64
 
66
- ### Data Extraction Methods
67
-
68
- After the Quick Start, you have the following methods to use. The "checkAndExtract" methods help to avoid paying for blocked URLs. **Price list** & example data [is here.](https://minifetch.com/docs/api#example-data)
65
+ ### API Methods
69
66
 
70
- **Wrap** these in a **try/catch** just like in the Quickstart example above. **Code examples** can be also found in the [Github repository](https://github.com/Niche-Networks/minifetch-api/) in the /example- directories.
71
-
72
- ```js
73
- // Extracts a light, token-efficient preview of a URL:
74
- // title, description, and image (only).
75
- client.checkAndExtractUrlPreview(url);
67
+ After the Quick Start, you have the following methods to use.
76
68
 
77
- // Extracts a clean, token-efficient content summary as markdown from a URL.
78
- // Removes ads, nav, scripts. More efficient than raw HTML fetches for LLMs.
79
- // Options: { includeMediaUrls: true } - defaults to false.
80
- client.checkAndExtractUrlContent(url, options);
69
+ **Wrap** these methods in a **try/catch** just like in the Quickstart example above. **Code examples** can be also found in the [Github repository](https://github.com/Niche-Networks/minifetch-api/) /example- directories.
81
70
 
82
- // Extracts all links from a URL categorized by type (internal/external/anchor).
83
- // Detects image links, nofollow attributes, analyzes external domain distribution.
84
- client.checkAndExtractUrlLinks(url);
71
+ The "checkAndExtract" methods check the target URL's `robots.txt` file to ensure its not blocked and tell us your preferred crawl delay (defaults to 1 second between requests to your domain). So fetching 10 URLs takes at least 10 seconds to complete. This is by design, so Minifetch never hammers your server or slows it down for your real users. [Full api docs here.](https://minifetch.com/docs/api)
85
72
 
86
- // Extracts rich structured metadata from a URL:
87
- // meta tags, json-ld, images, headings, response headers, + more.
88
- // Setting verbosity to "full" is the drop-in replacement for the
89
- // [`url-metadata`](https://www.npmjs.com/package/url-metadata) package.
73
+ ```js
74
+ await client.checkAndRunSeoPageAudit(url);
75
+ // Price: $0.01
76
+ // Runs a full technical SEO audit on your URL. It combines data from
77
+ // the other API endpoints and runs checks that each return a PASS/
78
+ // WARN/ FAIL result with no black-box scoring — just deterministic,
79
+ // composable signal you can act on or pipe into an agent.
80
+ // Audit rules are documented in the in the audit skill file:
81
+ // https://minifetch.com/skills/seo-page-audit/SKILL.md
82
+
83
+ await client.checkAndExtractUrlMetadata(url, options);
84
+ // Price: $0.002
85
+ // Fetches & extracts rich structured metadata from your URL: meta tags,
86
+ // hreflang, json-ld, images, headings, response headers, + more.
87
+ // Setting verbosity to "full" is the drop-in replacement for the npm
88
+ // `url-metadata` package.
90
89
  // Options:
91
90
  // { verbosity: "full" } - defaults to "standard"
92
91
  // { includeResponseBody: true } - defaults to false
93
- client.checkAndExtractUrlMetadata(url, options);
92
+
93
+ await client.checkAndExtractUrlLinks(url);
94
+ // Price: $0.002
95
+ // Fetches & extracts all links from your URL categorized by type
96
+ // (internal/ external/ anchor). Detects image links, `rel` attributes
97
+ // (nofollow, sponsored, ugc, etc), `title` and `target`, plus image
98
+ // detection. Summary stats include the most-linked-to internal pages
99
+ // (with anchor text variants used for each) and top external domains
100
+ // by link count.
101
+
102
+ await client.checkAndExtractUrlPreview(url);
103
+ // Price: $0.001
104
+ // For checking how your page unfurls when shared: Extracts the title,
105
+ // meta description, and preview image (only) - the lightweight card
106
+ // social platforms and chat apps render for a link.
107
+
108
+ await client.checkAndExtractUrlContent(url, options);
109
+ // Price: $0.002
110
+ // For site owners auditing AI readability: returns the clean markdown
111
+ // an LLM extracts from your page after nav, ads, & scripts are stripped.
112
+ // See what survives for AEO and AI search; respects robots.txt.
113
+ // Options: { includeMediaUrls: true } - defaults to false.
94
114
 
95
115
  // For max control, you can also use the following methods directly.
96
116
  // Free - check robots.txt:
97
- client.preflightCheck(url);
98
- // Extract data:
99
- client.extractUrlPreview(url);
100
- client.extractUrlContent(url, options); // same options as above
101
- client.extractUrlLinks(url);
102
- client.extractUrlMetadata(url, options) // same options as above
103
-
117
+ await client.preflightCheck(url);
118
+ // Paid methods:
119
+ await client.runSeoPageAudit(url);
120
+ await client.extractUrlMetadata(url, options); // same options as above
121
+ await client.extractUrlLinks(url);
122
+ await client.extractUrlPreview(url);
123
+ await client.extractUrlContent(url, options); // same options as above
104
124
  ```
105
125
  ---
106
126
  ### Error Types
107
- When you wrap the functions above in a try/catch, here are the errors you may encounter. You are never charged for errors.
127
+ When you wrap the functions above in a try/catch, here are the errors you may encounter. You are never charged for URLs that are blocked or error.
108
128
 
109
129
  - **"RobotsBlockedError: URL is blocked by robots.txt"**
110
- - URL is explicitly blocked by the website's robots.txt, cannot be fetched.
130
+ - Minifetch is explicitly blocked by the website's `robots.txt`, cannot be fetched. If this is your site, read our tutorial [How To Unblock Minifetch](https://minifetch.com/tutorials/unblock-minifetch)
111
131
  - **"Network Error: 402 Payment Required"**
112
132
  - Check your wallet -- likely you ran out of USDC to pay!
113
133
  - **"Network Error: 429 Too Many Requests"**
114
134
  - Back off and retry, max 5-10 requests per second.
115
135
  - **"Network Error: 502 Bad Gateway"**
116
- - URLs that pass their robots.txt check but are blocked anyway via 403 or other tactics may error like this.
136
+ - URLs that pass their robots.txt check but are blocked anyway via 403 or other tactics may error like this. No charge.
117
137
  - **"503 Service Temporarily Unavailable"**
118
138
  - Likely encountering upstream timeout errors on the target URL.
119
139
  - **"InvalidURLError: Invalid url ${url}"**
@@ -133,7 +153,7 @@ What Minifetch does NOT do *currently* but may offer in the future as an add-on:
133
153
  - Javascript execution
134
154
 
135
155
  ---
136
- ### x402 Best Practices
156
+ ### x402 Micropayments Best Practices
137
157
  - LLMs & Agents should *never* have direct access to your private key. They *will* expose it!
138
158
  - Only keep a small amount of USDC in the account whose private key you use.
139
159
  - Keep that account separate from the rest of your onchain funds.
@@ -42,6 +42,26 @@ export class MinifetchClient {
42
42
  throw new NetworkError(`Preflight check failed: ${error instanceof Error ? error.message : "Unknown error"}`);
43
43
  }
44
44
  }
45
+ /**
46
+ * Run SEO page audit (paid endpoint)
47
+ *
48
+ * @param url
49
+ * @throws {InvalidUrlError} if URL is invalid
50
+ * @throws {ExtractionFailedError} various reasons, check README
51
+ * @throws {PaymentFailedError} if x402 payment fails
52
+ * @throws {NetworkError} various reasons, check README
53
+ */
54
+ async runSeoPageAudit(url) {
55
+ try {
56
+ const normalizedUrl = validateAndNormalizeUrl(url);
57
+ const params = new URLSearchParams({ url: normalizedUrl });
58
+ const requestUrl = `${this.baseUrl}${this._paidPath("/run/seo-page-audit")}?${params.toString()}`;
59
+ return await this._makeRequest(requestUrl, normalizedUrl, "Run SEO page audit");
60
+ }
61
+ catch (error) {
62
+ return this._rethrowError(error, url, "Run SEO page audit");
63
+ }
64
+ }
45
65
  /**
46
66
  * Extract URL metadata (paid endpoint)
47
67
  *
@@ -62,11 +82,11 @@ export class MinifetchClient {
62
82
  params.set("verbosity", options.verbosity);
63
83
  if (options?.includeResponseBody)
64
84
  params.set("includeResponseBody", "true");
65
- const requestUrl = `${this.baseUrl}${this._extractPath("url-metadata")}?${params.toString()}`;
85
+ const requestUrl = `${this.baseUrl}${this._paidPath("/extract/url-metadata")}?${params.toString()}`;
66
86
  return await this._makeRequest(requestUrl, normalizedUrl, "Metadata extraction");
67
87
  }
68
88
  catch (error) {
69
- return this._rethrowExtraction(error, url, "Metadata extraction");
89
+ return this._rethrowError(error, url, "Metadata extraction");
70
90
  }
71
91
  }
72
92
  /**
@@ -81,11 +101,11 @@ export class MinifetchClient {
81
101
  async extractUrlLinks(url) {
82
102
  try {
83
103
  const normalizedUrl = validateAndNormalizeUrl(url);
84
- const requestUrl = `${this.baseUrl}${this._extractPath("url-links")}?url=${encodeURIComponent(normalizedUrl)}`;
104
+ const requestUrl = `${this.baseUrl}${this._paidPath("/extract/url-links")}?url=${encodeURIComponent(normalizedUrl)}`;
85
105
  return await this._makeRequest(requestUrl, normalizedUrl, "Links extraction");
86
106
  }
87
107
  catch (error) {
88
- return this._rethrowExtraction(error, url, "Links extraction");
108
+ return this._rethrowError(error, url, "Links extraction");
89
109
  }
90
110
  }
91
111
  /**
@@ -100,11 +120,11 @@ export class MinifetchClient {
100
120
  async extractUrlPreview(url) {
101
121
  try {
102
122
  const normalizedUrl = validateAndNormalizeUrl(url);
103
- const requestUrl = `${this.baseUrl}${this._extractPath("url-preview")}?url=${encodeURIComponent(normalizedUrl)}`;
123
+ const requestUrl = `${this.baseUrl}${this._paidPath("/extract/url-preview")}?url=${encodeURIComponent(normalizedUrl)}`;
104
124
  return await this._makeRequest(requestUrl, normalizedUrl, "Preview extraction");
105
125
  }
106
126
  catch (error) {
107
- return this._rethrowExtraction(error, url, "Preview extraction");
127
+ return this._rethrowError(error, url, "Preview extraction");
108
128
  }
109
129
  }
110
130
  /**
@@ -124,13 +144,23 @@ export class MinifetchClient {
124
144
  const params = new URLSearchParams({ url: normalizedUrl });
125
145
  if (options?.includeMediaUrls)
126
146
  params.set("includeMediaUrls", "true");
127
- const requestUrl = `${this.baseUrl}${this._extractPath("url-content")}?${params.toString()}`;
147
+ const requestUrl = `${this.baseUrl}${this._paidPath("/extract/url-content")}?${params.toString()}`;
128
148
  return await this._makeRequest(requestUrl, normalizedUrl, "Content extraction");
129
149
  }
130
150
  catch (error) {
131
- return this._rethrowExtraction(error, url, "Content extraction");
151
+ return this._rethrowError(error, url, "Content extraction");
132
152
  }
133
153
  }
154
+ /**
155
+ * Check URL then run SEO page audit in one call.
156
+ * Throws RobotsBlockedError if robots.txt blocks the URL.
157
+ *
158
+ * @param url
159
+ */
160
+ async checkAndRunSeoPageAudit(url) {
161
+ await this._preflightOrThrow(url);
162
+ return this.runSeoPageAudit(url);
163
+ }
134
164
  /**
135
165
  * Check URL then extract metadata in one call.
136
166
  * Throws RobotsBlockedError if robots.txt blocks the URL.
@@ -180,16 +210,16 @@ export class MinifetchClient {
180
210
  // Private helpers
181
211
  // ---------------------------------------------------------------------------
182
212
  /**
183
- * Returns the correct extract path segment based on auth mode.
184
- * x402 → /api/v1/x402/extract/<endpoint>
185
- * apiKey → /api/v1/extract/<endpoint>
213
+ * Returns the correct paid path segment based on auth mode.
214
+ * x402 → /api/v1/x402/<endpoint>
215
+ * apiKey → /api/v1/<endpoint>
186
216
  *
187
217
  * @param endpoint
188
218
  */
189
- _extractPath(endpoint) {
219
+ _paidPath(endpoint) {
190
220
  return this.config.authMode === "x402"
191
- ? `/api/v1/x402/extract/${endpoint}`
192
- : `/api/v1/extract/${endpoint}`;
221
+ ? `/api/v1/x402${endpoint}`
222
+ : `/api/v1${endpoint}`;
193
223
  }
194
224
  /**
195
225
  * Dispatch to the correct request handler based on auth mode, then
@@ -237,7 +267,7 @@ export class MinifetchClient {
237
267
  * @param url
238
268
  * @param label
239
269
  */
240
- _rethrowExtraction(error, url, label) {
270
+ _rethrowError(error, url, label) {
241
271
  if (error instanceof InvalidUrlError ||
242
272
  error instanceof ExtractionFailedError ||
243
273
  error instanceof PaymentFailedError ||
@@ -21,6 +21,16 @@ export declare class MinifetchClient {
21
21
  * @throws {NetworkError} if request fails
22
22
  */
23
23
  preflightUrlCheck(url: string): Promise<PreflightCheckResponse>;
24
+ /**
25
+ * Run SEO page audit (paid endpoint)
26
+ *
27
+ * @param url
28
+ * @throws {InvalidUrlError} if URL is invalid
29
+ * @throws {ExtractionFailedError} various reasons, check README
30
+ * @throws {PaymentFailedError} if x402 payment fails
31
+ * @throws {NetworkError} various reasons, check README
32
+ */
33
+ runSeoPageAudit(url: string): Promise<PaidEndpointResponse>;
24
34
  /**
25
35
  * Extract URL metadata (paid endpoint)
26
36
  *
@@ -71,6 +81,13 @@ export declare class MinifetchClient {
71
81
  extractUrlContent(url: string, options?: {
72
82
  includeMediaUrls?: boolean;
73
83
  }): Promise<PaidEndpointResponse>;
84
+ /**
85
+ * Check URL then run SEO page audit in one call.
86
+ * Throws RobotsBlockedError if robots.txt blocks the URL.
87
+ *
88
+ * @param url
89
+ */
90
+ checkAndRunSeoPageAudit(url: string): Promise<PaidEndpointResponse>;
74
91
  /**
75
92
  * Check URL then extract metadata in one call.
76
93
  * Throws RobotsBlockedError if robots.txt blocks the URL.
@@ -110,13 +127,13 @@ export declare class MinifetchClient {
110
127
  includeMediaUrls?: boolean;
111
128
  }): Promise<PaidEndpointResponse>;
112
129
  /**
113
- * Returns the correct extract path segment based on auth mode.
114
- * x402 → /api/v1/x402/extract/<endpoint>
115
- * apiKey → /api/v1/extract/<endpoint>
130
+ * Returns the correct paid path segment based on auth mode.
131
+ * x402 → /api/v1/x402/<endpoint>
132
+ * apiKey → /api/v1/<endpoint>
116
133
  *
117
134
  * @param endpoint
118
135
  */
119
- private _extractPath;
136
+ private _paidPath;
120
137
  /**
121
138
  * Dispatch to the correct request handler based on auth mode, then
122
139
  * normalize the response into PaidEndpointResponse.
@@ -140,5 +157,5 @@ export declare class MinifetchClient {
140
157
  * @param url
141
158
  * @param label
142
159
  */
143
- private _rethrowExtraction;
160
+ private _rethrowError;
144
161
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "minifetch-api",
3
- "version": "1.2.2",
4
- "description": "Minifetch.com API Client. Fetch & extract data from web pages. For AI Agents & SEO research.",
3
+ "version": "1.3.0",
4
+ "description": "Minifetch.com API Client. Pay-per-URL SEO audits. Composable toolkit for AI agents and automation pipelines.",
5
5
  "type": "module",
6
6
  "main": "./dist/esm/index.js",
7
7
  "types": "./dist/types/index.d.ts",
@@ -17,16 +17,37 @@
17
17
  "LICENSE"
18
18
  ],
19
19
  "keywords": [
20
- "seo",
20
+ "SEO",
21
+ "SEO page audit",
22
+ "SEO research",
23
+ "SEO toolkit",
24
+ "technical SEO",
25
+ "pay-per-url SEO",
26
+ "GEO",
27
+ "AEO",
28
+ "extract",
29
+ "content extraction",
30
+ "content indexing",
31
+ "html",
32
+ "html parser",
33
+ "json-ld",
34
+ "JSON LD",
35
+ "link analysis",
36
+ "link extraction",
21
37
  "metadata",
22
- "meta-tags",
23
- "web-pages",
24
- "web-scraping",
25
- "scraper",
26
- "html-parser",
27
- "ai",
28
- "ai-agents",
29
- "llm",
38
+ "meta tags",
39
+ "open graph",
40
+ "og tags",
41
+ "AI",
42
+ "AI Agents",
43
+ "AI readability",
44
+ "agent skills",
45
+ "automation",
46
+ "monitoring",
47
+ "LLM",
48
+ "previews",
49
+ "twitter cards",
50
+ "site monitoring",
30
51
  "x402",
31
52
  "micropayments",
32
53
  "usdc"
@@ -37,7 +58,7 @@
37
58
  "homepage": "https://minifetch.com",
38
59
  "repository": {
39
60
  "type": "git",
40
- "url": "git@github.com:Niche-Networks/minifetch-api.git"
61
+ "url": "git+ssh://git@github.com/Niche-Networks/minifetch-api.git"
41
62
  },
42
63
  "scripts": {
43
64
  "dist:clean": "rm -rf dist",