diff --git a/ai-agents.mdx b/ai-agents.mdx index 82b18d6..0c93a94 100644 --- a/ai-agents.mdx +++ b/ai-agents.mdx @@ -53,7 +53,7 @@ A trial key comes with these limits: |---|---| | Credits | 50 | | Expires | 7 days | -| Rate | 10 requests/min, one call at a time | +| Concurrency | One call at a time | | APIs | Read APIs only: no Web Scraping API, ChatGPT, Perplexity, Gemini, Copilot or stream monitors | | Network | Works only from the IP that minted it; not through the hosted MCP server | | Availability | One per IP per day; not available from proxy, VPN or Tor networks | @@ -152,3 +152,7 @@ A result too large for the context window comes back as a preview. To get the re ## Out of credits A `402` response body includes `upgrade_url`, `free_credits_url` and `pricing_url`. For a trial key, it includes `claim_url` instead. + +## Too many calls at once + +Your account has a [max concurrency](/concurrency): how many calls it can run at the same time, across all of its keys. Free calls such as `quote_call` and `get_account_info` count too. A call over it gets `429` with `"error": "concurrency_limit_exceeded"`, `max_concurrency` and `concurrent_requests`. It isn't run or billed. Wait `Retry-After` (1 s) and send it again, and run fewer calls in parallel. `get_account_info` returns `max_concurrency` and `concurrent_requests`. diff --git a/api-reference/endpoint/account/get-account-info.mdx b/api-reference/endpoint/account/get-account-info.mdx index fef40a9..8cb506d 100644 --- a/api-reference/endpoint/account/get-account-info.mdx +++ b/api-reference/endpoint/account/get-account-info.mdx @@ -3,5 +3,5 @@ openapi: get /v1/account/me --- - This endpoint is useful for monitoring your credit balance programmatically — e.g., before running a batch job or in a CI pipeline. It returns both PAYG and subscription credit balances, plus full subscription details if you're on a plan. **No credits are deducted.** + This endpoint is useful for monitoring your credit balance programmatically — e.g., before running a batch job or in a CI pipeline. It returns both PAYG and subscription credit balances, plus full subscription details if you're on a plan, and your account's [max concurrency](/concurrency) with how many requests are running now. **No credits are deducted.** diff --git a/api-reference/endpoint/ebay/completed.mdx b/api-reference/endpoint/ebay/completed.mdx index fdbba5b..0195331 100644 --- a/api-reference/endpoint/ebay/completed.mdx +++ b/api-reference/endpoint/ebay/completed.mdx @@ -237,9 +237,10 @@ Things to know before you rely on the count: return a few listings the first missed. Merge walks on `item_id`. - **The sold history is eBay's.** It covers roughly the last 90 days. -A walk of N pages costs 8 × N credits. Your API key's per-minute limit counts -every `/v1` call, so space a long walk out; a `429` carries a `Retry-After` -header with the seconds to wait. +A walk of N pages costs 8 × N credits. Each page is one `/v1` call and holds +one of your account's [concurrent requests](/concurrency) while it runs, so +fetch a long walk's pages a few at a time. A `429` means all of them are in +use; retry after its `Retry-After` header (1 s). Each completed/sold request costs **8 credits**. Failed requests are not charged. diff --git a/api-reference/endpoint/perplexity/ask.mdx b/api-reference/endpoint/perplexity/ask.mdx index b8465fc..9b92734 100644 --- a/api-reference/endpoint/perplexity/ask.mdx +++ b/api-reference/endpoint/perplexity/ask.mdx @@ -404,8 +404,10 @@ async function submit(jobId: string, prompt: string, attempt = 1): Promise ### Receive diff --git a/api-reference/endpoint/web-scraping/detect.mdx b/api-reference/endpoint/web-scraping/detect.mdx index ffe2682..11fd926 100644 --- a/api-reference/endpoint/web-scraping/detect.mdx +++ b/api-reference/endpoint/web-scraping/detect.mdx @@ -149,7 +149,7 @@ console.log(detection.antibot_systems); |--------|-------------| | `400` | Invalid URL | | `402` | Insufficient credits | -| `429` | Rate limit exceeded | +| `429` | Your account is at its [max concurrency](/concurrency) (`concurrency_limit_exceeded`, not billed) | | `500` | Unexpected server error | diff --git a/api-reference/endpoint/web-scraping/extract.mdx b/api-reference/endpoint/web-scraping/extract.mdx index a02b40d..654e070 100644 --- a/api-reference/endpoint/web-scraping/extract.mdx +++ b/api-reference/endpoint/web-scraping/extract.mdx @@ -157,7 +157,7 @@ console.log((await res.json()).ai_extraction); |--------|-------------| | `402` | Insufficient credits | | `422` | Invalid request or selector, or the target blocked the request (not billed) | -| `429` | Rate limit exceeded | +| `429` | Your account is at its [max concurrency](/concurrency) (`concurrency_limit_exceeded`, not billed) | | `502` | The page could not be fetched, or AI-only extraction returned nothing (not billed) | diff --git a/api-reference/endpoint/web-scraping/scrape.mdx b/api-reference/endpoint/web-scraping/scrape.mdx index d94437d..f0f8709 100644 --- a/api-reference/endpoint/web-scraping/scrape.mdx +++ b/api-reference/endpoint/web-scraping/scrape.mdx @@ -424,7 +424,7 @@ curl "https://scrapebadger.com/v1/web/unblock/d1b44a702e16a753" \ | `kept` | The host already had a configuration; it was re-checked and nothing better was found | Send your request again: the existing configuration does not get through every time | | `failed` | Nothing got through | The host goes on `cooldown`; contact support if you need it | -The poll is free and is not rate limited. It answers `404` for a few seconds +The poll is free and doesn't count toward your [max concurrency](/concurrency). It answers `404` for a few seconds after the `422`, until the search has started: keep polling. ## Response @@ -856,7 +856,7 @@ Infinite scroll: | `400` | Invalid URL (including a hostname confirmed not to exist), cost exceeds `max_cost`, or requested engine not available. Never charged. | | `402` | Insufficient credits | | `422` | Blocking detected after all retries exhausted (`error: "blocking_page_detected"`, with `block_kind`, `vendor`, `vendors`, `unblock` (plus `unblock_job_id` while a search is running) and, for a CAPTCHA wall, the gating `captcha` at the top level; the scrape result is in `data`). `vendors` lists every protection vendor seen on the page, the block's own first: a site can put two in front of one page, such as a Cloudflare challenge before PerimeterX. A request that runs out of time while retrying (about 165 s) returns this 422 rather than a gateway timeout; the `wait_for` selector never appeared (`error: "wait_for_timeout"`); a `js_scenario` step failed (`error: "js_scenario_failed"`); or the body contained an unknown field (`error: "unknown_request_field"`). Never charged. | -| `429` | Rate limit exceeded | +| `429` | Your account is at its [max concurrency](/concurrency) (`concurrency_limit_exceeded`). Never charged. | | `500` | Unexpected server error | ### Hostname does not exist diff --git a/api-reference/endpoint/web-scraping/screenshot.mdx b/api-reference/endpoint/web-scraping/screenshot.mdx index 454a1dc..0a1bfb2 100644 --- a/api-reference/endpoint/web-scraping/screenshot.mdx +++ b/api-reference/endpoint/web-scraping/screenshot.mdx @@ -117,7 +117,7 @@ await writeFile("page.png", Buffer.from(screenshot, "base64")); |--------|-------------| | `402` | Insufficient credits | | `422` | Invalid request, or the target blocked the request (not billed) | -| `429` | Rate limit exceeded, or the browser farm is at capacity (not billed) | +| `429` | Your account is at its [max concurrency](/concurrency) (`concurrency_limit_exceeded`), or the browser farm is at capacity (not billed) | | `502` | The page loaded but no screenshot was captured (not billed) | diff --git a/cli/commands.mdx b/cli/commands.mdx index 45eca38..49e2532 100644 --- a/cli/commands.mdx +++ b/cli/commands.mdx @@ -11,7 +11,7 @@ scrapebadger auth # Interactive prompt scrapebadger auth --show # Show saved key ``` -### `scrapebadger credits` Check your credit balance. ### `scrapebadger logout` Remove saved API key from config. --- +### `scrapebadger credits` Check your credit balance and max concurrency. ### `scrapebadger logout` Remove saved API key from config. --- ## Twitter Commands All Twitter commands are under `scrapebadger twitter`. ### Users diff --git a/concurrency.mdx b/concurrency.mdx new file mode 100644 index 0000000..4aef0fe --- /dev/null +++ b/concurrency.mdx @@ -0,0 +1,348 @@ +--- +title: Concurrency +description: How many requests your account can run at the same time, what counts toward that limit, and how to handle a 429 when you reach it. +--- + +Every ScrapeBadger account has a **max concurrency**: how many requests it can have in flight at the same time. There is no per-minute or per-day request limit. When a request finishes, its slot is free for the next one at once. + +## How it works + + + + Every API key of your account shares it, and so do your team members' keys. A team's keys use the team owner's account. + + + A request takes a slot when it starts and frees it when it finishes. Fast calls get through many times per second. + + + A request over the limit gets `429` straight away. It doesn't run, isn't billed and isn't queued. Retry it after 1 second. + + + +How many calls you can finish per second is your max concurrency divided by how long each call takes. With a max concurrency of 25 and calls that take 2 s each, you complete about 12 calls per second, or about 750 per minute. AI asks take 15–40 s each, so the same 25 slots complete fewer of them. + +## Max concurrency by plan + +| Plan | Max concurrency | +|------|-----------------| +| Free (sign-up credits, nothing bought yet) | 1 | +| Pay-as-you-go | 5 | +| Starter | 5 | +| Growth | 25 | +| Pro | 50 | +| Scale | 150 | +| Volume | 300 | +| Max | 800 | +| Custom and enterprise plans | Custom | + + + These are the starting values. The current value of each plan is on the [pricing page](https://scrapebadger.com/pricing). Your own account's value is `max_concurrency` in [`GET /v1/account/me`](#check-your-account) and the `X-Concurrency-Limit` header. + + +- Your first credit purchase moves a Free account to the Pay-as-you-go value. +- A subscription sets the plan's value. If you cancel it, the account goes back to the Pay-as-you-go value when the subscription ends. +- A change applies to your next request. + +## What counts + +A request holds one slot for as long as it runs, whether it succeeds or fails. + +| Counts | Doesn't count | +|--------|---------------| +| Every `/v1` call while it runs, including free ones: `/v1/account/me`, `/v1/quote` and the Twitter stream management routes | Polling an async call: `GET /v1/requests/{request_id}` | +| An [async call](/long-running-requests) (`Prefer: respond-async`, `async=true` or a callback URL), from the submit until the call finishes, not just until the `202` | Polling a web unblock search: `GET /v1/web/unblock/{job_id}` | +| Each item of a [batch](/long-running-requests#submit-a-batch), from when it is accepted until it finishes | The `POST /v1/batch` submit itself (only its items count) | +| Calls your AI agent makes through the [MCP server](/mcp/overview) with your key | The live [Twitter stream WebSocket](/twitter-streams/websocket) connection | + +Unclaimed agent [trial keys](/ai-agents#trial-keys-no-account) don't use an account's max concurrency. They run one call at a time: a second call while the first is still running gets `429` with `"error": "trial_concurrency"`. + +## Response headers + +Every response to a request that counts carries these headers: + +| Header | Description | Example | +|--------|-------------|---------| +| `X-Concurrency-Limit` | Your account's max concurrency | `25` | +| `X-Concurrency-Remaining` | How many more requests you can start right now, with this one running | `24` | +| `Retry-After` | On a `429` only: seconds to wait before you retry. Always `1`. | `1` | + +## Over the limit: 429 + +When all of your account's slots are in use, the next request is refused at once with `429 Too Many Requests`. It doesn't run and isn't billed. Nothing is queued on our side, so retry it yourself as soon as one of your running requests finishes. + +```json 429 concurrency_limit_exceeded +{ + "error": "concurrency_limit_exceeded", + "detail": "Too many concurrent requests: this account allows 5 at a time and 5 are already running. Retry as soon as one finishes, or upgrade your plan for more: https://scrapebadger.com/pricing", + "max_concurrency": 5, + "concurrent_requests": 5 +} +``` + +The response also carries `Retry-After: 1`, `X-Concurrency-Limit: 5` and `X-Concurrency-Remaining: 0`. + +| Field | Description | +|-------|-------------| +| `error` | Always `concurrency_limit_exceeded` for this response | +| `detail` | A human-readable explanation | +| `max_concurrency` | Your account's max concurrency | +| `concurrent_requests` | How many of your requests were running when this one arrived | + + + Other `429` responses use a different `error`, for example `trial_concurrency` on a trial key or a target site's own limit. Check `error` before you treat a `429` as your max concurrency. + + +## Check your account + +`GET /v1/account/me` is free. It returns your max concurrency and how many of your requests are running right now, not counting this call: + +```bash +curl -s https://scrapebadger.com/v1/account/me \ + -H "x-api-key: $SCRAPEBADGER_API_KEY" +``` + +```json +{ + "credits_balance": 99171, + "subscription_credits_balance": 0, + "total_credits_balance": 99171, + "max_concurrency": 5, + "concurrent_requests": 2, + "subscription": null +} +``` + +The call itself counts while it runs. Read `max_concurrency` once when your program starts, and limit parallel calls on your side. Don't poll this endpoint to decide when to send the next request. + +## Stay under the limit + +Run at most `max_concurrency` requests at a time on your side, and retry a `429` after `Retry-After`. If several workers or servers share one account, split the number between them: they all draw on the same slots. + + + +```python Python (asyncio) +import asyncio +import os + +import httpx + +BASE = "https://scrapebadger.com" +HEADERS = {"x-api-key": os.environ["SCRAPEBADGER_API_KEY"]} + + +async def call(client: httpx.AsyncClient, slots: asyncio.Semaphore, path: str, params: dict) -> dict: + async with slots: # at most max_concurrency calls in flight + while True: + response = await client.get(BASE + path, params=params) + if response.status_code == 429 and response.json().get("error") == "concurrency_limit_exceeded": + await asyncio.sleep(float(response.headers.get("Retry-After", "1"))) + continue + response.raise_for_status() + return response.json() + + +async def main(queries: list[str]) -> list[dict]: + async with httpx.AsyncClient(headers=HEADERS, timeout=130) as client: + me = (await client.get(BASE + "/v1/account/me")).json() + slots = asyncio.Semaphore(me["max_concurrency"]) + return await asyncio.gather( + *(call(client, slots, "/v1/google/search", {"q": q}) for q in queries) + ) + + +results = asyncio.run(main(["web scraping api", "serp api", "proxy api"])) +``` + +```javascript JavaScript (promise pool) +const BASE = "https://scrapebadger.com"; +const headers = { "x-api-key": process.env.SCRAPEBADGER_API_KEY }; +const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)); + +async function call(path) { + for (;;) { + const response = await fetch(BASE + path, { headers }); + if (response.status === 429) { + const body = await response.json(); + if (body.error !== "concurrency_limit_exceeded") throw new Error(body.detail); + await sleep(Number(response.headers.get("Retry-After") ?? 1) * 1000); + continue; + } + if (!response.ok) throw new Error(`HTTP ${response.status}`); + return response.json(); + } +} + +// Run fn over items with at most `limit` calls in flight. +async function pool(items, limit, fn) { + const results = new Array(items.length); + let next = 0; + const worker = async () => { + while (next < items.length) { + const i = next++; + results[i] = await fn(items[i]); + } + }; + await Promise.all(Array.from({ length: Math.min(limit, items.length) }, worker)); + return results; +} + +const me = await (await fetch(`${BASE}/v1/account/me`, { headers })).json(); +const queries = ["web scraping api", "serp api", "proxy api"]; +const results = await pool(queries, me.max_concurrency, (q) => + call(`/v1/google/search?q=${encodeURIComponent(q)}`), +); +``` + +```javascript JavaScript (p-limit) +import pLimit from "p-limit"; + +// BASE, headers and call() as in the promise pool example +const me = await (await fetch(`${BASE}/v1/account/me`, { headers })).json(); +const limit = pLimit(me.max_concurrency); + +const queries = ["web scraping api", "serp api", "proxy api"]; +const results = await Promise.all( + queries.map((q) => limit(() => call(`/v1/google/search?q=${encodeURIComponent(q)}`))), +); +``` + + + +### With the SDKs + +From version 0.84.0, the Python and Node SDKs raise `RateLimitError` for a `429`. It carries your max concurrency, how many requests were running and how many seconds to wait. Both SDKs first retry the call themselves, waiting at least `Retry-After`, and raise `RateLimitError` only when their retries run out (`max_retries` / `maxRetries`, 10 by default). + +| Python | Node | Description | +|--------|------|-------------| +| `max_concurrency` | `maxConcurrency` | Your account's max concurrency | +| `concurrent_requests` | `concurrentRequests` | How many of your requests were running when this one arrived | +| `retry_after` | `retryAfter` | Seconds to wait before you retry, from `Retry-After` | + + + +```python Python SDK +import asyncio + +from scrapebadger import RateLimitError, ScrapeBadger + + +async def search(client: ScrapeBadger, slots: asyncio.Semaphore, query: str): + async with slots: + try: + return await client.google.search.search(query) # retries a 429 itself + except RateLimitError as e: + # Raised once the SDK's own retries run out + print(f"{e.concurrent_requests}/{e.max_concurrency} running, retry in {e.retry_after}s") + raise + + +async def main(queries: list[str]): + async with ScrapeBadger(api_key="YOUR_API_KEY") as client: + me = await client.account.get_account_info() + slots = asyncio.Semaphore(me["max_concurrency"]) + return await asyncio.gather(*(search(client, slots, q) for q in queries)) + + +results = asyncio.run(main(["web scraping api", "serp api", "proxy api"])) +``` + +```typescript Node SDK +import pLimit from "p-limit"; +import { RateLimitError, ScrapeBadger } from "scrapebadger"; + +const client = new ScrapeBadger({ apiKey: process.env.SCRAPEBADGER_API_KEY }); +const me = await client.account.getAccountInfo(); +const limit = pLimit(Number(me.max_concurrency)); + +async function search(q: string) { + try { + return await client.google.search.search({ q }); // retries a 429 itself + } catch (error) { + if (error instanceof RateLimitError) { + // Thrown once the SDK's own retries run out + console.log(`${error.concurrentRequests}/${error.maxConcurrency} running, retry in ${error.retryAfter}s`); + } + throw error; + } +} + +const queries = ["web scraping api", "serp api", "proxy api"]; +const results = await Promise.all(queries.map((q) => limit(() => search(q)))); +``` + + + +## Async calls and batches + +- **An async call keeps its slot until it finishes.** The `202` comes back at once, but the call still runs. If your max concurrency is 25 and 25 async calls are still running, the next submit gets `429`. +- **Polling is free and doesn't count.** Poll `GET /v1/requests/{request_id}` as often as its `retry_after_seconds` suggests, or use a callback URL. Webhook deliveries to your server don't count either. +- **Each batch item takes its own slot.** It holds the slot from when it is accepted until it finishes. Items over your max concurrency come back with `"accepted": false` and `"status": 429`. They aren't billed, and you can resubmit just those items once earlier ones finish. +- **Size batches to your free slots.** A batch of 100 items on an account with 25 free slots starts 25 and refuses 75. Check `X-Concurrency-Remaining` on a recent response, or `max_concurrency` minus `concurrent_requests` from `/v1/account/me`, before you submit. + +See [Async requests and webhooks](/long-running-requests) for the details of each. + +## Best practices + + + + Use a semaphore, a worker pool or `p-limit` sized to your max concurrency. Firing everything at once only turns the extra calls into `429`s. + + + A refused request wasn't run or billed, so it is safe to send again. Wait the `Retry-After` seconds (1) and retry. + + + AI asks and rendered pages take tens of seconds. Run them [asynchronously](/long-running-requests) so you don't hold a connection open for each one. They still count until they finish. + + + ScrapeBadger doesn't cache responses, so an identical repeat call is billed again and takes a slot again. Keep results on your side where appropriate. + + + + + Max concurrency is per account, so extra API keys don't add capacity. Opening several accounts to get around the limit may get them restricted. If you need more, upgrade your plan or contact sales. + + +## FAQ + + + + No. Your account has a max concurrency only. How many requests you can make per minute depends on how quickly your calls finish. + + + Per account. All of your API keys, and the keys of your team's members, share the same slots. One busy key can use every slot, so limit each application on your side if they must not block each other. + + + The request gets `429` with `"error": "concurrency_limit_exceeded"` and `Retry-After: 1`. It isn't run, queued or billed. Retry it as soon as one of your running requests finishes. + + + Every `/v1` call while it runs, including the free ones: `/v1/quote` (an agent's `quote_call`) and `/v1/account/me` (`get_account_info`) take a slot like a scrape. On the Free plan's one request at a time, an agent that quotes or checks its balance while another call runs gets a `429`, so make those calls one after another. Polling an async call (`/v1/requests/{request_id}`) doesn't count. See [What counts](#what-counts). + + + Yes, while they run. A request refused with `429` for being over the limit never takes a slot. + + + No. Max concurrency is one number for the whole account. To give an application a smaller share, limit it on your side. + + + No. An async call and each batch item hold a slot until the call finishes. Only polling for the result is free of the limit. + + + Upgrade your plan on the [pricing page](https://scrapebadger.com/pricing). For more than the largest plan includes, contact [sales@scrapebadger.com](mailto:sales@scrapebadger.com). + + + +## Changes on 2026-11-29 + +Max concurrency replaced the per-minute rate limits and their tiers (Free, Basic, Pro, Enterprise). If your code read the old fields, update it: + +| Before | Now | +|--------|-----| +| `X-RateLimit-Limit`, `X-RateLimit-Remaining`, `X-RateLimit-Reset` headers | `X-Concurrency-Limit`, `X-Concurrency-Remaining` | +| `X-Api-Tier` header | Removed | +| `tier`, `rate_limit_per_minute` in `/v1/account/me` | `max_concurrency`, `concurrent_requests` | +| `429` body with `detail: "Rate limit exceeded"`, `limit`, `remaining`, `reset_at`, `tier` | `429` body with `error: "concurrency_limit_exceeded"`, `detail`, `max_concurrency`, `concurrent_requests` | +| SDK `RateLimitError` with `limit`, `remaining`, `reset_at`, `tier` | SDK 0.84.0 `RateLimitError` with `max_concurrency`, `concurrent_requests`, `retry_after` in seconds (Node: `maxConcurrency`, `concurrentRequests`, `retryAfter`) | + +--- + +Need a higher max concurrency? Contact us at [sales@scrapebadger.com](mailto:sales@scrapebadger.com). diff --git a/credits-and-pricing.mdx b/credits-and-pricing.mdx index 3dba146..dc2e30a 100644 --- a/credits-and-pricing.mdx +++ b/credits-and-pricing.mdx @@ -1,6 +1,6 @@ --- title: Credits & Pricing -description: Understand the ScrapeBadger credit system, pricing tiers, and credit costs per endpoint. +description: Understand the ScrapeBadger credit system, plans, and credit costs per endpoint. --- ScrapeBadger uses a simple credit-based pricing model. Pay only for what you use with transparent, predictable costs. diff --git a/docs.json b/docs.json index 1406bd6..f6e0be4 100644 --- a/docs.json +++ b/docs.json @@ -57,7 +57,7 @@ "teams", "credits-and-pricing", "usage-logs", - "rate-limits", + "concurrency", "long-running-requests", "ai-agents" ] @@ -1993,6 +1993,11 @@ "source": "/api-reference/google/google-trends/trending-searches", "destination": "/api-reference/google/google-trends/trending", "permanent": true + }, + { + "source": "/rate-limits", + "destination": "/concurrency", + "permanent": true } ] } diff --git a/github/profiles.mdx b/github/profiles.mdx index 499bb66..a6049e1 100644 --- a/github/profiles.mdx +++ b/github/profiles.mdx @@ -41,7 +41,7 @@ Timestamp pairs use ISO `*_at` and Unix-seconds `*_utc`. Invalid tab/parameter combinations are rejected before source requests. Unknown handles return 404; invalid values return 400/422; authentication, scope, credit -and account rate-limit errors follow the standard API contract. Source failures, +and [concurrency](/concurrency) errors follow the standard API contract. Source failures, challenge pages or unexpected markup return 502/503 and are not billed. An empty list is a verified native empty state, never a substitute for a source failure. diff --git a/github/repositories.mdx b/github/repositories.mdx index 59f459e..5ac1892 100644 --- a/github/repositories.mdx +++ b/github/repositories.mdx @@ -67,7 +67,7 @@ README/commit read is an unbilled error, not an empty success. Invalid inputs return 400/422. Missing/deleted/private resources share GitHub's public 404 verdict without revealing private existence. Transient challenge, throttle or invalid source state returns an unbilled source error. Standard -authentication/scope/rate-limit errors also apply. Repository search, trending, +authentication/scope/[concurrency](/concurrency) errors also apply. Repository search, trending, private data and paginated child lists are separate from this operation. See the [endpoint reference](/api-reference/endpoint/github/get-repository) and diff --git a/index.mdx b/index.mdx index 58b7b95..8c3b995 100644 --- a/index.mdx +++ b/index.mdx @@ -35,7 +35,7 @@ curl -X GET "https://scrapebadger.com/v1/twitter/users/elonmusk/by_username" \ Tweets, users, lists, communities, trends, geo data, and Twitter Spaces. - Automatic proxy rotation, retry logic, and rate limit management handled for you. + Automatic proxy rotation, retries, and target-site rate limits handled for you. diff --git a/long-running-requests.mdx b/long-running-requests.mdx index 046279b..0bd5d03 100644 --- a/long-running-requests.mdx +++ b/long-running-requests.mdx @@ -208,7 +208,7 @@ Each delivery carries these headers: - On a timeout, a connection error, `408`, `425`, `429`, `500`, `502`, `503` or `504`, the delivery is retried after **10 s, 60 s and 300 s**: four attempts in total. Any other status is final. - Delivery is **at least once**. The same result can arrive more than once, for example when your server handled it but the response didn't reach us in time. Deduplicate on `request_id`. - Answer first and do the work after. A slow handler times out, and the result is sent again. -- Calls refused before they run (invalid key, no credits, rate limit) answer synchronously and send no webhook. +- Calls refused before they run (invalid key, no credits, over your [max concurrency](/concurrency)) answer synchronously and send no webhook. - Deliveries in progress don't survive a restart of our gateway. If a restart interrupts retries, the delivery is reported as `failed` with `last_error: "interrupted (gateway restart)"`. Fetch the result from `result_url` while it is still kept. ### Verify the signature @@ -527,13 +527,13 @@ curl -s https://scrapebadger.com/v1/batch \ ]} ``` -- Each item is an ordinary async request under your key. It has the same authentication, permissions, credit check, [rate limit](/rate-limits) and price as if you had sent it alone. Submitting the batch is free. +- Each item is an ordinary async request under your key. It has the same authentication, permissions, credit check, [max concurrency](/concurrency) and price as if you had sent it alone. Submitting the batch is free and doesn't count toward your max concurrency itself. - Items are checked against your balance before any of them start, at each endpoint's base price (what `POST /v1/quote` reports). Items whose price no longer fits, after the items before them and your other batch items still running, come back as `402 insufficient_credits` and are not started. -- An item that can't start (for example `402` as above, `429` over your rate limit, or `404` unknown endpoint) comes back with `"accepted": false`, its `status` and `error`. It is not billed, and you can resubmit just that item later. +- An item that can't start (for example `402` as above, `429` over your max concurrency, or `404` unknown endpoint) comes back with `"accepted": false`, its `status` and `error`. It is not billed, and you can resubmit just that item later. - Poll each `poll_url`, or pass `callback_url` to get one webhook per item, each with `batch_id` set. -- At most 10 items of one batch run at a time. The others wait their turn and show as `running` when polled. +- Every accepted item starts at once and holds one of your account's concurrent requests until it finishes. Your max concurrency is what limits how many items of a batch run together: items beyond your free slots are not accepted (see below). - A batch over 100 items gets `413 batch_too_large`. -- Items still waiting for a slot when our gateway restarts are dropped. They are not billed, and polling them returns `404 request_not_found` within about 5 minutes. Resubmit those. +- Items still waiting for their turn when our gateway restarts are dropped. They are not billed, and polling them returns `404 request_not_found` within about 5 minutes. Resubmit those. ## Trial keys @@ -541,4 +541,6 @@ Unclaimed trial keys can't batch (`403 trial_not_allowed`) or use webhooks (`tri ## Concurrency -There is no per-key concurrency limit beyond your plan's [rate limit](/rate-limits). AI asks render a live answer, so latency rises when many run at once. Start around 10 in parallel per engine and scale up while you watch the error rate. A `502` on an AI ask means the engine produced no usable answer on that attempt. It is not billed, and retrying it is safe. +Async calls and batch items count toward your account's [max concurrency](/concurrency) until they finish, not just until the `202`. A submit over the limit gets `429` with `"error": "concurrency_limit_exceeded"`; in a batch, that item comes back with `"accepted": false`. Neither is billed, so resubmit once earlier calls finish. Polling `GET /v1/requests/{request_id}` doesn't count. + +AI asks render a live answer, so latency rises when many run at once. Start around 10 in parallel per engine, within your max concurrency, and scale up while you watch the error rate. A `502` on an AI ask means the engine produced no usable answer on that attempt. It is not billed, and retrying it is safe. diff --git a/mcp/overview.mdx b/mcp/overview.mdx index d72393e..a7805ac 100644 --- a/mcp/overview.mdx +++ b/mcp/overview.mdx @@ -83,7 +83,7 @@ ScrapeBadger provides a hosted MCP (Model Context Protocol) server at `mcp.scrap | **AutoScout24** | 4 | Vehicle search, full listing specifications/equipment/photos, filters and eight European markets | | **Copilot** | 3 | Microsoft Copilot (Copilot Search in Bing) answers with citations + brand-visibility scoring, market list | | **Gemini** | 2 | Answers with cited web sources + brand-visibility scoring | -| **Account** | 1 | Credit balance, tier, and rate-limit info | +| **Account** | 1 | Credit balance, max concurrency and requests running now | ## Google Tools diff --git a/openapi-account.json b/openapi-account.json index 01e8366..dfbc86a 100644 --- a/openapi-account.json +++ b/openapi-account.json @@ -324,7 +324,7 @@ "additionalProperties": { "type": "string" }, - "description": "The call's kept response headers, lower-case (content-type, x-credits-used, x-request-duration-ms, x-api-tier)." + "description": "The call's kept response headers, lower-case (content-type, x-credits-used, x-request-duration-ms)." }, "result_url": { "type": "string" @@ -396,7 +396,7 @@ "get": { "operationId": "get-account-info", "summary": "Get Account Info", - "description": "Check your credit balances, subscription details, plan tier, and rate limits. No credits are deducted for this call.", + "description": "Check your credit balances, subscription details and max concurrency: how many requests your account can run at the same time, and how many are running now. No credits are deducted for this call. The call itself counts toward your max concurrency while it runs.", "tags": [ "Account" ], @@ -412,6 +412,13 @@ "application/json": { "schema": { "type": "object", + "required": [ + "credits_balance", + "subscription_credits_balance", + "total_credits_balance", + "max_concurrency", + "concurrent_requests" + ], "properties": { "credits_balance": { "type": "integer", @@ -425,19 +432,15 @@ "type": "integer", "description": "Sum of PAYG + subscription credits" }, - "tier": { - "type": "string", - "description": "Account tier (free, basic, pro, enterprise)", - "enum": [ - "free", - "basic", - "pro", - "enterprise" - ] + "max_concurrency": { + "type": "integer", + "minimum": 1, + "description": "Max concurrency: how many requests this account (all of its API keys, and its team members' keys) can have in flight at the same time. A request over it gets 429 concurrency_limit_exceeded." }, - "rate_limit_per_minute": { + "concurrent_requests": { "type": "integer", - "description": "Maximum API requests allowed per minute" + "minimum": 0, + "description": "How many of this account's requests are in flight right now, not counting this call." }, "subscription": { "type": "object", @@ -518,8 +521,8 @@ "credits_balance": 50000, "subscription_credits_balance": 250000, "total_credits_balance": 300000, - "tier": "pro", - "rate_limit_per_minute": 1000, + "max_concurrency": 25, + "concurrent_requests": 3, "subscription": { "plan_code": "growth", "plan_title": "Growth", @@ -542,8 +545,8 @@ "credits_balance": 99171, "subscription_credits_balance": 0, "total_credits_balance": 99171, - "tier": "pro", - "rate_limit_per_minute": 100, + "max_concurrency": 5, + "concurrent_requests": 0, "subscription": null } } diff --git a/openapi-github.json b/openapi-github.json index e4c03a6..789f547 100644 --- a/openapi-github.json +++ b/openapi-github.json @@ -216,7 +216,7 @@ } }, "429": { - "description": "Account request limit reached.", + "description": "Too many concurrent requests: the account is already running as many requests as its max concurrency allows (`concurrency_limit_exceeded`, `Retry-After: 1`). Not run and not billed; retry as soon as one finishes.", "content": { "application/json": { "schema": { diff --git a/openapi-twitter.json b/openapi-twitter.json index 6ee3088..e9b22f0 100644 --- a/openapi-twitter.json +++ b/openapi-twitter.json @@ -2,7 +2,7 @@ "openapi": "3.1.0", "info": { "title": "ScrapeBadger Twitter API", - "description": "The ScrapeBadger Twitter API provides programmatic access to Twitter/X data through a simple REST interface. Retrieve tweets, user profiles, followers, lists, communities, trends, and geographic data \u2014 all with a single API key.\n\nAll endpoints require authentication via the `x-api-key` header. Each request consumes credits from your account balance. Paginated endpoints return a `next_cursor` field that you can pass to subsequent requests to retrieve additional pages of results.\n\n**Base URL:** `https://scrapebadger.com/v1/twitter`\n\n**Rate Limits:** Requests are rate-limited per API key. If you exceed your limit, you will receive a `429` response. Implement exponential backoff and retry logic for production use.\n\n**Credits:** Each successful API call deducts credits from your balance. If your balance reaches zero, subsequent requests will return `402 Payment Required`.", + "description": "The ScrapeBadger Twitter API provides programmatic access to Twitter/X data through a simple REST interface. Retrieve tweets, user profiles, followers, lists, communities, trends, and geographic data \u2014 all with a single API key.\n\nAll endpoints require authentication via the `x-api-key` header. Each request consumes credits from your account balance. Paginated endpoints return a `next_cursor` field that you can pass to subsequent requests to retrieve additional pages of results.\n\n**Base URL:** `https://scrapebadger.com/v1/twitter`\n\n**Concurrency:** every account has a max concurrency: how many requests it can run at the same time, across all of its API keys. A request over the limit gets a `429` response (`concurrency_limit_exceeded`) with `Retry-After: 1`; retry as soon as one of your running requests finishes. Your account's value is on the pricing page and in `GET /v1/account/me` (`max_concurrency`, `concurrent_requests`), and every response carries `X-Concurrency-Limit` and `X-Concurrency-Remaining`.\n\n**Credits:** Each successful API call deducts credits from your balance. If your balance reaches zero, subsequent requests will return `402 Payment Required`.", "version": "1.0.0", "contact": { "name": "ScrapeBadger Support", @@ -106,7 +106,7 @@ "$ref": "#/components/responses/PaymentRequired" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -159,7 +159,7 @@ "$ref": "#/components/responses/PaymentRequired" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -212,7 +212,7 @@ "$ref": "#/components/responses/PaymentRequired" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -265,7 +265,7 @@ "$ref": "#/components/responses/PaymentRequired" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -318,7 +318,7 @@ "$ref": "#/components/responses/PaymentRequired" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -362,7 +362,7 @@ "$ref": "#/components/responses/PaymentRequired" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -442,7 +442,7 @@ "$ref": "#/components/responses/PaymentRequired" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -486,7 +486,7 @@ "$ref": "#/components/responses/PaymentRequired" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -530,7 +530,7 @@ "$ref": "#/components/responses/PaymentRequired" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -583,7 +583,7 @@ "$ref": "#/components/responses/PaymentRequired" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -627,7 +627,7 @@ "$ref": "#/components/responses/PaymentRequired" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -671,7 +671,7 @@ "$ref": "#/components/responses/PaymentRequired" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -715,7 +715,7 @@ "$ref": "#/components/responses/PaymentRequired" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -759,7 +759,7 @@ "$ref": "#/components/responses/PaymentRequired" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -803,7 +803,7 @@ "$ref": "#/components/responses/PaymentRequired" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -856,7 +856,7 @@ "$ref": "#/components/responses/PaymentRequired" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -909,7 +909,7 @@ "$ref": "#/components/responses/PaymentRequired" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -962,7 +962,7 @@ "$ref": "#/components/responses/PaymentRequired" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -1015,7 +1015,7 @@ "$ref": "#/components/responses/PaymentRequired" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -1068,7 +1068,7 @@ "$ref": "#/components/responses/PaymentRequired" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -1121,7 +1121,7 @@ "$ref": "#/components/responses/PaymentRequired" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -1174,7 +1174,7 @@ "$ref": "#/components/responses/PaymentRequired" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -1239,7 +1239,7 @@ "$ref": "#/components/responses/PaymentRequired" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -1292,7 +1292,7 @@ "$ref": "#/components/responses/PaymentRequired" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -1336,7 +1336,7 @@ "$ref": "#/components/responses/PaymentRequired" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -1389,7 +1389,7 @@ "$ref": "#/components/responses/PaymentRequired" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -1452,7 +1452,7 @@ "$ref": "#/components/responses/PaymentRequired" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -1496,7 +1496,7 @@ "$ref": "#/components/responses/PaymentRequired" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -1564,7 +1564,7 @@ "$ref": "#/components/responses/PaymentRequired" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -1617,7 +1617,7 @@ "$ref": "#/components/responses/PaymentRequired" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -1680,7 +1680,7 @@ "$ref": "#/components/responses/PaymentRequired" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -1724,7 +1724,7 @@ "$ref": "#/components/responses/PaymentRequired" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -1790,7 +1790,7 @@ "$ref": "#/components/responses/PaymentRequired" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -1834,7 +1834,7 @@ "$ref": "#/components/responses/PaymentRequired" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -1878,7 +1878,7 @@ "$ref": "#/components/responses/PaymentRequired" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -1922,7 +1922,7 @@ "$ref": "#/components/responses/PaymentRequired" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -2022,7 +2022,7 @@ "$ref": "#/components/responses/PaymentRequired" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -2110,7 +2110,7 @@ "$ref": "#/components/responses/PaymentRequired" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -2153,7 +2153,7 @@ "$ref": "#/components/responses/PaymentRequired" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -2260,7 +2260,7 @@ "$ref": "#/components/responses/PaymentRequired" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -2294,7 +2294,7 @@ "$ref": "#/components/responses/PaymentRequired" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -2359,7 +2359,7 @@ "$ref": "#/components/responses/PaymentRequired" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -2412,7 +2412,7 @@ "$ref": "#/components/responses/PaymentRequired" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -2448,7 +2448,7 @@ "$ref": "#/components/responses/PaymentRequired" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -2527,7 +2527,7 @@ "$ref": "#/components/responses/PaymentRequired" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -2592,7 +2592,7 @@ "$ref": "#/components/responses/Unauthorized" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -2678,7 +2678,7 @@ "$ref": "#/components/responses/PaymentRequired" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -2771,7 +2771,7 @@ "$ref": "#/components/responses/PaymentRequired" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -2859,7 +2859,7 @@ "$ref": "#/components/responses/PaymentRequired" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -2902,7 +2902,7 @@ "$ref": "#/components/responses/PaymentRequired" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -3002,7 +3002,7 @@ "$ref": "#/components/responses/PaymentRequired" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -3036,7 +3036,7 @@ "$ref": "#/components/responses/PaymentRequired" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -3106,7 +3106,7 @@ "$ref": "#/components/responses/PaymentRequired" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -3171,7 +3171,7 @@ "$ref": "#/components/responses/Unauthorized" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -3219,7 +3219,7 @@ "$ref": "#/components/responses/PaymentRequired" }, "429": { - "$ref": "#/components/responses/RateLimitExceeded" + "$ref": "#/components/responses/ConcurrencyLimitExceeded" } }, "x-availability": "active" @@ -5202,15 +5202,68 @@ } } }, - "RateLimitExceeded": { - "description": "Rate limit exceeded. Too many requests in a given time period. Implement exponential backoff and retry.", + "ConcurrencyLimitExceeded": { + "description": "Too many concurrent requests. Every request of this account (all of its API keys) that is still running holds one of its max concurrency slots, and all of them are in use. Retry as soon as one finishes (`Retry-After: 1`), or upgrade your plan for more: https://scrapebadger.com/pricing", + "headers": { + "Retry-After": { + "description": "Seconds to wait before retrying. Always 1.", + "schema": { + "type": "integer", + "example": 1 + } + }, + "X-Concurrency-Limit": { + "description": "The account's max concurrency.", + "schema": { + "type": "integer", + "example": 5 + } + }, + "X-Concurrency-Remaining": { + "description": "Free slots left. 0 on this response.", + "schema": { + "type": "integer", + "example": 0 + } + } + }, "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/ErrorResponse" + "type": "object", + "required": [ + "error", + "detail", + "max_concurrency", + "concurrent_requests" + ], + "properties": { + "error": { + "type": "string", + "enum": [ + "concurrency_limit_exceeded" + ], + "description": "Machine-readable error code." + }, + "detail": { + "type": "string", + "description": "Human-readable explanation." + }, + "max_concurrency": { + "type": "integer", + "description": "How many requests this account may run at the same time." + }, + "concurrent_requests": { + "type": "integer", + "description": "How many of its requests were running when this one arrived." + } + } }, "example": { - "error": "Rate limit exceeded. Please retry after a short delay." + "error": "concurrency_limit_exceeded", + "detail": "Too many concurrent requests: this account allows 5 at a time and 5 are already running. Retry as soon as one finishes, or upgrade your plan for more: https://scrapebadger.com/pricing", + "max_concurrency": 5, + "concurrent_requests": 5 } } } diff --git a/rate-limits.mdx b/rate-limits.mdx deleted file mode 100644 index b58c852..0000000 --- a/rate-limits.mdx +++ /dev/null @@ -1,171 +0,0 @@ ---- -title: Rate Limits -description: Understand ScrapeBadger API rate limits, the limit each plan includes, and best practices for handling rate limit errors. ---- - -ScrapeBadger rate limits requests per minute to ensure fair usage and reliable performance for all users. - -## How Rate Limiting Works - - - - Your rate limit is determined by your plan. All API keys inherit the same limit from your account. - - - We use a sliding window algorithm for accurate rate limiting. Limits are calculated per minute with smooth request distribution. - - - Every response includes rate limit headers so you can monitor usage and implement smart retry logic. - - - -## Rate Limits by Plan - -| Plan | Tier | Requests/Minute | -|------|------|-----------------| -| Free (sign-up credits, nothing bought yet) | Free | 5 | -| Pay-as-you-go | Basic | 60 | -| Starter, Growth | Pro | 300 | -| Pro, Scale | Enterprise | 1,000 | -| Volume | Enterprise | 3,000 | -| Max | Enterprise | 5,000 | -| Custom | Enterprise | By agreement | - -See [pricing](https://scrapebadger.com/pricing) for what each plan includes. - -## Rate Limit Headers - -Every API response includes these headers to help you track your rate limit usage: - -| Header | Description | Example | -|--------|-------------|--------| -| `X-RateLimit-Limit` | Maximum requests allowed per minute for your tier | `300` | -| `X-RateLimit-Remaining` | Requests remaining in the current window | `287` | -| `X-RateLimit-Reset` | Unix timestamp when the rate limit window resets | `1703123456` | -| `Retry-After` | Seconds until you can retry (only on 429 responses) | `45` | - -## Rate Limit Exceeded Response - -When you exceed your rate limit, the API returns a `429 Too Many Requests` response: - -```json -{ - "detail": "Rate limit exceeded", - "limit": 300, - "remaining": 0, - "reset_at": 1703123456, - "tier": "basic" -} -``` - -## Handling Rate Limits - - - -```bash cURL -# Check rate limit headers in response -curl -i -H "x-api-key: sb_live_xxx" \ - https://scrapebadger.com/v1/twitter/tweets/123 - -# Response headers: -# X-RateLimit-Limit: 300 -# X-RateLimit-Remaining: 299 -# X-RateLimit-Reset: 1703123456 -``` - -```javascript JavaScript -async function fetchWithRateLimit(url, apiKey) { - const response = await fetch(url, { - headers: { 'x-api-key': apiKey } - }); - - const remaining = response.headers.get('X-RateLimit-Remaining'); - const limit = response.headers.get('X-RateLimit-Limit'); - - if (response.status === 429) { - const retryAfter = response.headers.get('Retry-After'); - console.log(`Rate limited. Retry in ${retryAfter} seconds`); - await new Promise(r => setTimeout(r, retryAfter * 1000)); - return fetchWithRateLimit(url, apiKey); - } - - console.log(`Requests remaining: ${remaining}/${limit}`); - return response.json(); -} -``` - -```python Python -import time -import requests - -def fetch_with_rate_limit(url: str, api_key: str): - response = requests.get(url, headers={"x-api-key": api_key}) - - remaining = response.headers.get("X-RateLimit-Remaining") - limit = response.headers.get("X-RateLimit-Limit") - - if response.status_code == 429: - retry_after = int(response.headers.get("Retry-After", 60)) - print(f"Rate limited. Retry in {retry_after} seconds") - time.sleep(retry_after) - return fetch_with_rate_limit(url, api_key) - - print(f"Requests remaining: {remaining}/{limit}") - return response.json() -``` - - - -## Best Practices - - - - Check `X-RateLimit-Remaining` on each response to proactively slow down before hitting limits. - - - When rate limited, wait the `Retry-After` time and consider increasing wait time on repeated limits. - - - Queue requests and process them at a controlled rate to stay within your limits. - - - ScrapeBadger doesn't cache responses, so an identical repeat call is billed again. Keep results on your side where appropriate to reduce the number of requests you need to make. - - - - - **Avoid Rate Limit Abuse** - - Repeatedly hitting rate limits or attempting to bypass them may result in temporary or permanent restrictions on your account. - - - Don't create multiple accounts to circumvent limits - - Don't use rotating API keys to bypass rate limiting - - Contact support if you need higher limits - - -## FAQ - - - - Rate limits are applied per API key using a sliding window algorithm. Each API key has its own separate rate limit counter based on your plan. - - - The API returns a 429 Too Many Requests response with details about when you can retry. Use the `Retry-After` header to know when to try again. - - - Every `/v1` call, including the free ones: `/v1/quote` (an agent's `quote_call`) and `/v1/account/me` (`get_account_info`) count like a scrape. On the Free tier's 5 requests per minute, quoting before each call halves how many calls you can make. Polling an async request (`/v1/requests/{request_id}`) does not count. - - - Yes, all requests (successful or not) count against your rate limit. However, rate limits are generous and designed to accommodate normal usage patterns. - - - All API keys inherit the rate limit from your plan. To get higher rate limits, upgrade your plan. - - - Every API response includes rate limit headers (`X-RateLimit-Limit`, `X-RateLimit-Remaining`, `X-RateLimit-Reset`) so you can track your usage in real-time. - - - ---- - -Need higher rate limits? Contact us at [sales@scrapebadger.com](mailto:sales@scrapebadger.com). diff --git a/reddit/overview.mdx b/reddit/overview.mdx index d86e199..247cf8d 100644 --- a/reddit/overview.mdx +++ b/reddit/overview.mdx @@ -486,9 +486,9 @@ still-processing slots are omitted. the query string, invalidates the signature and Reddit answers `403`. -## Rate Limits +## Concurrency -Reddit Scraper API requests are subject to the same rate limits as all ScrapeBadger endpoints. See [Rate Limits](/rate-limits) for details. +Reddit Scraper API requests count toward your account's max concurrency like every other ScrapeBadger endpoint. See [Concurrency](/concurrency) for details. ## Run this asynchronously diff --git a/snippets/async-requests.mdx b/snippets/async-requests.mdx index 4a12d9b..ae20739 100644 --- a/snippets/async-requests.mdx +++ b/snippets/async-requests.mdx @@ -14,4 +14,4 @@ curl -s "https://scrapebadger.com/v1/requests/REQUEST_ID" \ -H "X-API-Key: $SCRAPEBADGER_API_KEY" ``` -An async call is billed once, when it completes. See [Async requests and webhooks](/long-running-requests) for webhooks, signatures and the SDK helpers. +An async call is billed once, when it completes. Until then it holds one of your account's [concurrent requests](/concurrency); polling for it doesn't. See [Async requests and webhooks](/long-running-requests) for webhooks, signatures and the SDK helpers. diff --git a/teams.mdx b/teams.mdx index cb6b51c..a3401b2 100644 --- a/teams.mdx +++ b/teams.mdx @@ -3,7 +3,7 @@ title: Teams description: Share one ScrapeBadger account with colleagues — invite members, grant them permissions, sign in with your company's SSO, and manage member and service API keys. --- -Teams let a company use one ScrapeBadger balance from several user accounts. Each member signs in with their own account, and the team's API keys draw credits from the **team owner's** balance and use the owner's rate limit. +Teams let a company use one ScrapeBadger balance from several user accounts. Each member signs in with their own account, and the team's API keys draw credits from the **team owner's** balance and share the owner's [max concurrency](/concurrency). Create a team on the [Teams](https://scrapebadger.com/dashboard/teams) page.