socialcrawl-mcp 2.2.0 → 2.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 +42 -20
- package/dist/app.d.ts +3 -3
- package/dist/app.js +5 -1
- package/dist/client-tag.d.ts +13 -0
- package/dist/client-tag.js +17 -0
- package/dist/client.js +6 -4
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/context.d.ts +6 -0
- package/dist/context.js +1 -0
- package/dist/data/docs-async.d.ts +2 -2
- package/dist/data/docs-async.js +137 -116
- package/dist/data/docs-handwritten.js +46 -5
- package/dist/data/docs.js +2 -0
- package/dist/data/endpoints.js +13111 -10305
- package/dist/data/examples.js +2 -2
- package/dist/data/guide.d.ts +2 -2
- package/dist/data/guide.js +2 -2
- package/dist/data/outputs.js +324 -219
- package/dist/data/platforms.js +207 -48
- package/dist/data/recipes.js +1 -1
- package/dist/data/registry-meta.d.ts +8 -8
- package/dist/data/registry-meta.js +8 -8
- package/dist/hydration.js +21 -3
- package/dist/oauth/config.d.ts +19 -4
- package/dist/oauth/config.js +31 -6
- package/dist/schemas/async.d.ts +37 -27
- package/dist/schemas/async.js +28 -9
- package/dist/schemas/outputs.d.ts +2 -2
- package/dist/schemas/tools.d.ts +18 -6
- package/dist/schemas/tools.js +24 -4
- package/dist/server.js +6 -5
- package/dist/tools/account.d.ts +4 -1
- package/dist/tools/account.js +1 -1
- package/dist/tools/async-common.js +3 -1
- package/dist/tools/check-balance.d.ts +4 -2
- package/dist/tools/check-balance.js +9 -0
- package/dist/tools/discover-runs.js +117 -11
- package/dist/tools/estimate.js +10 -1
- package/dist/tools/manage.js +2 -0
- package/dist/tools/monitors.d.ts +7 -1
- package/dist/tools/monitors.js +26 -2
- package/package.json +75 -75
package/dist/data/docs-async.js
CHANGED
|
@@ -6,81 +6,100 @@
|
|
|
6
6
|
* {routes,resume,more,schedule-routes}.ts, platforms/review-history/
|
|
7
7
|
* {http,engine}.ts, events/{feed,routes}.ts, webhooks/{http,limits}.ts.
|
|
8
8
|
*/
|
|
9
|
-
export const DISCOVER_RUNS_DOC = `# SocialCrawl API — Discover runs, schedules and review history
|
|
10
|
-
|
|
11
|
-
Work that keeps running after the call that started it. Start it with \`socialcrawl_request\`; read, export, steer and stop it with \`socialcrawl_manage\` (areas \`discover\` and \`review_history\`). Every read here is free; only the searches a run goes on to make are billed.
|
|
12
|
-
|
|
13
|
-
## Discover runs (\`/v1/prism/discover/runs\`)
|
|
14
|
-
|
|
15
|
-
Start a run with \`socialcrawl_request\` on \`prism/discover\` (\`max_credits\` is required; \`async\` runs it in the background). Manage it with \`socialcrawl_manage\` \`area: "discover"\`; \`id\` is the run id (\`run_…\`, \`data.run.run_id\`).
|
|
16
|
-
|
|
17
|
-
| Action | Route | Cost |
|
|
18
|
-
|--------|-------|------|
|
|
19
|
-
| \`run_list\` | \`GET /runs\` (status, kind, created_after, cursor, page_size ≤100; \`id\` = a schedule id lists that schedule's runs) | 0 |
|
|
20
|
-
| \`run_get\` | \`GET /runs/{run_id}\` | 0 |
|
|
21
|
-
| \`run_export\` | \`GET /runs/{run_id}/results.jsonl\` | 0 |
|
|
22
|
-
| \`run_legs\` | \`GET /runs/{run_id}/legs\` (page_size ≤500) | 0 |
|
|
23
|
-
| \`run_cancel\` | \`DELETE /runs/{run_id}\` | 0 — rows kept, resume continues |
|
|
24
|
-
| \`run_resume\` | \`POST /runs/{run_id}/resume\` \`{ max_credits?, retry_failed? }\` | 0 itself; continued searches bill as they run |
|
|
25
|
-
| \`run_more\` | \`POST /runs/{run_id}/more\` \`{ new_searches?, feedback?, max_credits?, pages? }\` | each new search bills at its lane price |
|
|
26
|
-
|
|
27
|
-
- **Long-poll:** \`run_get\` with \`wait_s\` (0-25) answers early on a status change, a finished stage or 10% more rows. At most 5 long-polls per key; a sixth answers at once.
|
|
28
|
-
- **Filters** (run_get and run_export): view, order (arrival | rank; rank on a running run is a free 400), include_pending, changes_since, group, platform, keyword, sort, state (kept | dropped | all), include=dropped, and \`tags\` sent as \`tag.<key>=<value>\`. Any parameter the route does not take is a free 400. A cursor is signed with the filters it was issued for: send the SAME filters with it.
|
|
29
|
-
- **run_export** streams every matching row; the last line is \`{"complete":true}\` or \`{"next_cursor":"…"}\` (stopped after about 45 s; send it back with the same filters).
|
|
30
|
-
- **run_resume** works on paused, partial, failed or cancelled runs. A run paused at its cap needs a HIGHER \`max_credits\`. Searches already paid for are never paid twice.
|
|
31
|
-
- **run_more** works on completed runs only: \`pages\` 1-10, \`feedback.accept\`/\`feedback.reject\` up to 100 ids each (\`accept\` needs \`new_searches: true\`). Read only the new rows with \`changes_since\` = \`data.more.since_version\`. \`data.more.nothing_more\` (200) charged nothing. The route takes no Idempotency-Key, so check the run before repeating a more.
|
|
32
|
-
- **No dry_run** on any run or schedule route (resume and more refuse any query parameter).
|
|
33
|
-
- **Errors:** 404 RUN_NOT_FOUND (not your run), 409 RUN_STATE_CONFLICT, 410 RUN_EXPIRED (retention passed), 503 store_unavailable (retryable, nothing charged).
|
|
34
|
-
|
|
35
|
-
## Discover schedules (\`/v1/prism/discover/schedules\`)
|
|
36
|
-
|
|
37
|
-
Created by \`prism/discover\` with a \`schedule\` field. All free; each scheduled run bills like a run within \`max_credits_per_run\` and \`max_credits_per_month\`. \`id\` is the schedule id (\`dsch_…\`).
|
|
38
|
-
|
|
39
|
-
\`schedule_list\` (status active | paused | stopped, cursor, page_size ≤100), \`schedule_get\` (its recent runs, this month's spend, next fire), \`schedule_pause\`, \`schedule_resume\` (\`{ max_credits_per_run?, max_credits_per_month? }\`, null clears the month cap), \`schedule_delete\` (runs keep their rows). \`run_list\` with the schedule id lists one schedule's runs.
|
|
40
|
-
|
|
41
|
-
##
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
##
|
|
46
|
-
|
|
47
|
-
|
|
9
|
+
export const DISCOVER_RUNS_DOC = `# SocialCrawl API — Discover runs, schedules and review history
|
|
10
|
+
|
|
11
|
+
Work that keeps running after the call that started it. Start it with \`socialcrawl_request\`; read, export, steer and stop it with \`socialcrawl_manage\` (areas \`discover\` and \`review_history\`). Every read here is free; only the searches a run goes on to make are billed.
|
|
12
|
+
|
|
13
|
+
## Discover runs (\`/v1/prism/discover/runs\`)
|
|
14
|
+
|
|
15
|
+
Start a run with \`socialcrawl_request\` on \`prism/discover\` (\`max_credits\` is required; \`async\` runs it in the background). Manage it with \`socialcrawl_manage\` \`area: "discover"\`; \`id\` is the run id (\`run_…\`, \`data.run.run_id\`). Runs created since 14/11/2026 are kept 30 days by default (was 7); \`retention_days\` is 1 to 30.
|
|
16
|
+
|
|
17
|
+
| Action | Route | Cost |
|
|
18
|
+
|--------|-------|------|
|
|
19
|
+
| \`run_list\` | \`GET /runs\` (status, kind, created_after, cursor, page_size ≤100; \`id\` = a schedule id lists that schedule's runs) | 0 |
|
|
20
|
+
| \`run_get\` | \`GET /runs/{run_id}\` | 0 |
|
|
21
|
+
| \`run_export\` | \`GET /runs/{run_id}/results.jsonl\` | 0 |
|
|
22
|
+
| \`run_legs\` | \`GET /runs/{run_id}/legs\` (page_size ≤500) | 0 |
|
|
23
|
+
| \`run_cancel\` | \`DELETE /runs/{run_id}\` | 0 — rows kept, resume continues |
|
|
24
|
+
| \`run_resume\` | \`POST /runs/{run_id}/resume\` \`{ max_credits?, retry_failed? }\` | 0 itself; continued searches bill as they run |
|
|
25
|
+
| \`run_more\` | \`POST /runs/{run_id}/more\` \`{ new_searches?, feedback?, max_credits?, pages? }\` | each new search bills at its lane price |
|
|
26
|
+
|
|
27
|
+
- **Long-poll:** \`run_get\` with \`wait_s\` (0-25) answers early on a status change, a finished stage or 10% more rows. At most 5 long-polls per key; a sixth answers at once.
|
|
28
|
+
- **Filters** (run_get and run_export): view, order (arrival | rank; rank on a running run is a free 400), include_pending, changes_since, group, platform, keyword, sort, state (kept | dropped | all), include=dropped, and \`tags\` sent as \`tag.<key>=<value>\`. Any parameter the route does not take is a free 400. A cursor is signed with the filters it was issued for: send the SAME filters with it.
|
|
29
|
+
- **run_export** streams every matching row; the last line is \`{"complete":true}\` or \`{"next_cursor":"…"}\` (stopped after about 45 s; send it back with the same filters).
|
|
30
|
+
- **run_resume** works on paused, partial, failed or cancelled runs. A run paused at its cap needs a HIGHER \`max_credits\`. Searches already paid for are never paid twice.
|
|
31
|
+
- **run_more** works on completed runs only: \`pages\` 1-10, \`feedback.accept\`/\`feedback.reject\` up to 100 ids each (\`accept\` needs \`new_searches: true\`). Read only the new rows with \`changes_since\` = \`data.more.since_version\`. \`data.more.nothing_more\` (200) charged nothing. The route takes no Idempotency-Key, so check the run before repeating a more.
|
|
32
|
+
- **No dry_run** on any run or schedule route (resume and more refuse any query parameter).
|
|
33
|
+
- **Errors:** 404 RUN_NOT_FOUND (not your run), 409 RUN_STATE_CONFLICT, 410 RUN_EXPIRED (retention passed), 503 store_unavailable (retryable, nothing charged).
|
|
34
|
+
|
|
35
|
+
## Discover schedules (\`/v1/prism/discover/schedules\`)
|
|
36
|
+
|
|
37
|
+
Created by \`prism/discover\` with a \`schedule\` field. All free; each scheduled run bills like a run within \`max_credits_per_run\` and \`max_credits_per_month\`. \`id\` is the schedule id (\`dsch_…\`).
|
|
38
|
+
|
|
39
|
+
\`schedule_list\` (status active | paused | stopped, cursor, page_size ≤100), \`schedule_get\` (its recent runs, this month's spend, next fire), \`schedule_pause\`, \`schedule_resume\` (\`{ max_credits_per_run?, max_credits_per_month? }\`, null clears the month cap), \`schedule_delete\` (runs keep their rows). \`run_list\` with the schedule id lists one schedule's runs.
|
|
40
|
+
|
|
41
|
+
## Stored lists (\`/v1/prism/discover/inputs\`)
|
|
42
|
+
|
|
43
|
+
Make one with \`socialcrawl_request\` on \`POST prism/discover/inputs\` (\`{ kind: "authors", authors: [...] }\` up to 10,000 handles, or \`{ kind: "exclude", exclude: [...] }\` up to 50,000 entries); the answer's \`author_list_id\` / \`exclude_list_id\` (\`din_…\`) goes into a discover call. Then, free: \`input_list\` (every live list with \`item_count\` and \`expires_at\`, plus \`live\` of \`limit\` 500 per account), \`input_append\` (\`id\` + \`{ exclude: [...] }\`, 1 to 50,000 entries; duplicates skipped, the expiry moves to 31 days; past 50,000 in all it is a free 400 \`exclude_list_full\`), \`input_delete\`. An unknown, expired or foreign id, or an author list sent to append, is a 404 \`input_not_found\`. Lists live 30 days.
|
|
44
|
+
|
|
45
|
+
## Review history (\`/v1/{platform}/reviews/history/{job_id}\`)
|
|
46
|
+
|
|
47
|
+
Start a job with \`socialcrawl_request\` on the POST for the platform — it holds the price and answers 202 with \`job_id\` (\`job_…\`):
|
|
48
|
+
|
|
49
|
+
| Start (POST) | Poll with \`platform\` | Price |
|
|
50
|
+
|---|---|---|
|
|
51
|
+
| \`trustpilot/reviews/history\` | \`trustpilot\` (default) | holds \`depth\` + 5 |
|
|
52
|
+
| \`tripadvisor/reviews/history\` | \`tripadvisor\` | holds \`depth\` |
|
|
53
|
+
| \`google/business/reviews/history\` (exactly one of \`place_id\` or \`cid\`, \`depth\` 1-10,000) | \`google\` | 5 per started 100 reviews collected; none collected is refunded in full |
|
|
54
|
+
| \`yelp/business/reviews/history\` | \`yelp\` | 1 per started 4 pages (held at 52 a language; \`languages=all\` holds 154); honours \`Idempotency-Key\` |
|
|
55
|
+
|
|
56
|
+
Poll with \`socialcrawl_manage\` \`area: "review_history"\`, \`action: "get"\`, \`id\` = the job id, free. Trustpilot, Tripadvisor and Google: status queued → running → polling → succeeded | failed; once settled each page carries \`data.items\` and \`data.job\` (\`credits_hold\`, the settled \`credits_charged\`, \`expires_at\`); page with \`offset\` and \`limit\` (1-100) until a page is shorter than \`limit\`. Yelp: rows are readable while the job runs, each page carries \`data.job\` (\`pages_read\`, \`reviews_collected\`, per-language progress), \`total\` and \`next_offset\` (null on the last page). Jobs live 7 days.
|
|
57
|
+
|
|
58
|
+
## Bulk review history (\`POST /v1/prism/reviews/bulk\`)
|
|
59
|
+
|
|
60
|
+
One background job over up to 20,000 businesses or apps: \`platform\` (\`yelp\`, \`tripadvisor\`, \`app_store\`, \`google_play\`), \`items\`, optional \`since\` / \`until\`, \`languages\` (not Tripadvisor or App Store), \`max_reviews_per_item\`, \`format\` (\`jsonl\` | \`csv\`), \`include\` (\`business\`, \`business_full\` on Yelp, \`none\`), \`country\` (App Store, Google Play), \`webhook_url\` (https; the 202 shows its \`webhook_secret\` once) and \`refresh_of\` (an earlier job of this key: reuses its items and starts from the day it settled). Start it with \`socialcrawl_request\`. It bills 1 credit per started 4 pages over the whole job, reserved 25 credits at a time; a business that cannot be read costs nothing. When the next block cannot be held the job pauses as \`paused_insufficient_credits\` and resumes after a top-up (webhook events \`reviews_bulk.paused\`, \`resumed\`, \`completed\`, signed \`x-socialcrawl-signature\`). \`Idempotency-Key\` replays the job at 0 credits.
|
|
61
|
+
|
|
62
|
+
Then, free: \`action: "bulk_get"\` (progress, each item's \`status\` pending | walking | waiting | done | unavailable, and signed links to the combined file, the manifest and each item's file, valid 1 hour; page items with \`offset\`/\`limit\`) and \`action: "bulk_cancel"\` (keeps and bills what was read; the job can still read \`running\` until it settles as \`cancelled\`). There is no list route: keep the job id.
|
|
63
|
+
|
|
64
|
+
## follow
|
|
65
|
+
|
|
66
|
+
Answers carry ready next-step URLs in \`data.next.*\`. \`socialcrawl_manage\` \`area: "discover"\`, \`action: "follow"\`, \`input: { url }\` GETs one only when it is on the configured SocialCrawl API AND one of the free read routes above (batch jobs, discover runs and schedules, review history, the events feed, webhook endpoints). \`status_url\`, \`results_url\`, \`changes_url\` and \`poll_url\` are free reads. \`continue_url\` STARTS a billable continuation and is never followed (call \`socialcrawl_request\` after checking \`continue_estimate\`); \`resume_url\`/\`more_url\` are POSTs: use \`run_resume\`/\`run_more\`.
|
|
48
67
|
`;
|
|
49
|
-
export const EVENTS_DOC = `# SocialCrawl API — Account events feed and webhook endpoints
|
|
50
|
-
|
|
51
|
-
The account event log records what happens to this key's background work: discover runs (\`discover.completed\`, \`discover.partial\`, \`discover.paused\`, \`discover.failed\`, \`discover.progress\`, \`discover.accounts_ready\`, \`discover.new_rows\`, \`discover.new_accounts\`, \`discover.new_items\`), schedules (\`discover.run_skipped\`, \`discover.run_failed\`) and webhook endpoint health (\`endpoint.disabled\`). Pull it with the feed or have it pushed to a webhook endpoint. Use \`socialcrawl_manage\` \`area: "events"\`. Everything here costs **0 credits**, and no route here takes \`dry_run\`.
|
|
52
|
-
|
|
53
|
-
## Feed (\`GET /v1/events\`)
|
|
54
|
-
|
|
55
|
-
- **Your own cursor:** \`cursor\` = \`oldest\` (start of the 30-day retention), \`now\` (only new events), an event id (\`evt_…\`) or \`pagination.next_cursor\` exactly as returned. Save \`next_cursor\` after each page.
|
|
56
|
-
- **Named consumer:** \`id\` = a consumer name (a-z, 0-9, _ and -, up to 64). The server keeps its position; \`start\` (now | oldest) sets where a new consumer begins; its \`types\`/\`subject_ids\` filters bind at first use. A read commits nothing: process the page, then \`ack\` its \`pagination.next_cursor\` (\`POST /v1/events/consumers/{name}/ack\`, same \`id\`, \`input: { cursor }\`). Until you ack, the read returns the same page.
|
|
57
|
-
- Not both \`cursor\` and a consumer (a free 400).
|
|
58
|
-
- **Filters:** \`types\` (up to 50 types or patterns: \`discover.completed\`, \`discover.*\`, \`*\`) and \`subject_ids\` (up to 100 run_… or dsch_… ids). \`limit\` 1-500 (default 100).
|
|
59
|
-
- **Long-poll:** \`wait_s\` (0-25) holds an empty read until an event arrives. At most 5 long-polls per key; a sixth answers at once.
|
|
60
|
-
- **410 CURSOR_EXPIRED:** the position is older than the 30-day retention, so events were missed. Restart from \`oldest\` (a consumer restarts there on its next read and says \`restarted_from\` once) and tell the user which window was missed.
|
|
61
|
-
- \`data.next.poll_url\` is a free read: \`area: "discover"\` action \`follow\` can GET it.
|
|
62
|
-
|
|
63
|
-
## Webhook endpoints (\`/v1/webhook-endpoints\`)
|
|
64
|
-
|
|
65
|
-
At most **20 per API key**; an endpoint answers only to the key that created it. \`id\` is the endpoint id (\`we_…\`, \`data.endpoint.id\`).
|
|
66
|
-
|
|
67
|
-
| Action | Route |
|
|
68
|
-
|--------|-------|
|
|
69
|
-
| \`endpoint_create\` | \`POST /\` \`{ url, types?, description?, subject_ids? }\` (201) |
|
|
70
|
-
| \`endpoint_list\` | \`GET /\` (limit ≤100, cursor, status) |
|
|
71
|
-
| \`endpoint_get\` | \`GET /{id}\` |
|
|
72
|
-
| \`endpoint_update\` | \`PATCH /{id}\` (url, types, description, subject_ids, status enabled/disabled) |
|
|
73
|
-
| \`endpoint_delete\` | \`DELETE /{id}\` |
|
|
74
|
-
| \`endpoint_rotate_secret\` | \`POST /{id}/rotate-secret\` |
|
|
75
|
-
| \`endpoint_test\` | \`POST /{id}/test\` \`{ type? }\` |
|
|
76
|
-
| \`endpoint_attempts\` | \`GET /{id}/attempts\` (limit ≤100, cursor) |
|
|
77
|
-
|
|
78
|
-
- **The secret is shown ONCE.** \`endpoint_create\` and \`endpoint_rotate_secret\` return a \`whsec_\` secret in \`data.secret\`; store it immediately. Both send an Idempotency-Key (generated when you omit it, and echoed): a replay never creates a second endpoint and never shows the secret again. If it is lost, rotate with a NEW key.
|
|
79
|
-
- **Rotation:** for 24 hours every delivery is signed with both the old and the new secret, so deploy the new one before then.
|
|
80
|
-
- **URL rules:** a public HTTPS receiver. Private hosts and chat-app incoming webhooks are refused (400 invalid_webhook_url).
|
|
81
|
-
- **Types** default to \`["*"]\`. \`endpoint_test\` sends one signed sample of a subscribed type; the receiver has 15 s to answer 2xx. Answering 410 to a real delivery disables the endpoint.
|
|
82
|
-
- **Retries:** a failing delivery gets 8 attempts in all, backing off over roughly 41 hours; \`endpoint_attempts\` shows the log. Setting \`status: "enabled"\` on a disabled endpoint resumes its parked deliveries at once.
|
|
83
|
-
- **Links are full URLs.** An event's \`links\` (\`run\`, \`results\`, \`changes\`) start with the API's https origin; pass any of them to action \`follow\` (areas \`discover\`, \`search_runs\`, \`creator_runs\`).
|
|
68
|
+
export const EVENTS_DOC = `# SocialCrawl API — Account events feed and webhook endpoints
|
|
69
|
+
|
|
70
|
+
The account event log records what happens to this key's background work: discover runs (\`discover.completed\`, \`discover.partial\`, \`discover.paused\`, \`discover.failed\`, \`discover.progress\`, \`discover.accounts_ready\`, \`discover.new_rows\`, \`discover.new_accounts\`, \`discover.new_items\`), schedules (\`discover.run_skipped\`, \`discover.run_failed\`) and webhook endpoint health (\`endpoint.disabled\`). Pull it with the feed or have it pushed to a webhook endpoint. Use \`socialcrawl_manage\` \`area: "events"\`. Everything here costs **0 credits**, and no route here takes \`dry_run\`.
|
|
71
|
+
|
|
72
|
+
## Feed (\`GET /v1/events\`)
|
|
73
|
+
|
|
74
|
+
- **Your own cursor:** \`cursor\` = \`oldest\` (start of the 30-day retention), \`now\` (only new events), an event id (\`evt_…\`) or \`pagination.next_cursor\` exactly as returned. Save \`next_cursor\` after each page.
|
|
75
|
+
- **Named consumer:** \`id\` = a consumer name (a-z, 0-9, _ and -, up to 64). The server keeps its position; \`start\` (now | oldest) sets where a new consumer begins; its \`types\`/\`subject_ids\` filters bind at first use. A read commits nothing: process the page, then \`ack\` its \`pagination.next_cursor\` (\`POST /v1/events/consumers/{name}/ack\`, same \`id\`, \`input: { cursor }\`). Until you ack, the read returns the same page.
|
|
76
|
+
- Not both \`cursor\` and a consumer (a free 400).
|
|
77
|
+
- **Filters:** \`types\` (up to 50 types or patterns: \`discover.completed\`, \`discover.*\`, \`*\`) and \`subject_ids\` (up to 100 run_… or dsch_… ids). \`limit\` 1-500 (default 100).
|
|
78
|
+
- **Long-poll:** \`wait_s\` (0-25) holds an empty read until an event arrives. At most 5 long-polls per key; a sixth answers at once.
|
|
79
|
+
- **410 CURSOR_EXPIRED:** the position is older than the 30-day retention, so events were missed. Restart from \`oldest\` (a consumer restarts there on its next read and says \`restarted_from\` once) and tell the user which window was missed.
|
|
80
|
+
- \`data.next.poll_url\` is a free read: \`area: "discover"\` action \`follow\` can GET it.
|
|
81
|
+
|
|
82
|
+
## Webhook endpoints (\`/v1/webhook-endpoints\`)
|
|
83
|
+
|
|
84
|
+
At most **20 per API key**; an endpoint answers only to the key that created it. \`id\` is the endpoint id (\`we_…\`, \`data.endpoint.id\`).
|
|
85
|
+
|
|
86
|
+
| Action | Route |
|
|
87
|
+
|--------|-------|
|
|
88
|
+
| \`endpoint_create\` | \`POST /\` \`{ url, types?, description?, subject_ids? }\` (201) |
|
|
89
|
+
| \`endpoint_list\` | \`GET /\` (limit ≤100, cursor, status) |
|
|
90
|
+
| \`endpoint_get\` | \`GET /{id}\` |
|
|
91
|
+
| \`endpoint_update\` | \`PATCH /{id}\` (url, types, description, subject_ids, status enabled/disabled) |
|
|
92
|
+
| \`endpoint_delete\` | \`DELETE /{id}\` |
|
|
93
|
+
| \`endpoint_rotate_secret\` | \`POST /{id}/rotate-secret\` |
|
|
94
|
+
| \`endpoint_test\` | \`POST /{id}/test\` \`{ type? }\` |
|
|
95
|
+
| \`endpoint_attempts\` | \`GET /{id}/attempts\` (limit ≤100, cursor) |
|
|
96
|
+
|
|
97
|
+
- **The secret is shown ONCE.** \`endpoint_create\` and \`endpoint_rotate_secret\` return a \`whsec_\` secret in \`data.secret\`; store it immediately. Both send an Idempotency-Key (generated when you omit it, and echoed): a replay never creates a second endpoint and never shows the secret again. If it is lost, rotate with a NEW key.
|
|
98
|
+
- **Rotation:** for 24 hours every delivery is signed with both the old and the new secret, so deploy the new one before then.
|
|
99
|
+
- **URL rules:** a public HTTPS receiver. Private hosts and chat-app incoming webhooks are refused (400 invalid_webhook_url).
|
|
100
|
+
- **Types** default to \`["*"]\`. \`endpoint_test\` sends one signed sample of a subscribed type; the receiver has 15 s to answer 2xx. Answering 410 to a real delivery disables the endpoint.
|
|
101
|
+
- **Retries:** a failing delivery gets 8 attempts in all, backing off over roughly 41 hours; \`endpoint_attempts\` shows the log. Setting \`status: "enabled"\` on a disabled endpoint resumes its parked deliveries at once.
|
|
102
|
+
- **Links are full URLs.** An event's \`links\` (\`run\`, \`results\`, \`changes\`) start with the API's https origin; pass any of them to action \`follow\` (areas \`discover\`, \`search_runs\`, \`creator_runs\`).
|
|
84
103
|
`;
|
|
85
104
|
/**
|
|
86
105
|
* Universal search runs, lists and watches (UPGRADE-LOG API-073, API-077,
|
|
@@ -89,47 +108,49 @@ At most **20 per API key**; an endpoint answers only to the key that created it.
|
|
|
89
108
|
* meta-search/{list-http,list-start,list-actions,list-more,list-followups,
|
|
90
109
|
* list-watch,list-watch-routes,stored-runs}.ts and prism/creators/follow.ts.
|
|
91
110
|
*/
|
|
92
|
-
export const SEARCH_RUNS_DOC = `# SocialCrawl API — Universal search runs, lists, watches and creator runs
|
|
93
|
-
|
|
94
|
-
\`GET /v1/search/everywhere\` answers one search in the call (20 credits, flat). Everything that keeps working after the call — a list of searches, a scheduled watch, the next page, follow-up reads — is a **run**, read and steered with \`socialcrawl_manage\` area \`search_runs\`. Every read is free.
|
|
95
|
-
|
|
96
|
-
## Start one (socialcrawl_request, \`POST /v1/search/everywhere\`)
|
|
97
|
-
|
|
98
|
-
The JSON body takes every search field of the GET (\`query\` or \`keywords\`, \`context\`, \`platforms\`, \`exclude_platforms\`, \`period\`/\`since\`/\`until\`, \`languages\`, \`country\`, \`depth\`, \`label\`, …) plus exactly one of:
|
|
99
|
-
|
|
100
|
-
- **\`queries\`** — up to 100 search strings (≤512 chars each). One background run; each search is a job that reserves its own **20 credits**.
|
|
101
|
-
- **\`groups\`** — 1-100 \`{id, query | keywords, context?, platforms?, exclude_platforms?, period?, since?, until?, tags?}\`. A group's rows keep their own order; one de-duplication runs across the list, and a row several groups found lists them in \`also_in_groups\`.
|
|
102
|
-
- **\`schedule\`** — \`{every: 1h|6h|12h|1d|7d|30d, max_credits_per_run, max_credits_per_month?, name, start_at?}\` turns the search (or list) into a **watch**: each fire returns only rows that watch never delivered (the first fire marks its rows \`baseline: true\`).
|
|
103
|
-
|
|
104
|
-
**Price:** 20 credits per search plus any extras' ceilings (\`comments.*\`, \`authors.*\`). A list needs \`max_credits\` at or above that estimate; nothing is held at submit, each search charges as it runs, and the run **pauses** at \`max_credits\`, the key budget or the balance with \`data.next.resume_url\` — nothing is paid twice. A watch needs \`max_credits_per_run\` at least one fire's estimate; each fire bills like the list (no surcharge, no refund when nothing is new). \`dry_run: true\` answers the plan and estimate for free — on a watch, the price of a fire (\`credits_per_fire\`) and of 30 days (\`credits_per_30_days\`). The answer is **202** with \`data.run\` and \`data.next.status_url\` (a watch adds \`data.watch\`). \`Idempotency-Key\` replays the first answer; the same request sent again while its run is live returns that run (\`run.deduplicated\`).
|
|
105
|
-
|
|
106
|
-
## Runs (area \`search_runs\`)
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
|
111
|
-
|
|
112
|
-
| \`
|
|
113
|
-
| \`
|
|
114
|
-
| \`
|
|
115
|
-
| \`
|
|
116
|
-
| \`
|
|
117
|
-
| \`
|
|
118
|
-
|
|
119
|
-
\`
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
\`
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
111
|
+
export const SEARCH_RUNS_DOC = `# SocialCrawl API — Universal search runs, lists, watches and creator runs
|
|
112
|
+
|
|
113
|
+
\`GET /v1/search/everywhere\` answers one search in the call (20 credits, flat). Everything that keeps working after the call — a list of searches, a scheduled watch, the next page, follow-up reads — is a **run**, read and steered with \`socialcrawl_manage\` area \`search_runs\`. Every read is free.
|
|
114
|
+
|
|
115
|
+
## Start one (socialcrawl_request, \`POST /v1/search/everywhere\`)
|
|
116
|
+
|
|
117
|
+
The JSON body takes every search field of the GET (\`query\` or \`keywords\`, \`context\`, \`platforms\`, \`exclude_platforms\`, \`period\`/\`since\`/\`until\`, \`languages\`, \`country\`, \`depth\`, \`label\`, …) plus exactly one of:
|
|
118
|
+
|
|
119
|
+
- **\`queries\`** — up to 100 search strings (≤512 chars each). One background run; each search is a job that reserves its own **20 credits**.
|
|
120
|
+
- **\`groups\`** — 1-100 \`{id, query | keywords, context?, platforms?, exclude_platforms?, period?, since?, until?, tags?}\`. A group's rows keep their own order; one de-duplication runs across the list, and a row several groups found lists them in \`also_in_groups\`.
|
|
121
|
+
- **\`schedule\`** — \`{every: 1h|6h|12h|1d|7d|30d, max_credits_per_run, max_credits_per_month?, name, start_at?}\` turns the search (or list) into a **watch**: each fire returns only rows that watch never delivered (the first fire marks its rows \`baseline: true\`).
|
|
122
|
+
|
|
123
|
+
**Price:** 20 credits per search plus any extras' ceilings (\`comments.*\`, \`authors.*\`). A list needs \`max_credits\` at or above that estimate; nothing is held at submit, each search charges as it runs, and the run **pauses** at \`max_credits\`, the key budget or the balance with \`data.next.resume_url\` — nothing is paid twice. A watch needs \`max_credits_per_run\` at least one fire's estimate; each fire bills like the list (no surcharge, no refund when nothing is new). \`dry_run: true\` answers the plan and estimate for free — on a watch, the price of a fire (\`credits_per_fire\`) and of 30 days (\`credits_per_30_days\`). The answer is **202** with \`data.run\` and \`data.next.status_url\` (a watch adds \`data.watch\`). \`Idempotency-Key\` replays the first answer; the same request sent again while its run is live returns that run (\`run.deduplicated\`).
|
|
124
|
+
|
|
125
|
+
## Runs (area \`search_runs\`)
|
|
126
|
+
|
|
127
|
+
Universal-search runs created since 14/11/2026 are kept 30 days by default (was 7); \`retention_days\` is 1 to 30.
|
|
128
|
+
|
|
129
|
+
| Action | Route | Cost |
|
|
130
|
+
|---|---|---|
|
|
131
|
+
| \`run_list\` | \`GET /v1/search/everywhere/runs\` — status, created_after, cursor, page_size 1-100; a watch id as \`id\` lists its fires | 0 |
|
|
132
|
+
| \`run_get\` | \`GET …/runs/{run_id}\` — \`wait_s\` 0-25 long-polls; format evidence\\|compact\\|text, fields, sort relevance\\|recent\\|engagement, max_per_platform, platform, group, state kept\\|dropped\\|all, changes_since, cursor, page_size | 0 |
|
|
133
|
+
| \`run_export\` | \`GET …/runs/{run_id}/results.jsonl\` — the same filters, no paging; ends with \`{"complete":true,"changes_url":…}\` | 0 |
|
|
134
|
+
| \`run_legs\` | \`GET …/runs/{run_id}/legs\` — every search with its outcome and credits | 0 |
|
|
135
|
+
| \`run_cancel\` | \`DELETE …/runs/{run_id}\` — a list only (409 \`run_not_a_list\` on a one-off) | 0 |
|
|
136
|
+
| \`run_resume\` | \`POST …/runs/{run_id}/resume\` — \`max_credits\` (higher, if it paused at its cap), \`retry_failed\` | 0 + the searches it runs |
|
|
137
|
+
| \`run_more\` | \`POST …/runs/{run_id}/more\` — the next page of every search that has one; \`max_credits\` is the run's new total cap | **20 credits per search** with another page; \`nothing_more\` is free; dry_run quotes it |
|
|
138
|
+
| \`run_include\` | \`POST …/runs/{run_id}/include\` — \`include\` comments\\|authors\\|body, \`ids\` (1-200 rows), \`comments.per_post\` 5-50, \`comments.replies\`, \`authors.top\` 1-100, \`max_credits\` | metered per read, capped by max_credits (default: the quote); dry_run answers \`estimate.credits {min, expected, max}\` |
|
|
139
|
+
|
|
140
|
+
\`run_more\` and \`run_include\` take \`Idempotency-Key\` and \`dry_run\`. Read only what a step added with \`run_get\` + \`changes_since\`, or follow \`data.next.changes_url\` — the page that serves a run's last row names it.
|
|
141
|
+
|
|
142
|
+
## Watches (area \`search_runs\`)
|
|
143
|
+
|
|
144
|
+
\`watch_list\` (status active\\|paused\\|stopped), \`watch_get\` (with its 10 latest fires), \`watch_delete\` — all free on \`/v1/search/everywhere/watches\`. \`watch_pause\` / \`watch_resume\` (new \`max_credits_per_run\` / \`max_credits_per_month\`) use the discover schedule routes a watch is built on. A watch view carries \`caps\`, \`spend.month\`, \`next_fire_at\`, \`last_fire {run_id, new_rows, results_url}\`.
|
|
145
|
+
|
|
146
|
+
## Creator runs (area \`creator_runs\`)
|
|
147
|
+
|
|
148
|
+
\`prism/creators\` (GET or POST, socialcrawl_request) works toward \`limit\` until it has the creators, runs dry or reaches \`max_credits\`, and says which (\`stopped_because\`, \`short_reason\`). Its run is read like a search run on \`/v1/prism/creators/runs\` (\`run_list\`, \`run_get\` with country / account_kind / platform / sort / order filters, \`run_export\`, \`run_legs\`, \`run_cancel\`, \`run_resume\`, \`run_more\`) — reads free.
|
|
149
|
+
|
|
150
|
+
\`run_save\` (\`POST …/runs/{run_id}/save\`, \`keys\` optional, Idempotency-Key) stores the creators as author lists — **free**, kept 30 days, counted in the 500 live stored lists per account (see Stored lists in the \`discover-runs\` topic), 10,000 handles each — and answers \`data.next.follow\`: a ready \`POST prism/discover\` schedule body (daily, event \`discover.new_rows\`) that watches those creators for new posts. It costs what its runs cost, with no premium.
|
|
151
|
+
|
|
152
|
+
## follow
|
|
153
|
+
|
|
154
|
+
Any \`data.next.*\` read URL (status_url, results_url, legs_url, changes_url, a watch's links) goes to action \`follow\` — absolute or relative, on the configured API only. POST links are refused with the action to use: more_url → \`run_more\`, include_url → \`run_include\`, resume_url → \`run_resume\`, a creator save → \`run_save\`.
|
|
134
155
|
`;
|
|
135
156
|
//# sourceMappingURL=docs-async.js.map
|
|
@@ -168,6 +168,12 @@ Judged lists carry free default labels (posts: sponsored, intent, niche · comme
|
|
|
168
168
|
|
|
169
169
|
\`socialcrawl_account\` with \`view: "transactions"\` returns the credit ledger: every deduction and refund with \`amount\`, \`balance_after\`, \`endpoint\`, and \`request_id\`. Deductions are negative and refunds positive, so a page of amounts sums to the balance delta. Look up a specific call with \`requestId\` to see exactly what a metered endpoint settled at.
|
|
170
170
|
|
|
171
|
+
## Tagging charges by client: \`x-client-tag\`
|
|
172
|
+
|
|
173
|
+
Send an optional \`x-client-tag\` header on any request (one of your own customers, a project, a job name) and it is stored on that request's charge and echoed back. Read spend per tag with \`GET /v1/credits/usage?group_by=tag\` (\`socialcrawl_account\` \`view: "usage"\`, \`group_by: "tag"\`) and one tag's receipts with \`GET /v1/credits/transactions?tag=<tag>\` (\`view: "transactions"\`, \`tag\`); each receipt carries its \`tag\`. A malformed tag is ignored, never refused, and the response says so with \`X-Client-Tag-Ignored\`. This MCP server sends the tag set in \`SOCIALCRAWL_CLIENT_TAG\` on every call, if you set one.
|
|
174
|
+
|
|
175
|
+
A usage read that would take longer than 20 s answers a free 503 that says to try a shorter range, one key (\`api_key_id\`) or fewer groups.
|
|
176
|
+
|
|
171
177
|
## Advisory warnings (ENV-03)
|
|
172
178
|
|
|
173
179
|
Successful responses may include an optional \`data._warnings\` string array — non-fatal notices from the transform pipeline (e.g. an engagement-rate clamp, or \`walk_deadline_reached\` on a server-side page walk). Treat as observability hints, not as failures.
|
|
@@ -223,6 +229,18 @@ A request that hits the request-scoped deadline returns a JSON 504 with the cred
|
|
|
223
229
|
|
|
224
230
|
**Bad input on a single-source lane is a free 400.** On lanes served by one source (\`weibo/profile\`, \`goodreads/quotes\`, \`airbnb/search\`, \`airbnb/listing/availability\` and the like), input the source cannot use is \`INVALID_REQUEST\` naming the param, at 0 credits — no longer a refunded, retryable 502. Fix the param; do not retry.
|
|
225
231
|
|
|
232
|
+
**Answers about the request are not outages.** Since mid-November 2026 these come back after one attempt as a free, non-retryable answer, where each was a refunded 502 after four: an age-restricted Facebook group or Threads profile (404 \`RESOURCE_NOT_FOUND\` that says so); \`sort=popular\` on a YouTube channel whose popular order cannot be read (400 naming \`sort=latest\`); a TikTok account that does not exist on \`profile/videos\`, \`user/followers\` or \`user/following\` (404); a YouTube channel, \`/c/\`, \`/user/\` or \`/post/\` link sent to a video lane (400 naming the right endpoint), and a video id that is not 11 characters (400); \`twitter/ai-search\` with both \`from_handles\` and \`exclude_handles\` (400) or \`from_date\` after \`to_date\` (422). Change the request; do not retry it.
|
|
233
|
+
|
|
234
|
+
**Expired cursors.** A cursor the source can no longer continue answers 400 \`INVALID_REQUEST\` saying the cursor expired — free on \`facebook/adlibrary/company/ads\`, refunded on \`twitter/tweet/replies\` (expired or foreign reply cursor). Start again from the first page.
|
|
235
|
+
|
|
236
|
+
**A paused source is not a timeout.** A 503 \`SERVICE_UNAVAILABLE\` with \`details.reason: "breaker_open"\` means one source is paused (spent quota or repeated failures): the call was refused without being sent and not billed. The message states until when; the same request without the named option (for example without \`sort=most_viewed\`) usually works now. With no time stated, wait for \`Retry-After\`. \`utility/explain-error\` explains a pasted one this way.
|
|
237
|
+
|
|
238
|
+
**Web pages that cannot be read.** \`web/scrape\` and \`web/extract\` answer a free 404 \`RESOURCE_NOT_FOUND\` with \`details.reason: "site_not_supported"\` for a site the scraper refuses by policy (a platform page also gets \`details.suggestion\`, the SocialCrawl endpoint to use instead), and \`details.reason: "url_unreachable"\` in about 1 s for a dead or unresolvable address. A Google redirect link (\`google.<tld>/url?q=…\`) is read as its target. \`page_state\` on \`web/scrape\` reports bot checks and blank pages, with a \`_warnings\` line.
|
|
239
|
+
|
|
240
|
+
**Retry-After.** A refunded 504 carries \`Retry-After: 30\`. A Reddit lane whose source stays rate-limited after its own retries answers a refunded 503 saying Reddit is momentarily rate-limited upstream, with Retry-After: 30. A 429 body carries \`error.details\` (the limit, the window and when it resets). A 504 whose every search timed out (\`*/search/mentions\`, \`*/search/hashtag\`) is the refunded 504 timeout, not a 502.
|
|
241
|
+
|
|
242
|
+
**Errors from monitors and background jobs** use the same envelope as every other route: \`success\`, \`status\`, \`doc_url\`, \`retryable\`, \`credits_used\` and \`request_id\` beside \`error.type\` and \`error.message\`. \`MONITOR_LIMIT_REACHED\` is a catalogued type.
|
|
243
|
+
|
|
226
244
|
## Names the API accepts for you
|
|
227
245
|
|
|
228
246
|
- **Common param names are renamed, not dropped.** \`sort\` (or \`sort_by\`, \`order_by\`, …), \`country\` (\`region\`, \`country_code\`, \`gl\`, \`geo\`, \`market\`, …), \`limit\` (\`page_size\`, \`per_page\`, \`count\`, \`num\`, …), and a dated \`since\` / \`until\` (or \`start_date\`, \`from\`, \`date_from\`, …) move onto the endpoint's own name for the same thing; a sort word lands on its synonym (\`newest\` → \`latest\`), and an over-large limit is clamped. Each rename is a line in \`data._warnings\`. A name with no counterpart on the endpoint is still dropped (and named in \`_warnings\` with the closest declared name).
|
|
@@ -315,9 +333,9 @@ For a handful it is **collect-until-N**: the endpoint walks upstream pages itsel
|
|
|
315
333
|
|
|
316
334
|
Server-side composites marked *paginatable* (e.g. \`prism/comments\`) walk every page in one call and fold the results together. One call, one metered charge covering the whole walk — do not page these yourself.
|
|
317
335
|
|
|
318
|
-
## Walk several pages in one call: \`max_pages\`
|
|
336
|
+
## Walk several pages in one call: \`max_pages\`, \`max_items\`, \`max_credits\`
|
|
319
337
|
|
|
320
|
-
Where an endpoint declares
|
|
338
|
+
Where an endpoint declares them (about 200 lists do), one call walks pages and returns the rows from all of them, after any row filter: \`max_pages\` (1-50) walks up to that many pages, \`max_items\` (1-5000) walks until the response holds at least that many rows, and \`max_credits\` (1-100000) caps what the call may spend across every page (sent alone it walks as far as the budget goes, up to 50 pages). Each page walked is billed exactly as one call (a cached page is free). \`data.walk.stopped\` says why the walk ended (\`end\`, \`max_pages\`, \`max_items\`, \`max_credits\`, \`time_budget\`, \`page_error\`) and \`pagination.next_cursor\` continues from there — send it with the same params to resume a walk that stopped on \`time_budget\`. The row filters \`min_views\`, \`max_age_days\` and \`sort_rows=views\` run on our side across every page walked; \`data.walk.discarded\` counts what they removed.
|
|
321
339
|
|
|
322
340
|
## Incremental polling: \`since\` and \`stop_at_id\`
|
|
323
341
|
|
|
@@ -327,6 +345,14 @@ On the profile feeds that declare them (Instagram posts/reels, TikTok videos, Yo
|
|
|
327
345
|
|
|
328
346
|
\`seen=<your id>\` (1-64 letters, digits, \`.\`, \`_\`, \`-\`) drops rows this account already received under the same id in the last 24 hours, and the page price falls with the share of repeats — a page of nothing but repeats is free. Use one id across a set of related searches; \`data.walk.repeats\` counts what was removed.
|
|
329
347
|
|
|
348
|
+
## When a search runs out
|
|
349
|
+
|
|
350
|
+
A narrow or date-bounded search can reach a later page the source answers empty. The first time, that page is a refunded, retryable 503 — "retry the same cursor". Retry the same cursor later: on \`tiktok/search\` the same cursor answering empty again ends the walk; on \`facebook/search/posts\` it ends only when the cursor answers empty again at least 10 minutes after its first empty answer (a stalled page often recovers within a minute). The end is served as 200, \`items: []\`, \`has_more: false\`, 0 credits. Do not loop on the same cursor more often than that.
|
|
351
|
+
|
|
352
|
+
## Cursors that expire or belong to one sort
|
|
353
|
+
|
|
354
|
+
An expired or foreign cursor is a 400 \`INVALID_REQUEST\` that says to start again from the first page (\`twitter/tweet/replies\`: refunded; \`facebook/adlibrary/company/ads\`: free). A cursor minted under one sort keeps that sort: \`yelp/business/reviews\` carries its \`sort\` inside \`next_cursor\`, and \`instagram/profile/reels\` with \`sort=most_viewed\` continues only on the source that minted it — any other combination is a free 400. Cursors on \`g2/reviews\` and \`twitter/tweet/replies\` are portable across sources.
|
|
355
|
+
|
|
330
356
|
## Billing while paging
|
|
331
357
|
|
|
332
358
|
Each page of an ordinary list endpoint is a separate billed request. A repeat of the same page inside the cache TTL is free. An empty page is refunded.`,
|
|
@@ -429,6 +455,12 @@ One join key worth memorising: the stable cross-endpoint YouTube creator key is
|
|
|
429
455
|
|
|
430
456
|
Where the inputs are present, responses add a \`computed\` block: \`engagement_rate\`, \`language\`, \`content_category\`, \`estimated_reach\`. Unknown values are \`null\`, never zero.
|
|
431
457
|
|
|
458
|
+
Every comment item (on \`reddit/post/comments\`, \`youtube/video/comments\`, \`facebook/post/comments\` and every other comment lane) also carries \`computed.country\` — \`{ value, source, confidence }\` or null — beside \`computed.language\`. \`computed.engagement_rate\` is null on a repost row (\`twitter/user/tweets\`, with one \`_warnings\` line) and on GitHub accounts and repositories.
|
|
459
|
+
|
|
460
|
+
## Empty and closed lists
|
|
461
|
+
|
|
462
|
+
An empty list says why: \`empty_reason\` (for example \`no_matches\`) and \`empty_reason_note\`. On a search the note suggests changing the query or the filters; on a list read by link, handle or id it does not. A post whose comment section is closed answers a free 200 with no rows and \`comments_disabled: true\` (\`youtube/video/comments\`, \`telegram/post/comments\`; \`youtube/video\` carries \`post.ext.comments_disabled\`). An empty Google search and a text filter that matches nothing are a free 200 \`no_matches\`, not a 404.
|
|
463
|
+
|
|
432
464
|
## Response headers
|
|
433
465
|
|
|
434
466
|
| Header | Value |
|
|
@@ -740,6 +772,10 @@ For 51 to 5,000 items:
|
|
|
740
772
|
|
|
741
773
|
**Billing.** The job runs in chunks of 50 (25 with posts), each exactly as a call to the batch endpoint. When the last chunk settles, the charge is the sum of the rows that succeeded and the rest of the hold is refunded; a job where every row failed is \`failed\` and charged nothing. A 402 at submit creates nothing. The same \`Idempotency-Key\` with the same body replays the job at 0 credits; with a different body it is a 422.
|
|
742
774
|
|
|
775
|
+
**A GET endpoint as the job.** \`endpoint\` can also be the path of any GET endpoint (for example \`youtube/channel/about\`), with up to 1,000 \`items\`, each an object of that endpoint's query params (\`{ "handle": "@mkbhd" }\`). Each item runs as the direct call would — served, cached and billed per call, three side by side — so the job itself holds nothing; \`credits_max\` is the most the job can settle at, an item that walks counted at its walk ceiling (\`max_pages\` pages at their most, capped by \`max_credits\`). A streaming-only or non-GET endpoint is refused free.
|
|
776
|
+
|
|
777
|
+
**Long walks finish inside a job.** An item that sends \`max_pages\`, \`max_items\` or \`max_credits\` and stops on \`time_budget\` resumes from its own \`pagination.next_cursor\` with what is left of those limits (50 pages when only a target is sent), up to 5 times inside the job's 260 s ceiling, and answers one merged walk: rows once (repeats counted under \`data.walk.duplicates\`), pages, credits and \`request_ids\` summed, the last cursor, and \`data.walk.resumes\` (the extra calls). A failed page is asked again up to twice; a resume that still fails keeps the rows and ends \`page_error\` with \`walk_incomplete\`, and one refused under \`max_credits\` ends \`max_credits\`. Every page is billed as a direct call.
|
|
778
|
+
|
|
743
779
|
**Webhook.** One \`batch.completed\` event (never the rows) signed \`x-socialcrawl-signature: t=<unix>,v1=<hmac>\` with the per-job secret, to a public https URL.
|
|
744
780
|
|
|
745
781
|
In this server: \`socialcrawl_request\` with platform \`prism\`, resource \`jobs\` and the job in \`body\` to submit; resource \`jobs/{job_id}\` with \`params: { job_id }\` (or resource \`jobs/<id>\`) to poll; resource \`jobs\` with no body to list.
|
|
@@ -766,11 +802,14 @@ Monitors are **not** registry endpoints — they live at \`/v1/monitors/*\` and
|
|
|
766
802
|
| \`get\` | \`GET /v1/monitors/:id\` | A single monitor (404 if not owned — never leaks existence or the secret). |
|
|
767
803
|
| \`runs\` | \`GET /v1/monitors/:id/runs\` | Reverse-chron run history, each with its \`legs[]\` + \`alerts_fired\` + \`skip_reason\`. \`include=result\` adds the stored result (legacy monitors), \`include=numbers\` a track run's numbers and deltas, \`include=result,numbers\` both. |
|
|
768
804
|
| \`timeseries\` | \`GET /v1/monitors/:id/timeseries\` | The headline read — each stored run's metrics as a \`{ t, metrics }\` series (reads snapshots, no live API calls). Track monitors add a per-row \`series\`; \`row\` (comma-separated row ids) narrows it. |
|
|
769
|
-
| \`export\` | \`GET /v1/monitors/:id/export\` | A monitor's stored numbers as \`format\` = \`csv\` (default) or \`ndjson\`, optional \`from\`/\`to\`. Free; reads at most the newest 1,000 runs in the window. |
|
|
770
|
-
| \`pause\` / \`resume\` | \`PATCH /v1/monitors/:id\` | Pause or resume scheduling. A paused monitor is not run, billed, or counted against the cap. |
|
|
805
|
+
| \`export\` | \`GET /v1/monitors/:id/export\` | A monitor's stored numbers as \`format\` = \`csv\` (default) or \`ndjson\`, optional \`from\`/\`to\`. \`shape\` = \`long\` (default: one line per run, row and metric, \`t,row_id,metric,value,abs_change,pct_change\`) or \`shape=rows\` (one line per run and row with a column per metric, \`run_at_utc\` as \`DD/MM/YYYY HH:mm\`; CSV text cells starting \`=\`, \`+\`, \`-\` or \`@\` get a leading apostrophe). Free; reads at most the newest 1,000 runs in the window. |
|
|
806
|
+
| \`pause\` / \`resume\` | \`PATCH /v1/monitors/:id\` | Pause or resume scheduling. A paused monitor is not run, billed, or counted against the cap. Either can carry \`max_credits_per_month\` and \`email_digest\` in the same PATCH. Resuming a monitor paused by its monthly cap needs no free plan slot. |
|
|
807
|
+
| \`update\` | \`PATCH /v1/monitors/:id\` | Change \`max_credits_per_month\` (\`null\` removes the cap) and/or \`email_digest\` without touching the status. |
|
|
771
808
|
| \`delete\` | \`DELETE /v1/monitors/:id\` | Unschedule + cascade-delete runs and the webhook. |
|
|
772
809
|
|
|
773
|
-
\`dry_run: true\` on \`create\` sends \`?dry_run=1\`: the API runs the real call's checks (including the plan cap) and answers \`{ valid, normalized_body, estimate }\` without writing, scheduling or charging anything. Its \`estimate\` carries \`recipe_cost_per_run\`, \`scheduling_premium\`, \`estimated_cost_per_run\`, \`runs_per_month
|
|
810
|
+
\`dry_run: true\` on \`create\` sends \`?dry_run=1\`: the API runs the real call's checks (including the plan cap) and answers \`{ valid, normalized_body, estimate }\` without writing, scheduling or charging anything. Its \`estimate\` carries \`recipe_cost_per_run\`, \`scheduling_premium\`, \`estimated_cost_per_run\`, \`runs_per_month\` (730 hourly, 30 daily, 4 weekly), \`estimated_monthly_cost\`, \`monthly_cap\` and \`runs_until_cap\` (null without a cap), \`legs_billed_separately\` and \`next_run_at\`. A dry run always answers 200 with the quote; when the real create would be refused at the plan's monitor or list-subject limit it adds \`data.would_be_refused\` (\`type\` MONITOR_LIMIT_REACHED, \`message\`, \`slots\` with \`used\`, \`adding\`, \`limit\`, \`plan\`).
|
|
811
|
+
|
|
812
|
+
**Reading a monitor.** \`list\` and \`get\` carry \`max_credits_per_month\`, \`email_digest\`, \`legs_billed_separately\` and \`paused_because\` — \`monthly_cap\`, \`consecutive_skips\`, \`webhook_failing\`, or null when active or paused by you. The create answer is \`{ monitor, webhook_secret }\` (not the usual envelope); on a recipe whose sources bill themselves its \`warnings\` say those sources are billed on top of the quote. An hourly monitor runs at its own minute of the hour, fixed at create (the quote's \`next_run_at\` shows the top of the hour).
|
|
774
813
|
|
|
775
814
|
## Create parameters
|
|
776
815
|
|
|
@@ -783,6 +822,8 @@ Monitors are **not** registry endpoints — they live at \`/v1/monitors/*\` and
|
|
|
783
822
|
- \`webhook_format\` — \`full\` (default: the run's payload, plus \`numbers\`/\`deltas\` on a track monitor) or \`rows\` (one flat, spreadsheet-ready line per row and metric; needs \`track\`). Needs \`webhook_url\`.
|
|
784
823
|
- \`webhook_rows\` — \`all\` (default) or \`new\`: only the rows new since the previous run. Needs \`track\` with an \`items[].\` metric and a \`webhook_url\`; the first run is a \`baseline: true\` run with no rows.
|
|
785
824
|
- \`suppress_webhook_unless_alert\` — only deliver the webhook when a rule trips.
|
|
825
|
+
- \`max_credits_per_month\` — the most the monitor may bill in a calendar month (UTC), whole credits 1 to 10,000,000. The run that would pass it is skipped unbilled and the monitor pauses with \`paused_because: "monthly_cap"\` until the 1st. A free 400 below one run's price (recipe cost + 1) and on recipes whose sources bill themselves (\`search/multi\`, \`tiktokshop/sales\`, the tag searches).
|
|
826
|
+
- \`email_digest\` — \`daily\` or \`off\` (default). With it on the monitor has a second destination, so it keeps running when its webhook stops.
|
|
786
827
|
- \`name\`, \`output_schema\`, \`webhook_secret\` (8-200 chars) — optional.
|
|
787
828
|
|
|
788
829
|
## Track monitors (numbers only)
|
package/dist/data/docs.js
CHANGED
|
@@ -213,6 +213,8 @@ function buildPricingDoc() {
|
|
|
213
213
|
"",
|
|
214
214
|
"Cache hits, idempotent replays, empty results (404 RESOURCE_NOT_FOUND or 200 `{items:[]}`), upstream errors (502), circuit-breaker rejections (503), internal errors (500), deadline 504s, and `GET /v1/credits/{balance,transactions}` all cost 0 credits — see the `credits` topic.",
|
|
215
215
|
"",
|
|
216
|
+
"**Reading a live quote (`GET /v1/utility/estimate`, behind `socialcrawl_estimate`).** `hold` is the most the request can bill — every page of a walk, legs that bill themselves, a run's `max_credits` — so gate on it. `upfront_hold` is what is deducted when the call starts (one page of a walk; equal to `hold` on a plain call), and `quote_basis` is one sentence saying why the two differ. Before 21/11/2026 `hold` meant the up-front deduction. `utility/find` rows add `credits_ceiling` (the most one call costs once its price-moving params are set) and `ceiling_params` (which ones).",
|
|
217
|
+
"",
|
|
216
218
|
`## Free endpoints (${free.length})`,
|
|
217
219
|
"",
|
|
218
220
|
free.map((e) => `\`${e.method === "GET" ? "" : `${e.method} `}/v1/${e.platform}/${e.resource}\``).join(" · "),
|