scrapebadger 0.64.0 → 0.65.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 +34 -0
- package/dist/{index-MBQ1Ksjt.d.cts → index-CQ1vFI8s.d.cts} +5 -1
- package/dist/{index-MBQ1Ksjt.d.ts → index-CQ1vFI8s.d.ts} +5 -1
- package/dist/index.d.cts +273 -131
- package/dist/index.d.ts +273 -131
- package/dist/index.js +157 -134
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +154 -134
- package/dist/index.mjs.map +1 -1
- package/dist/twitter/index.d.cts +1 -1
- package/dist/twitter/index.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -123,6 +123,40 @@ Etsy and AliExpress category navigation is separate from search: their search me
|
|
|
123
123
|
| **ChatGPT** | Prompt the real chatgpt.com anonymously — structured answer with citations anchored to character offsets, the full retrieved search trail, and AEO/GEO brand-visibility analysis | [ChatGPT Guide](docs/chatgpt.md) |
|
|
124
124
|
| **Gemini** | Prompt the real gemini.google.com anonymously — structured answer with cited web sources, the full retrieved search trail, and AEO/GEO brand-visibility analysis | [Gemini Docs](https://docs.scrapebadger.com/gemini/overview) |
|
|
125
125
|
|
|
126
|
+
## Quotes, feedback and free re-reads
|
|
127
|
+
|
|
128
|
+
These calls are free and never billed.
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
import { ScrapeBadger, type AgentTrial } from "scrapebadger";
|
|
132
|
+
|
|
133
|
+
const client = new ScrapeBadger({ apiKey: "your-api-key" });
|
|
134
|
+
|
|
135
|
+
// What would a call cost, are its params valid, how long does it take?
|
|
136
|
+
const quote = await client.agent.quote("GET", "/v1/google/search", { params: { q: "coffee" } });
|
|
137
|
+
console.log(quote.valid, quote.errors, quote.credits.max, quote.usd, quote.latency);
|
|
138
|
+
|
|
139
|
+
// Re-read a billed result for ~15 minutes, reshaped. The ID is the call's
|
|
140
|
+
// X-Result-ID header (raw HTTP, the CLI) or AsyncRequest.resultId.
|
|
141
|
+
const titles = await client.results.get<string[]>(resultId, { jq: "[.organic_results[].title]" });
|
|
142
|
+
const outline = await client.results.get(resultId, { summary: true });
|
|
143
|
+
const first5 = await client.results.get(resultId, { fields: ["title", "link"], maxItems: 5 });
|
|
144
|
+
|
|
145
|
+
// Poll a call made with `Prefer: respond-async` (202 + request_id).
|
|
146
|
+
const state = await client.requests.get(requestId);
|
|
147
|
+
if (!state.running) console.log(state.status, state.creditsUsed, state.data);
|
|
148
|
+
|
|
149
|
+
// Report a bug or send feedback (pass the failing call's X-Request-ID).
|
|
150
|
+
await client.agent.reportBug("Empty results for a valid query", { requestId });
|
|
151
|
+
await client.agent.feedback("Need a Google Maps photos endpoint");
|
|
152
|
+
|
|
153
|
+
// Agent trial keys: account info carries an `agent_trial` block.
|
|
154
|
+
const info = await client.account.getAccountInfo();
|
|
155
|
+
const trial = info.agent_trial as AgentTrial | undefined;
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
`results.get` returns the stored body as-is (any JSON value) and throws `NotFoundError` once it has expired. `requests.get` returns `running: true` while the call is in progress — wait `retryAfterSeconds` and poll again; never re-submit the call. Once finished it returns the original body, or throws the original call's error. The SDK's own methods never send `Prefer: respond-async`; `requests.get` polls a request ID obtained elsewhere (raw HTTP, the CLI or MCP server).
|
|
159
|
+
|
|
126
160
|
## Error Handling
|
|
127
161
|
|
|
128
162
|
```typescript
|
|
@@ -35,6 +35,10 @@ interface RateLimit {
|
|
|
35
35
|
interface ResponseWithHeaders<T> {
|
|
36
36
|
data: T;
|
|
37
37
|
rateLimit?: RateLimit;
|
|
38
|
+
/** HTTP status of the response (a 2xx — errors throw). */
|
|
39
|
+
status?: number;
|
|
40
|
+
/** Raw response headers. */
|
|
41
|
+
headers?: Headers;
|
|
38
42
|
}
|
|
39
43
|
interface RequestOptions {
|
|
40
44
|
method?: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
|
|
@@ -69,7 +73,7 @@ declare class BaseClient {
|
|
|
69
73
|
status: number;
|
|
70
74
|
}>;
|
|
71
75
|
/**
|
|
72
|
-
* Make an HTTP request and return
|
|
76
|
+
* Make an HTTP request and return the data with its rate limit, status and headers.
|
|
73
77
|
*/
|
|
74
78
|
requestWithHeaders<T>(path: string, options?: RequestOptions): Promise<ResponseWithHeaders<T>>;
|
|
75
79
|
/**
|
|
@@ -35,6 +35,10 @@ interface RateLimit {
|
|
|
35
35
|
interface ResponseWithHeaders<T> {
|
|
36
36
|
data: T;
|
|
37
37
|
rateLimit?: RateLimit;
|
|
38
|
+
/** HTTP status of the response (a 2xx — errors throw). */
|
|
39
|
+
status?: number;
|
|
40
|
+
/** Raw response headers. */
|
|
41
|
+
headers?: Headers;
|
|
38
42
|
}
|
|
39
43
|
interface RequestOptions {
|
|
40
44
|
method?: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
|
|
@@ -69,7 +73,7 @@ declare class BaseClient {
|
|
|
69
73
|
status: number;
|
|
70
74
|
}>;
|
|
71
75
|
/**
|
|
72
|
-
* Make an HTTP request and return
|
|
76
|
+
* Make an HTTP request and return the data with its rate limit, status and headers.
|
|
73
77
|
*/
|
|
74
78
|
requestWithHeaders<T>(path: string, options?: RequestOptions): Promise<ResponseWithHeaders<T>>;
|
|
75
79
|
/**
|