Skip to main content

Error Response Contract

  • A successful response uses the numeric code value 0
  • An error response may return code as an integer or a string; normalize it with String(code) before comparison
  • Do not branch on the message text. It explains the error and may vary by context
  • The HTTP status describes the request-level outcome, while code identifies the specific business reason; clients should check both

HTTP API

HTTP error responses contain at least code and message. Some endpoints also return error or data:
Financial and fundamental endpoints generally use this structure:

WebSocket Connection Failures

Authentication errors that occur before the WebSocket upgrade completes are regular HTTP error responses. The connection has not been established, so no WebSocket message is delivered.

Errors After WebSocket Connection

Subscription or message errors after the connection is established are delivered as WebSocket messages. cmd identifies the command that caused the error:

Error Code Reference

Authentication Errors (1xxx)

Parameter Errors (2xxx)

An ambiguous symbol in an HTTP request returns the string AMBIGUOUS_SYMBOL. An ambiguous symbol in a WebSocket subscription currently returns the numeric code 2003. In both cases, use available_types in the response to provide type.

Access and Quota Errors (3xxx)

WebSocket Channel Permission Errors (4xxx)

The current public WebSocket connection uses the following 4xxx error: Invalid JSON and unknown commands currently return cmd="error" with code=2001. Codes 4001–4004 are not part of the current public response contract, so clients should not depend on them.

Service Errors (5xxx)

The data object in a WebSocket subscription response with 5004 may include these fields:
  • symbols: symbols already subscribed successfully; do not subscribe to them again
  • failed_symbols: all symbols that were not subscribed in this request
  • retryable_symbols: the subset that can be retried later
  • retryable: whether at least one symbol can be retried

String Error Codes

Financial and Fundamental API Errors

The following five-digit codes apply to standard financial and fundamental endpoints. Stock news endpoints may use a different error mapping; use the code and message returned by those endpoints.

Error Handling Examples

JavaScript

Python