minifetch-api 1.0.1 → 1.1.1

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
@@ -7,11 +7,11 @@
7
7
 
8
8
  **Fetch & extract data from web pages.** [Minifetch.com](https://minifetch.com) provides composable extraction APIs that humans and AI Agents can autonomously discover, orchestrate, and pay for— making web pages simple to access. Pay-as-you-go at competitive prices.
9
9
 
10
- **Full [API docs are here](https://minifetch.com/docs/api)**, including example response data & prices. For AI Agents, read the [LLMs.txt](https://minifetch.com/llms.txt).
10
+ **Full [API docs are here](https://minifetch.com/docs/api)**, including example queries, response data & prices. For AI Agents, read the [LLMs.txt](https://minifetch.com/llms.txt) instead.
11
11
 
12
- **Payments** work with [x402](https://www.x402.org/) USDC stablecoin micropayments on Coinbase's Base & Solana blockchain networks. Transaction fees are free. If you'd like to use a traditional credit card & API key instead, sign up for the waitlist and we'll let you know when it's ready: [forms.gle/rkMi7T23bHJc8XFw9](https://forms.gle/rkMi7T23bHJc8XFw9)
12
+ **Payments** work with [x402](https://www.x402.org/) USDC stablecoin micropayments on Coinbase's Base & Solana blockchain networks. Transaction fees are free. If you'd like to use a traditional credit card & API key instead, sign up for the waitlist: [forms.gle/rkMi7T23bHJc8XFw9](https://forms.gle/rkMi7T23bHJc8XFw9)
13
13
 
14
- **Bulk fetch and extract** for building datasets is coming soon, sign up for the waitlist and we'll let you know when it's ready: [forms.gle/rkMi7T23bHJc8XFw9](https://forms.gle/rkMi7T23bHJc8XFw9)
14
+ **Bulk fetch and extract** for building datasets is coming soon, sign up for the waitlist: [forms.gle/rkMi7T23bHJc8XFw9](https://forms.gle/rkMi7T23bHJc8XFw9)
15
15
 
16
16
  ## Prerequisites
17
17
 
@@ -37,7 +37,7 @@ const client = new Minifetch({
37
37
 
38
38
  try {
39
39
  const url = "example.com";
40
- const response = await client.checkAndExtractPreview(url);
40
+ const response = await client.checkAndExtractUrlPreview(url);
41
41
  // 200 "ok" responses will return the data and x402 payment info:
42
42
  console.log("data: ", response.data);
43
43
  console.log("payment info: ", response.payment);
@@ -51,34 +51,38 @@ try {
51
51
 
52
52
  After you initialize the client (above), you have the following methods available to use. The "checkAndExtract" API methods provided help you avoid paying for blocked URLs and return more granular info about why a URL may or may not return data. There is no charge for blocked upstream URLs.
53
53
 
54
- [Price list and example data for each method is here.](https://minifetch.com/docs/api#example-data)
54
+ **Price list** and example data for each method [is here.](https://minifetch.com/docs/api#example-data)
55
55
 
56
- Requests exceeding rate limits return `503` errors. This is intentional — back off and retry, max 5-10 queries per second. We'll add bulk fetch and extract in the future. Sign up for the [waitlist here](https://forms.gle/rkMi7T23bHJc8XFw9).
56
+ **Rate limit** Requests exceeding rate limits return `503` errors. This is intentional — back off and retry, max 5-10 queries per second. We'll add bulk fetch and extract in the future. Sign up for the [waitlist](https://forms.gle/rkMi7T23bHJc8XFw9).
57
+
58
+ **Code examples** can be found in the github repository under /test.
57
59
 
58
60
  - **`client.checkAndExtractUrlPreview(url)`**
59
61
  - Extracts a light, token-efficient preview of a URL: title, description, and image (only).
60
62
 
61
63
  - **`client.checkAndExtractUrlContent(url, options)`**
62
64
  - Extracts a clean, token-efficient content summary as markdown from a URL. Removes ads, nav, scripts. Much more efficient than raw HTML fetches for LLMs.
63
- - Options: `{ includeMediaUrls: true }`, defaults to false
65
+ - Option: `{ includeMediaUrls: true }`, defaults to false
64
66
 
65
67
  - **`client.checkAndExtractUrlLinks(url)`**
66
68
  - Extracts all links from a URL categorized by type (internal/external/anchor) with SEO metadata. Detects image links, nofollow attributes, and analyzes external domain distribution.
67
69
 
68
70
  - **`client.checkAndExtractUrlMetadata(url, options)`**
69
- - Extracts rich structured metadata from a URL: title, description, og/twitter tags, json-ld, images, headings, response headers, and more. Perfect for SEO research or metadata indexing & analysis. Largest response size of the client methods available.
70
- - Options: `{ includeResponseBody: true }`, defaults to false
71
+ - Extracts rich structured metadata from a URL: title, description, og/twitter tags, json-ld, images, headings, response headers, and more. Perfect for SEO research or metadata indexing & analysis. Largest response size of the client methods available. Calling this method and setting verbosity to "full" is the drop-in replacement for the [`url-metadata`](https://www.npmjs.com/package/url-metadata) package.
72
+ - Option: `{ verbosity: "full" }`, defaults to "standard"
73
+ - Option: `{ includeResponseBody: true }`, defaults to false
71
74
 
72
- For maximum control, you can also use the following methods directly:
75
+ ***For maximum control, you can also use the following methods directly:***
73
76
 
74
77
  - **`client.preflightCheck(url)`**
75
- - Standalone call to check if a URL is allowed to be fetched according to the website's robots.txt file. Use this free endpoint before using our other paid endpoints to avoid spending extra on un-fetchable URLs
78
+ - Standalone call to check if a URL is allowed to be fetched according to the website's robots.txt file. Use this free endpoint before using our other paid endpoints to help avoid spending extra on un-fetchable URLs
76
79
  - **`client.extractUrlPreview(url)`**
77
80
  - **`client.extractUrlContent(url, options)`**
78
- - Options: `{ includeMediaUrls: true }`, defaults to false
81
+ - Option: `{ includeMediaUrls: true }`, defaults to false
79
82
  - **`client.extractUrlLinks(url)`**
80
83
  - **`client.extractUrlMetadata(url, options)`**
81
- - Options: `{ includeResponseBody: true }`, defaults to false
84
+ - Option: `{ verbosity: "full" }`, defaults to "standard"
85
+ - Option: `{ includeResponseBody: true }`, defaults to false
82
86
 
83
87
  ### Error Types
84
88
  When you wrap the functions above in a try/catch, here are the errors you may encounter:
@@ -51,9 +51,11 @@ export class MinifetchClient {
51
51
  * @param url
52
52
  * @param options
53
53
  * @param options.includeResponseBody
54
+ * @param options.verbosity - Controls response detail level: "standard" (default) or "full"
54
55
  * @throws {InvalidUrlError} if URL is invalid
56
+ * @throws {ExtractionFailedError} various reasons, check README
55
57
  * @throws {PaymentFailedError} if payment fails
56
- * @throws {ExtractionFailedError} if extraction fails
58
+ * @throws {NetworkError} various reasons, check README
57
59
  */
58
60
  async extractUrlMetadata(url, options) {
59
61
  try {
@@ -61,6 +63,9 @@ export class MinifetchClient {
61
63
  const normalizedUrl = validateAndNormalizeUrl(url);
62
64
  // Build request URL with optional params
63
65
  const params = new URLSearchParams({ url: normalizedUrl });
66
+ if (options?.verbosity) {
67
+ params.set("verbosity", options.verbosity);
68
+ }
64
69
  if (options?.includeResponseBody) {
65
70
  params.set("includeResponseBody", "true");
66
71
  }
@@ -95,8 +100,9 @@ export class MinifetchClient {
95
100
  *
96
101
  * @param url
97
102
  * @throws {InvalidUrlError} if URL is invalid
103
+ * @throws {ExtractionFailedError} various reasons, check README
98
104
  * @throws {PaymentFailedError} if payment fails
99
- * @throws {ExtractionFailedError} if extraction fails
105
+ * @throws {NetworkError} various reasons, check README
100
106
  */
101
107
  async extractUrlLinks(url) {
102
108
  try {
@@ -130,8 +136,9 @@ export class MinifetchClient {
130
136
  *
131
137
  * @param url
132
138
  * @throws {InvalidUrlError} if URL is invalid
139
+ * @throws {ExtractionFailedError} various reasons, check README
133
140
  * @throws {PaymentFailedError} if payment fails
134
- * @throws {ExtractionFailedError} if extraction fails
141
+ * @throws {NetworkError} various reasons, check README
135
142
  */
136
143
  async extractUrlPreview(url) {
137
144
  try {
@@ -170,8 +177,9 @@ export class MinifetchClient {
170
177
  * @param options
171
178
  * @param options.includeMediaUrls
172
179
  * @throws {InvalidUrlError} if URL is invalid
180
+ * @throws {ExtractionFailedError} various reasons, check README
173
181
  * @throws {PaymentFailedError} if payment fails
174
- * @throws {ExtractionFailedError} if extraction fails
182
+ * @throws {NetworkError} various reasons, check README
175
183
  */
176
184
  async extractUrlContent(url, options) {
177
185
  try {
@@ -213,7 +221,8 @@ export class MinifetchClient {
213
221
  *
214
222
  * @param url
215
223
  * @param options
216
- * @param options.includeResponseBody
224
+ * @param options.verbosity - Controls response detail level: "standard" (default) or "full"
225
+ * @param options.includeResponseBody - Include raw response body in result
217
226
  */
218
227
  async checkAndExtractUrlMetadata(url, options) {
219
228
  const checkResponse = await this.preflightUrlCheck(url);
@@ -26,11 +26,14 @@ export declare class MinifetchClient {
26
26
  * @param url
27
27
  * @param options
28
28
  * @param options.includeResponseBody
29
+ * @param options.verbosity - Controls response detail level: "standard" (default) or "full"
29
30
  * @throws {InvalidUrlError} if URL is invalid
31
+ * @throws {ExtractionFailedError} various reasons, check README
30
32
  * @throws {PaymentFailedError} if payment fails
31
- * @throws {ExtractionFailedError} if extraction fails
33
+ * @throws {NetworkError} various reasons, check README
32
34
  */
33
35
  extractUrlMetadata(url: string, options?: {
36
+ verbosity?: "standard" | "full";
34
37
  includeResponseBody?: boolean;
35
38
  }): Promise<PaidEndpointResponse>;
36
39
  /**
@@ -38,8 +41,9 @@ export declare class MinifetchClient {
38
41
  *
39
42
  * @param url
40
43
  * @throws {InvalidUrlError} if URL is invalid
44
+ * @throws {ExtractionFailedError} various reasons, check README
41
45
  * @throws {PaymentFailedError} if payment fails
42
- * @throws {ExtractionFailedError} if extraction fails
46
+ * @throws {NetworkError} various reasons, check README
43
47
  */
44
48
  extractUrlLinks(url: string): Promise<PaidEndpointResponse>;
45
49
  /**
@@ -47,8 +51,9 @@ export declare class MinifetchClient {
47
51
  *
48
52
  * @param url
49
53
  * @throws {InvalidUrlError} if URL is invalid
54
+ * @throws {ExtractionFailedError} various reasons, check README
50
55
  * @throws {PaymentFailedError} if payment fails
51
- * @throws {ExtractionFailedError} if extraction fails
56
+ * @throws {NetworkError} various reasons, check README
52
57
  */
53
58
  extractUrlPreview(url: string): Promise<PaidEndpointResponse>;
54
59
  /**
@@ -58,8 +63,9 @@ export declare class MinifetchClient {
58
63
  * @param options
59
64
  * @param options.includeMediaUrls
60
65
  * @throws {InvalidUrlError} if URL is invalid
66
+ * @throws {ExtractionFailedError} various reasons, check README
61
67
  * @throws {PaymentFailedError} if payment fails
62
- * @throws {ExtractionFailedError} if extraction fails
68
+ * @throws {NetworkError} various reasons, check README
63
69
  */
64
70
  extractUrlContent(url: string, options?: {
65
71
  includeMediaUrls?: boolean;
@@ -70,9 +76,11 @@ export declare class MinifetchClient {
70
76
  *
71
77
  * @param url
72
78
  * @param options
73
- * @param options.includeResponseBody
79
+ * @param options.verbosity - Controls response detail level: "standard" (default) or "full"
80
+ * @param options.includeResponseBody - Include raw response body in result
74
81
  */
75
82
  checkAndExtractUrlMetadata(url: string, options?: {
83
+ verbosity?: "standard" | "full";
76
84
  includeResponseBody?: boolean;
77
85
  }): Promise<PaidEndpointResponse>;
78
86
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "minifetch-api",
3
- "version": "1.0.1",
3
+ "version": "1.1.1",
4
4
  "description": "Minifetch.com API Client. Fetch & extract data from web pages. For AI Agents & SEO research.",
5
5
  "type": "module",
6
6
  "main": "./dist/esm/index.js",