Skip to content

Error handling

The Python SDK maps HTTP error responses to exception subclasses so you can except AuthError / except RateLimitError without inspecting status_code yourself.

ExceptionHTTPRetry?What to do
AuthError401NoPrompt for a new key; don’t retry blindly
ValidationError400, 422NoFix the request — exc.response_body has the detail
NotFoundError404NoAddress couldn’t be resolved; try a different mode
RateLimitError429Yes (SDK auto-retries)If you re-raise, honor exc.retry_after
ServiceError5xxYes (SDK auto-retries)Upstream issue; give up after max_retries
AmbiguousLookupError— (client-side)N/AWalk response.rows manually

The SDK retries 429 and 5xx automatically with exponential backoff (default 3 attempts, honoring Retry-After). 4xx errors other than 429 raise immediately — there’s no point retrying a malformed request.

from taxql import (
TaxQL, AuthError, RateLimitError, NotFoundError,
ValidationError, ServiceError, TaxQLError,
)
try:
response = client.lookup(state="tx", zip="75068")
except AuthError:
raise SystemExit("Invalid API key. Check the dashboard.")
except RateLimitError as exc:
# SDK already retried; this means it gave up
raise SystemExit(f"Quota exhausted; retry after {exc.retry_after}s")
except (NotFoundError, ValidationError) as exc:
log.error("Lookup failed: %s (body=%s)", exc, exc.response_body)
except ServiceError:
# Upstream is down — defer to a retry queue
enqueue_for_later(...)
except TaxQLError as exc:
log.exception("Unexpected SDK error", extra={"status": exc.status_code})

Full content coming soon — including caller-side retry strategies for batch processing.