Type/to search
Built-in Functions
Structures
Ticker
Depth
OrderBook
Trade
Record
Market
Order
Condition
Account
Asset
Position
Funding
Other Structures
HttpQuery-options
HttpQuery-return
LogStatus-table
LogStatus-btnTypeOne
LogStatus-btnTypeTwo
Status Bar Components
Chart-options
Chart-return
KLineChart-options
KLineChart-return
SetData-data
EventLoop-return
exchange.Go-return
DBExec-return
Dial-return
Thread.join-return
Built-in Variables and Constants
Conventions
Exchanges

This JSON structure is the data structure returned by the HttpQuery function in debug mode, when the debug field is set to true in the options parameter structure while calling the HttpQuery function.

Attributes

NameTypeDescription

StatusCode

number

HTTP status code. It is 0 when no response is received for the request (connection refused, DNS resolution failure, timeout, proxy failure, etc.).

Header

object

Response header information. The value of each key is an array of strings (a header name can appear several times, for example multiple Set-Cookie headers).

Cookies

array

Array parsed from each Set-Cookie header of the response; every element has the fields Name, Value, Path, Domain, Expires, MaxAge, Secure, HttpOnly, SameSite and Raw.

Trace

object

Diagnostic timing information for each stage of the request, including millisecond values such as elapsed_ms (total), dns_ms, connect_ms, tls_ms, ttfb_ms (time to first byte) and recv_ms, plus fields such as peer_addr (remote address), reused (whether the connection was reused) and version (HTTP version). Only present when debug is true.

Length

number

Message length. When charset is set, it is the length before decoding.

Body

string

Message content. It is an empty string when the request fails.

Error

string

The reason for the request failure, including the request method, URL, and underlying error information, for example: Get "https://www.okx.com/api/v5/public/time": timeout after 1000ms. It only appears when the request fails (StatusCode is 0).

See Also

Remarks

Example of the returned JSON data structure:

json
{ "StatusCode": 302, "Header": { "Content-Type": ["text/html"], "Location": ["https://www.example.com/"] }, "Cookies": [], "Trace": { "elapsed_ms": 152.4, "dns_ms": 3.1, "connect_ms": 20.5, "tls_ms": 45.2, "ttfb_ms": 150.8, "recv_ms": 1.6, "peer_addr": "93.184.216.34:443", "reused": false, "version": "HTTP/1.1" }, "Length": 154, "Body": "..." }

Example of the data structure returned when the request fails (no response received):

json
{ "StatusCode": 0, "Header": {}, "Cookies": [], "Length": 0, "Body": "", "Error": "Get \"https://www.okx.com/api/v5/public/time\": timeout after 1000ms" }

Responses with HTTP status codes 4xx and 5xx are not considered request failures. In this case, StatusCode is the actual status code, and the Error field is not included. You can use StatusCode for unified checking: if (ret.StatusCode !== 200) { ... }.

In Rust, the HttpRet structure returned by HttpQuery only has the fields StatusCode, Header, Cookies, Body and Error (there is no Length or Trace, and Cookies is not filled).