Foxbit Invest REST API (3.0)

Introduction

Welcome to the official documentation for the Foxbit Invest Trading API, your gateway to seamless cryptocurrency trading automation. Designed specifically for clients of the Foxbit Invest platform, our API empowers users to execute buy and sell orders for cryptocurrencies programmatically, enabling the creation of sophisticated trading bots and automation of investment strategies.

What is Foxbit Invest Trading API?

The Foxbit Invest Trading API is a powerful tool designed to streamline cryptocurrency trading activities for our platform users. With real-time access to buy and sell orders, updated cryptocurrency quotes, transaction history, and account balance information, users can efficiently manage their portfolios and react swiftly to market changes.

Who is it for?

This documentation is aimed at clients of the Foxbit Invest platform who wish to integrate automated cryptocurrency trading into their systems. Whether you're an experienced developer or new to algorithmic trading, our API provides the flexibility and functionality you need to execute transactions programmatically and optimize your trading strategies.

Key Features and Benefits

  • Real-time buy and sell orders for cryptocurrencies
  • Access to updated cryptocurrency quotes
  • Transaction history retrieval
  • Account balance inquiries

How Does it Work?

Our API operates on a RESTful architecture, utilizing JSON for data exchange, ensuring compatibility and ease of integration with a wide range of programming languages and platforms. Authentication mechanisms ensure secure access to the API, protecting user data and transactions.

Usage Limits and Rate Limiting Policies

By default, the API enforces a rate limit of 150 requests per 10 seconds. However, some endpoints may have customized rate limits, which will be specified in the documentation for each endpoint.

Authentication

Authentication is required for accessing certain endpoints of the Foxbit Invest Trading API to ensure secure interactions and protect user data. To authenticate API requests, users need to include specific parameters in the request headers.

Authentication Parameters:

  • x-access-key: This parameter should contain the API Key generated within the Foxbit Invest platform. The API Key uniquely identifies the user and grants access to the API.

  • x-access-signature: The signature is generated using the Secret Key, along with the HTTP method, request path, query parameters (if any), and request body data. This ensures the integrity and authenticity of the request. The signature must be created using HMAC-SHA256 algorithm.

  • x-access-timestamp: The timestamp (in milliseconds) indicates when the signature was generated. This parameter helps prevent replay attacks by ensuring that each request is made within a valid timeframe.

Generating Signature Example (JavaScript):

  function sign(method, path, params, body) {
    let queryString = '';
    if (params) {
      queryString = Object.keys(params).map((key) => {
        return `${key}=${encodeURIComponent(params[key])}`;
      }).join('&');
    }

    let rawBody = '';
    if (body) {
      rawBody = JSON.stringify(body);
    }

    const timestamp = Date.now();
    const preHash = `${timestamp}${method}${path}${queryString}${rawBody}`;
    console.debug('PreHash:', preHash);
    const signature = CryptoJS.HmacSHA256(preHash, process.env.FOXBIT_INVEST_API_SECRET).toString();
    console.debug('Signature:', signature);

    return { signature, timestamp };
  }

Note: Ensure that you keep your Secret Key secure and never expose it publicly. The generated signature and timestamp must be included in the request headers when accessing authenticated endpoints.

This authentication mechanism ensures secure access to the Foxbit Invest Trading API and helps protect user data and transactions. If you have any questions or encounter any issues regarding authentication, please refer to the documentation or contact our support team for assistance.

Rate Limit

The Foxbit Invest Trading API implements a rate limiting policy to ensure fair usage and maintain system stability. This policy applies to all API endpoints by default.

Default Rate Limit:

By default, users are allowed a maximum of 150 requests every 10 seconds. If a user exceeds this limit, further requests will be blocked until the next 10-second window begins.

Endpoint-Specific Rate Limits:

Some endpoints may have specific rate limits tailored to their functionality. If an endpoint has a customized rate limit, it will be clearly specified in the documentation for that endpoint. In case a user exceeds the rate limit for a specific endpoint, they will be temporarily blocked from making further requests for the duration specified by that endpoint's rate limit.

Handling Rate Limit Exceedance:

If a user surpasses the rate limit, they will receive a response with a status code indicating that they have exceeded the rate limit.

Example:

Suppose an endpoint has a rate limit of 5 requests per 2 seconds. If a user exceeds this limit, they will be blocked from making further requests for a period of 2 seconds, after which they can resume making requests.

Note: It's important for users to monitor their API usage and ensure compliance with rate limiting policies to avoid disruptions in service.

System

Get current time

Responses

Response samples

Content type
application/json
{
  • "iso": "2021-06-01T00:00:00.000Z",
  • "timestamp": 1622505600000
}

Markets

Get markets

List available OTC Markets.
Rate Limit: This endpoint has the limit of 1 requests per second

Responses

Response samples

Content type
application/json
{
  • "data": {
    }
}

RFQ

Request for quote

Request a quotation with best price available
Rate Limit: This endpoint has the limit of 3 requests per 10 seconds

Request Body schema: application/json
required
market_symbol
required
string

The market symbol of the order to be created

side
required
string
Enum: "BUY" "SELL"

The side of the operation that you will place the order

quantity
required
string

The quantity of the base currency you want to buy or sell, expressed in string format

Responses

Request samples

Content type
application/json
{
  • "market_symbol": "btcbrl",
  • "side": "BUY",
  • "quantity": "0.42"
}

Response samples

Content type
application/json
{
  • "rfq_id": "faebd8ec-a70f-4193-bea3-543353b7c84c",
  • "market_symbol": "btcbrl",
  • "side": "BUY",
  • "quantity": "0.145",
  • "price": "178195.13",
  • "valid_until": "2024-01-01T00:00:00.000Z"
}

Execute quote

Execute a quotation previously requested
Rate Limit: This endpoint has the limit of 5 requests per 10 seconds

Request Body schema: application/json
required
client_order_id
string

Client self managed order id

rfq_id
required
string

Generated quote id

Responses

Request samples

Content type
application/json
{
  • "client_order_id": "123456",
  • "rfq_id": "faebd8ec-a70f-4193-bea3-543353b7c84c"
}

Response samples

Content type
application/json
{
  • "rfq_id": "faebd8ec-a70f-4193-bea3-543353b7c84c",
  • "client_order_id": "123456",
  • "market_symbol": "btcbrl",
  • "price": "1890.40",
  • "quantity": "0.001",
  • "side": "BUY",
  • "status": "CREATED",
  • "created_at": "2024-01-01T00:00:00.000Z"
}

History

Get the history of executed RFQs
Rate Limit: This endpoint has the limit of 5 requests per 2 seconds

query Parameters
page
required
number >= 1
Default: 1
Example: page=1

Page number

limit
required
number [ 1 .. 20 ]
Default: 10
Example: limit=10

Number of items per page

Responses

Response samples

Content type
application/json
{
  • "data": [
    ],
  • "total": 89
}

Accounts

Get account balances

List account balances Rate Limit: This endpoint has the limit of 8 requests per 2 seconds

Responses

Response samples

Content type
application/json
{
  • "data": [
    ]
}