API

Request & Response Formats

Request

The fox.exchange API is reachable at the endpoint https://fox.exchange/api/cs.

For GET requests, parameters are expected to be located in the query string.

For POST requests, parameters are expected to be located in the request body. Both application/x-www-form-urlencoded and application/json encodings are supported (with the correct Content-Type header!), but there are some parameters (objects) which can only be sent properly with content type application/json. It is up to you to decide what works best for your use case.

User IP header

Note that many endpoints require an x-user-ip header to be sent. In this header, the original IP address of the end user may be transmitted (both IPv4 and IPv6 are supported). This is required for compliance reasons.

If you are using the API directly on a client device so that the requester's IP already is the user's IP, you may set this header to same_as_requester.

Based on the user's geographic location, some services may be unavailable. In case you are attempting an operation that is unavailable in the user's region, you will receive an error code region_lock.

You should send this header for all actions which are initiated by a user. (Querying existing orders does not require the header.)

Response

The response is always JSON (except when status code is 502, 503 or 504, in that case the response format is undefined), and follows the following schema:

Success case:

{
  "success": true,
  "code": "ok",
  "data": "actual response data here"
}

Error case:

{
  "success": false,
  "code": "error_code_here",
  "data": null,
  "error": "error message here"
}

The HTTP status also has meaning and can be understood as generalized status description. It will be 200 in success cases and an appropriate code from the 4xx/5xx ranges for error cases.

Error codes

Following is a non-exhaustive list of error codes:

authentication_error
invalid_address
invalid_input
invalid_symbol
invalid_quote_token
trade_pair_disabled
min_limit_breached
max_limit_breached
rate_limit
region_lock
unknown

Continue reading: Method Reference

Back to documentation overview