Overview

The API primarily returns JSON-encoded responses, unless specified otherwise, and uses standard HTTP headers, methods, response codes, and authentication procedures.

The text payload for requests and responses is encoded in UTF-8.

All HTTP endpoints are relative and resolved based on the specified hostname, which is configured during the setup of B2Core.

HTTP headers

Include the following HTTP headers in your requests:

Authorization: Bearer <token>

Incudes a bear token required for authorization.

Accept: <media-type>

Indicates the response format which is used to process a response body.

For example: Accept: application/json

Accept-Language: <language-code>

Indicates the natural language which is used to process a response body.

For example: Accept-Language: ja

Content-Type: <media-type>

Indicates the request format which is used to process a request body.

For example: Content-Type: application/json

HTTP methods

The B2Core API uses the following HTTP methods:

POST

Creates a resource.

GET

Reads a resource.

PUT

Updates a resource. Instead of this method, you can use a similar method that uses the HTTP verb PATCH.

DELETE

Removes a resource.

HTTP response codes

The B2Core API uses standard HTTP response codes to indicate the success or failure of a request:

Successful responses

200 OK

The request succeeded.

201 Created

The request succeeded, and a new resource was created as a result. Typically, this response is sent after POST requests.

202 Accepted

The request was accepted for processing, but the processing will start later.

204 No Content

The request succeeded, but no response body was returned.

Error responses

400 Bad Request

The request was invalid (for example, malformed or syntactically incorrect). This status code may indicate one of the following issues:

  • The API cannot convert the payload data to the underlying data type.

  • The data is not in the expected data format.

  • Required fields are not available.

  • A data validation error occurred.

401 Unauthorized

The request didn’t include an authentication token or the token has expired.

403 Forbidden

The client didn’t have the permissions to access the requested resource.

404 Not Found

The requested resource wasn’t found because the specified URI was invalid or the requested resource was unavailable (for example, a URI pointed to an empty database).

405 Method Not Allowed

The HTTP method in the request wasn’t supported by the resource.

406 Not Acceptable

The request wasn’t completed because the server doesn’t support the requested response format. For example, the request contained the Accept: application/xml header, but the API can only generate a response in the application/json format.

413 Payload Too Large

The request payload was too large to be processed by the server.

415 Unsupported Media Type

The request was rejected by the server because it doesn’t support the requested data format. For example, the request contained the Content-Type: application/xml header, but the API only accepts requests in the application/json format.

429 Too Many Requests

The rate limit set for the user, application or token exceeded a predefined value.

500 Internal Server Error

The request wasn’t completed due to an internal error on the server side.

503 Service Unavailable

The server is down for maintenance.

Query parameters

You can include filter and sorting parameters as well as the parameters to facilitate pagination in your HTTP requests.

Filtering

filter array

Specifies a key-value pair in the following format: filter[<key>]=<value>

For example: filter[currencyAlphaCode]=BTC

If a method supports multiple filter parameters, you can include them in a single request.

For example: filter[clientId]=1&filter[platformId]=1&filter[productId]=1

Note

HTTP methods support specific filter parameters, which are described in the Query parameters section for each method.

Sorting

sort_by string

Sorts the items in the response by a specified parameter.

For example: sort_by=createTime

sort_order string

Sorts the items in the response in the ascending or descending order.

For example: sort_by=createTime&sort_order=asc or sort_by=createTime&sort_order=desc

Pagination

limit integer

Specify this parameter to define the maximum number of items that may be returned in a response.

For example, limit=10 returns the first ten items.

offset integer

Specify this parameter to exclude from a response the first N items of a resource collection.

For example, offset=5&limit=5 returns the items 6 through 10.

Date and time formats

The B2Core API supports the RFC 3339 format for date and time representation.

Such formats as the Unix timestamp or LDAP timestamp that are frequently used on trading platforms and return unambiguous data are also supported in responses.