Error responses
TaxiScrape returns JSON for documented errors.
Error body
Section titled “Error body”{ "detail": "string"}| Field | Type | Description |
|---|---|---|
detail | string | Human-readable error detail. |
Status codes
Section titled “Status codes”| Status | Response body | Meaning |
|---|---|---|
429 | ErrorBody | Too many requests. Back off before retrying. |
502 | ErrorBody | Upstream provider returned an error or could not provide a usable quote. |
503 | ErrorBody | TaxiScrape or an upstream dependency is temporarily unavailable. |
Retry guidance
Section titled “Retry guidance”For 429, wait before retrying. For 502 and 503, retry with a short delay and cap the number of attempts.
async function fetchFareWithRetry(url, attempts = 3) { for (let attempt = 1; attempt <= attempts; attempt += 1) { const response = await fetch(url);
if (response.ok) return response.json();
const retryable = [429, 502, 503].includes(response.status); if (!retryable || attempt === attempts) { const error = await response.json().catch(() => ({ detail: response.statusText })); throw new Error(error.detail); }
await new Promise((resolve) => setTimeout(resolve, attempt * 1000)); }}