Skip to main content
All SDK exceptions inherit from TONAPIError. Catch it to handle any error from the library.
from pytonapi.exceptions import TONAPIError

Client Errors

CodeExceptionDescription
400TONAPIBadRequestErrorCheck query parameters, request body, and path arguments.
401TONAPIUnauthorizedErrorInvalid API key. Obtain one at tonconsole.com.
403TONAPIForbiddenErrorCheck your API key permissions.
404TONAPINotFoundErrorResource does not exist.
405TONAPIMethodNotAllowedErrorUse GET or POST.
409TONAPIConflictErrorResource does not match the expected type.
422TONAPIUnprocessableErrorParameters failed validation.
429TONAPITooManyRequestsErrorRate limit exceeded. Back off and retry.

Server Errors

CodeExceptionDescription
500TONAPIInternalServerErrorInternal server error.
501TONAPINotImplementedErrorNot implemented.
504TONAPIGatewayTimeoutErrorGateway timeout. Retry the request.

Other Exceptions

ExceptionWhen
TONAPIConnectionErrorDNS failure, TCP timeout, or refused connection — before any HTTP response.
TONAPIValidationErrorResponse body did not match the expected Pydantic model.
TONAPISessionNotCreatedErrorRequest made before client session was initialized.
TONAPIStreamingErrorTransport-level error during streaming.
TONAPIConnectionLostErrorReconnect limit exhausted during streaming.
TONAPIRetryLimitErrorAll retry attempts exhausted.