Skip to content

Error responses

TaxiScrape returns JSON for documented errors.

{
"detail": "string"
}
FieldTypeDescription
detailstringHuman-readable error detail.
StatusResponse bodyMeaning
429ErrorBodyToo many requests. Back off before retrying.
502ErrorBodyUpstream provider returned an error or could not provide a usable quote.
503ErrorBodyTaxiScrape or an upstream dependency is temporarily unavailable.

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));
}
}