Reference
Errors & Rate Limits
Standard error envelope, SDK exception mapping, and per tier rate limits.
Errors
All errors return a JSON envelope with code, message, and status. The SDK maps each code to a typed exception inheriting from MarketlensError. The two 429 errors additionally carry structured fields inside the error object: limit, reset (Unix seconds), upgrade_url, and (for the daily budget) used.
Non HTTP exceptions: ConnectionError on network failure, TimeoutError after 30s (configurable). The SDK retries 429 and 5xx errors with exponential backoff (default 2 retries, configurable via max_retries). DAILY_BUDGET_EXCEEDED is not retried since the budget resets at midnight UTC.
{
"error": {
"code": "MARKET_NOT_FOUND",
"message": "Market abc... not found",
"status": 404
}
}{
"error": {
"used": 5000123,
"limit": 5000000,
"reset": 1783728000,
"upgrade_url": "https://marketlens.trade/#pricing",
"code": "DAILY_BUDGET_EXCEEDED",
"message": "Daily event budget exhausted (5,000,000 events). Resets at midnight UTC.",
"status": 429
}
}from marketlens import MarketLens, NotFoundError, RateLimitError
try:
book = client.orderbook.get("nonexistent-id")
except NotFoundError as e:
print(e.code, e.message)
except RateLimitError as e:
print(f"Retry after {e.retry_after}s")Rate Limits
Dual gated: a per-minute burst limit (RPM) and a daily event-volume budget, both tracked per user across all API keys. Bulk exports are charged against the same event budget. One row equals one event.