bitcastle API docs (1.0.0)

Download OpenAPI specification:Download

API Key Setup

All the endpoints will require an API Key. Please refer to this page regarding API key creation..

Once an API key is created, it is recommended to set IP restrictions on the key for security reasons.

Never share your API key/secret key to ANYONE.

If the API keys were accidentally shared, please delete them immediately and create a new key.

To manage your API keys, please go to the API Key Management page.

API Key Restrictions.

We support different options for API Key calling requests to Bitcastle:

Read Only: Request for login authentication and be able to use all the API to read info (Ex: user profile info, user’s balance info, trading history, deposit/ withdrawal history, etc.)

Spot Trading: Request to create or cancel an exchange order

Withdraw: Request to create a withdraw order

After creating the API key, the default restriction is Enable. If we see any suspicious attempts that may not be safe for our system, it would be Disabled and no longer be used.

The default rate for an API Key is:

50 calls per 10 seconds for user account.

100 calls per 10 seconds for enterprise account.

Websocket

We are support both MQTT and Websocket protocol for real time data. Data format must using MQTT package structure.

Base url:

  • Websocket: wss://socket.bitcastle.io/mqtt
  • MQTT: mqtt.bitcastle.io

Get Realtime Price Changes for All Markets:

  • Topic: public/exchange/update_ticker_24h
{
  "data": [
    {
      "coin": "ada",
      "currency": "usdt",
      "volume": "3536679.8",
      "total": "1321685.59747",
      "high": "0.38",
      "low": "0.3658",
      "price": "0.3684",
      "price_change": "-0.0096",
      "price_percentage": "-2.539682539682539683"
    }
  ],
  "last_update": "1684469752863"
}

Get Realtime Market Trades for Pair:

  • Topic: public/exchange/update_market_trade/{coin}/{currency}
  • Example: public/exchange/update_market_trade/btc/usdt
{
  "data": {
    "id": "68367233",
    "origin_order_id": "711794895602066054",
    "match_order_id": "711794895606258816",
    "coin": "btc",
    "currency": "usdt",
    "price": "26824.8",
    "net_volume": "0.00326556",
    "gross_volume": "0.00326556",
    "create_time": "1684469927659",
  },
  "last_update": "1684469927705"
}

Get Realtime Orderbook for Pair:

  • Topic: public/exchange/update_orderbook/{coin}/{currency}/{precision}
  • Example: public/exchange/update_orderbook/btc/usdt/0.01
    {
      "data": {
    "coin": "btc",
    "currency": "usdt",
    "precision": "0.01",
    "type": "ws",
    "orderbook": {
      "asks": [
        {
          "price": "26851.57",
          "volume": "0.00356067"
        },
        {
          "price": "26851.49",
          "volume": "0.00423304"
        },
        {
          "price": "26851.47",
          "volume": "0.01969202"
        }
      ],
      "bids": [
        {
          "price": "26797.22",
          "volume": "0.00285109"
        },
        {
          "price": "26797.19",
          "volume": "0.00570166"
        },
        {
          "price": "26797.18",
          "volume": "0.00096345"
        }
      ]
    }
      },
      "last_update": 1684469761904
    }
    

Balance

API that get user Balances

Get user balances

Authorizations:
ApiKeyAuth
query Parameters
types[]
Array of any
Default: [3]
Example: types[]=1&types[]=2

Balance Types ([CASHBACK,BO,EXCHANGE,REWARD,1,2,3,4])

Responses

Response samples

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

Markets

API that related to market data

Get Pairs

Market related statistics for all markets for the last 24 hours.

Responses

Response samples

Content type
application/json
[
  • {
    },
  • {
    }
]

Get 24h tickers

Market related statistics for all markets for the last 24 hours.

query Parameters
coin
string
Example: coin=btc
currency
string
Example: currency=usdt

Responses

Response samples

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

Get orderbook

Order book depth of any given trading pair, split into two different arrays for bid and ask orders.

query Parameters
coin
required
string
Example: coin=btc
currency
required
string
Example: currency=usdt
precision
required
string
Example: precision=0.01
take
number
Example: take=100

number of elements in each array, default = 100

sort
string
Enum: "ASC" "DESC"

order by: price, default = DESC

Responses

Response samples

Content type
application/json
{
  • "data": {
    },
  • "last_update": 1684470804010
}

Get historical trades

Used to return data on historical completed trades for a given market pair.

path Parameters
coin
required
string
Example: BTC
currency
required
string
Example: USDT

Responses

Response samples

Content type
application/json
{
  • "buy": [
    ],
  • "sell": [
    ]
}

Get market trades

Historical trade data for any given trading pair.

query Parameters
coin
required
string
Example: coin=btc
currency
required
string
Example: currency=usdt
take
number
Example: take=50

Default is 50

Responses

Response samples

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

Get price chart candlestick

The request will respond candle stick data buy trading pair

query Parameters
coin
required
string
Example: coin=btc
currency
required
string
Example: currency=usdt
range
required
string
Example: range=24h

Write List: 24h,7d,30d

Responses

Response samples

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

Spot Trading

API that use by user to create or cancel an exchange order

List open orders

The List Open Orders API allows you to retrieve a list of open or pending orders.

Define ENUM

  • status: PENDING = 1, FILLED = 2, CANCELED = 3, EXPIRED = 4, CANCELING = 6
  • stop_direction: UNDEFINED = 0, UP = 1, DOWN = 2
Authorizations:
ApiKeyAuth
query Parameters
order_class
number
Enum: 1 2 3 4
Example: order_class=2

MARKET = 1, LIMIT = 2, STOP_MARKET = 3, STOP_LIMIT = 4

order_type
number
Enum: 1 2
Example: order_type=2

BUY = 1, SELL = 2

currency
string
Example: currency=usdt
coin
string
Example: coin=btc
from_create_date
string
Example: from_create_date=1672053435907
to_create_date
string
Example: to_create_date=1672053435907
take
number
Default: 10
Example: take=10

Default is 10. For pagination

from
string

order_id of order

to
string

order_id of order

Responses

Response samples

Content type
application/json
{
  • "data": [
    ],
  • "status_code": 200,
  • "msg": "Success",
  • "timestamp": "123124123123"
}

List order history

The List Order History API provides a convenient way to retrieve a user's order history

Define ENUM

  • stop_direction: UNDEFINED = 0, UP = 1, DOWN = 2
Authorizations:
ApiKeyAuth
query Parameters
order_class
number
Enum: 1 2 3 4
Example: order_class=2

MARKET = 1, LIMIT = 2, STOP_MARKET = 3, STOP_LIMIT = 4

order_type
number
Enum: 1 2
Example: order_type=2

BUY = 1, SELL = 2

currency
string
Example: currency=usdt
coin
string
Example: coin=btc
from_create_date
string
Example: from_create_date=1672053435907
to_create_date
string
Example: to_create_date=1672053435907
order_status
number
Enum: 1 2 3 4 6
Example: order_status=2

PENDING = 1, FILLED = 2, CANCELED = 3, EXPIRED = 4, CANCELING = 6

take
number
Default: 10
Example: take=10

Default is 10. For pagination

from
string

id of order

to
string

id of order

Responses

Response samples

Content type
application/json
{
  • "data": [
    ],
  • "status_code": 200,
  • "msg": "Success",
  • "timestamp": "123124123123"
}

List trade history

The List Trade History API provides a convenient way to retrieve the trade history.

Authorizations:
ApiKeyAuth
query Parameters
order_class
number
Enum: 1 2 3 4
Example: order_class=2

MARKET = 1, LIMIT = 2, STOP_MARKET = 3, STOP_LIMIT = 4

order_type
number
Enum: 1 2
Example: order_type=2

BUY = 1, SELL = 2

currency
string
Example: currency=usdt
coin
string
Example: coin=btc
from_create_date
string
Example: from_create_date=1672053435907
to_create_date
string
Example: to_create_date=1672053435907
take
number
Default: 10
Example: take=10

Default is 10. For pagination

from
string

id of trade-history

to
string

id of trade-history

Responses

Response samples

Content type
application/json
{
  • "data": [
    ],
  • "status_code": 200,
  • "msg": "Success",
  • "timestamp": "123124123123"
}

Open order

Open new Order

Define ENUM

  • order_class: MARKET = 1, LIMIT = 2, STOP_MARKET = 3, STOP_LIMIT = 4
  • order_type: BUY = 1, SELL = 2
Authorizations:
ApiKeyAuth
Request Body schema: application/json
order_type
required
number
order_class
required
number
coin
required
string
currency
required
string
price
required
string
stop_price
required
string
volume
required
string

Responses

Request samples

Content type
application/json
{
  • "order_type": 1,
  • "order_class": 1,
  • "coin": "btc",
  • "currency": "usdt",
  • "price": "0.1",
  • "stop_price": "0.1",
  • "volume": "0.1"
}

Response samples

Content type
application/json
{
  • "order_type": 0,
  • "order_class": 0,
  • "coin": "btc",
  • "currency": "usdt",
  • "price": "0.1234211",
  • "stop_price": "0.1234211",
  • "volume": "0.1234211"
}

Get order by id

Get user's order by order_id.

Authorizations:
ApiKeyAuth
query Parameters
order_id
required
number
Example: order_id=687611739734551300

Id of the order

Responses

Response samples

Content type
application/json
{
  • "data": [
    ],
  • "status_code": 200,
  • "msg": "Success",
  • "timestamp": "123124123123"
}

Cancel orders by ids

The Cancel Open Order API allows you to cancel an open or pending orders by list of IDs

Authorizations:
ApiKeyAuth
Request Body schema: application/json
ids
Array of strings non-empty

Responses

Request samples

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

Response samples

Content type
application/json
{
  • "data": { },
  • "status_code": 200,
  • "msg": "Success",
  • "timestamp": "123124123123"
}