Skip to content

Error Codes

One error model spans the SDK: the Rust core classifies every failure once, and each language surfaces the classification in its idiom. Catch the specific class you can recover from; let the rest propagate.

Download as CSV

ConditionRust Error variantPython exceptionC++ exception
Bad or expired credentialsAuthAuthenticationError / InvalidCredentialsErrortdx::AuthenticationError / tdx::InvalidCredentialsError
Endpoint needs a higher tierGrpc (permission)SubscriptionErrortdx::SubscriptionError
Too many requests in flight upstreamGrpc (resource exhausted)RateLimitErrortdx::RateLimitError
Request returned no rowsNoDataNoDataFoundErrortdx::Error with kind == NoData
Per-request deadline elapsedTimeoutTimeoutErrortdx::Error with kind == Timeout
Connection / TLS / protocol faultTransportNetworkErrortdx::NetworkError
Response shape unexpectedDecodeSchemaMismatchErrortdx::SchemaMismatchError
Streaming session faultFpssStreamErrortdx::StreamError
Invalid parameters / configurationConfigThetaDataErrortdx::ThetaDataError
  • Python exceptions all derive from ThetaDataError, so except ThetaDataError is the catch-all.
  • TypeScript throws the standard Error; the message carries the same stable text as the Rust Display output, so the failure category is recognizable without a class tree.
  • C++ exceptions derive from tdx::ThetaDataError; NoData and Timeout ride the generic tdx::Error with a kind discriminator.
python
from thetadatadx import NoDataFoundError, RateLimitError, ThetaDataError

try:
    rows = tdx.option_history_trade("SPY", "20250321", "20250303", strike="570", right="C")
except NoDataFoundError:
    rows = []                # nothing traded — a normal outcome, not a failure
except RateLimitError:
    ...                      # back off and retry; see Concurrent Requests
except ThetaDataError:
    raise                    # anything else is a real failure

Transient faults (transport drops, upstream exhaustion) are retried inside the SDK with backoff before any error surfaces; tune the budget via the retry_* configuration fields.

Server error envelope

The HTTP server reports every failure with one envelope shape and an error_type discriminator:

json
{
    "header": { "error_type": "bad_request", "error_msg": "missing required parameter: 'date' (Date YYYYMMDD)" },
    "response": []
}
HTTP statuserror_typeMeaning
400bad_requestMissing or invalid parameter; the message names it.
404not_foundUnknown route.
429Per-IP rate limit on non-loopback binds; carries Retry-After.
503upstream_exhaustedUpstream capacity exhausted after retries; carries Retry-After.

Released under the Apache-2.0 License.