minifetch-api 1.4.0 → 1.5.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 +10 -8
- package/dist/esm/client.js +8 -5
- package/dist/esm/utils/payment.js +1 -1
- package/dist/types/client.d.ts +5 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -72,7 +72,7 @@ After the Quick Start, you have the following methods to use.
|
|
|
72
72
|
|
|
73
73
|
**Wrap** these methods in a **try/catch** just like in the Quick Start example above. **Code examples** can be also found in the [Github repository /example- directories](https://github.com/Niche-Networks/minifetch-api/).
|
|
74
74
|
|
|
75
|
-
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 by default. This is by design, so Minifetch never hammers your server or slows it down for your real users. If the
|
|
75
|
+
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 by default. This is by design, so Minifetch never hammers your server or slows it down for your real users. If you own the site and want to allow Minifetch access or to set custom rules for it, read [How To Unblock Minifetch](https://minifetch.com/tutorials/unblock-minifetch).
|
|
76
76
|
|
|
77
77
|
```js
|
|
78
78
|
await client.checkAndRunSeoPageAudit(url);
|
|
@@ -108,9 +108,8 @@ await client.checkAndExtractUrlLinks(url);
|
|
|
108
108
|
|
|
109
109
|
await client.checkAndExtractUrlPreview(url);
|
|
110
110
|
// Price: $0.002
|
|
111
|
-
//
|
|
112
|
-
//
|
|
113
|
-
// platforms, chat apps and AI.
|
|
111
|
+
// Extracts all fields used for a page's share previews: the lightweight
|
|
112
|
+
// cards that represent the page on social platforms, chat apps, and AI.
|
|
114
113
|
|
|
115
114
|
await client.checkAndExtractUrlContent(url, options);
|
|
116
115
|
// Price: $0.002
|
|
@@ -118,10 +117,14 @@ await client.checkAndExtractUrlContent(url, options);
|
|
|
118
117
|
// an LLM extracts from your page after nav, ads, & scripts are stripped.
|
|
119
118
|
// See what survives for AEO and AI search; respects robots.txt.
|
|
120
119
|
// Options: { includeMediaUrls: true } - defaults to false.
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
For max control, you can also use the following methods directly:
|
|
123
|
+
```js
|
|
124
|
+
await client.preflightCheck(url, options);
|
|
125
|
+
// Free: check if `minfetch` user agent can access target via robots.txt
|
|
126
|
+
// Options: { "fresh": true } - bypass 24hr robots.txt cache, defaults to false
|
|
121
127
|
|
|
122
|
-
// For max control, you can also use the following methods directly.
|
|
123
|
-
// Free: check if `minfetch` user agent can access target via robots.txt:
|
|
124
|
-
await client.preflightCheck(url);
|
|
125
128
|
// Paid methods:
|
|
126
129
|
await client.runSeoPageAudit(url);
|
|
127
130
|
await client.extractUrlMetadata(url, options); // same options as above
|
|
@@ -129,7 +132,6 @@ await client.extractUrlLinks(url);
|
|
|
129
132
|
await client.extractUrlPreview(url);
|
|
130
133
|
await client.extractUrlContent(url, options); // same options as above
|
|
131
134
|
```
|
|
132
|
-
|
|
133
135
|
---
|
|
134
136
|
|
|
135
137
|
### Error Types
|
package/dist/esm/client.js
CHANGED
|
@@ -22,13 +22,18 @@ export class MinifetchClient {
|
|
|
22
22
|
* Check if URL is allowed by robots.txt (free preflight check — no auth required)
|
|
23
23
|
*
|
|
24
24
|
* @param url
|
|
25
|
+
* @param options
|
|
26
|
+
* @param options.fresh
|
|
25
27
|
* @throws {InvalidUrlError} if URL is invalid
|
|
26
28
|
* @throws {NetworkError} if request fails
|
|
27
29
|
*/
|
|
28
|
-
async preflightUrlCheck(url) {
|
|
30
|
+
async preflightUrlCheck(url, options) {
|
|
29
31
|
try {
|
|
30
32
|
const normalizedUrl = validateAndNormalizeUrl(url);
|
|
31
|
-
const
|
|
33
|
+
const params = new URLSearchParams({ url: normalizedUrl });
|
|
34
|
+
if (options?.fresh)
|
|
35
|
+
params.set("fresh", "true");
|
|
36
|
+
const requestUrl = `${this.baseUrl}/api/v1/free/preflight/url-check?${params.toString()}`;
|
|
32
37
|
const response = await fetch(requestUrl);
|
|
33
38
|
if (!response.ok) {
|
|
34
39
|
throw new NetworkError(`Preflight check failed: ${response.status} ${response.statusText}`);
|
|
@@ -221,9 +226,7 @@ export class MinifetchClient {
|
|
|
221
226
|
* @param endpoint
|
|
222
227
|
*/
|
|
223
228
|
_paidPath(endpoint) {
|
|
224
|
-
return this.config.authMode === "x402"
|
|
225
|
-
? `/api/v1/x402${endpoint}`
|
|
226
|
-
: `/api/v1${endpoint}`;
|
|
229
|
+
return this.config.authMode === "x402" ? `/api/v1/x402${endpoint}` : `/api/v1${endpoint}`;
|
|
227
230
|
}
|
|
228
231
|
/**
|
|
229
232
|
* Dispatch to the correct request handler based on auth mode, then
|
|
@@ -29,7 +29,7 @@ export async function handlePayment(url, config) {
|
|
|
29
29
|
}
|
|
30
30
|
else if (isSolana) {
|
|
31
31
|
if (!config.privateKey)
|
|
32
|
-
throw new PaymentFailedError(
|
|
32
|
+
throw new PaymentFailedError("privateKey is required for Solana payments");
|
|
33
33
|
const privateKeyBytes = bs58.decode(config.privateKey);
|
|
34
34
|
const signer = await createKeyPairSignerFromBytes(privateKeyBytes);
|
|
35
35
|
const svmSigner = signer;
|
package/dist/types/client.d.ts
CHANGED
|
@@ -17,10 +17,14 @@ export declare class MinifetchClient {
|
|
|
17
17
|
* Check if URL is allowed by robots.txt (free preflight check — no auth required)
|
|
18
18
|
*
|
|
19
19
|
* @param url
|
|
20
|
+
* @param options
|
|
21
|
+
* @param options.fresh
|
|
20
22
|
* @throws {InvalidUrlError} if URL is invalid
|
|
21
23
|
* @throws {NetworkError} if request fails
|
|
22
24
|
*/
|
|
23
|
-
preflightUrlCheck(url: string
|
|
25
|
+
preflightUrlCheck(url: string, options?: {
|
|
26
|
+
fresh?: boolean;
|
|
27
|
+
}): Promise<PreflightCheckResponse>;
|
|
24
28
|
/**
|
|
25
29
|
* Run SEO page audit (paid endpoint)
|
|
26
30
|
*
|
package/package.json
CHANGED