NAV

Overview

Welcome to the 01 API documentation. We offer complete REST API to suit your algorithmic trading needs.(01 Rest API was inspired by FTX Rest API documentation)

Alternatively you can use our Python , Typescript, and Rust SDKs.

For more details visit our developer documentation: docs.01.xyz

REST API Setup

Since 01 is a non-custodian exchange you need to run the REST API on your end, so you can sign transactions yourself without any third party. You can download the rest api executable here. The source code is available at https://github.com/01protocol/zo-ts-rest-api


REST endpoint URL: localhost:3000

Requests and responses use JSON.

REST API Requests

Markets

Get markets

Request

GET /markets

Response

{
  "success": true,
  "result": [
    {
      "name": "SOL-PERP",
      "type": "future",
      "underlying": "SOL",
      "enabled": true,
      "ask": 39.93,
      "bid": 39.91,
      "price": 39.91999998430629
    }
    ...
  ]
}

Response format

Name Type Value Description
name string BTC-PERP e.g. "BTC/USD" for spot, "BTC-PERP" for futures
type string future "future" or "spot"
underlying string BTC future markets only
enabled boolean true
ask number 3949.25 best ask
bid number 3949.00 best bid
price number 10579.52 current price

Get single market

Request

GET /markets/{market_name}

Response

See /markets

Get orderbook

Request

GET /markets/{market_name}/orderbook?depth={depth}

Response

{
  "success": true,
  "result": {
    "asks": [
      [
        4114.25,
        6.263
      ]
    ],
    "bids": [
      [
        4112.25,
        49.29
      ]
    ]
  }
}

Parameters

Name Type Value Description
market_name string BTC-PERP Required. Name of the market.

Response format

Name Type Value Description
asks array [4114.25, 6.263] Array with price and size
bids array [4112, 49.29] Array with price and size

Get historical prices

Historical prices of expired futures can be retrieved with this end point but make sure to specify start time and end time.

Request

GET /markets/{market_name}/candles?resolution={resolution}&page={page}

Response

{
  "success": true,
  "result": [
    {
      "close": 21748.6,
      "high": 21917.9,
      "low": 21555.9,
      "open": 21689.7,
      "startTime": "2022-07-09T07:30:00.000Z"
    }
  ]
}

Parameters

Name Type Value Description
market_name string BTC-PERP name of the market
resolution number 300 window length in seconds. options: 15, 60, 300, 900, 3600, 14400, 86400, or any multiple of 86400 up to 30*86400
page number 0 page of interest

Response format

Name Type Value Description
startTime string 2019-06-24T17:15:00+00:00 start time of the window
open number 11059.25 mark price at startTime
close number 11055.25 mark price at the end of the window: startTime + resolution
high number 11089.0 highest mark price over the window
low number 11059.25 lowest mark price over the window

Get trades

Request

GET /markets/{market_name}/trades

Response

{
  "success": true,
  "result": [
    {
      "price": 41.72,
      "side": "sell",
      "size": 0.23,
      "status": "filled",
      "type": "market",
      "liquidation": false
    },
  ]
}

Parameters

Name Type Value Description
market_name string BTC-PERP name of the market
page number 0 page of interest

Response format

Name Type Value Description
liquidation boolean false if this trade involved a liquidation order
price number 3857.75
side string buy
size number 0.111
time string 2019-03-20T18:16:23.397991+00:00

Get coins

Request

GET /wallet/coins

Response

{
  "success": true,
  "result": [
    {
      "canConvert": false,
      "canDeposit": true,
      "canWithdraw": true,
      "collateral": true,
      "collateralWeight": 1000,
      "id": "USDC",
      "mint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
    },
  ]
}

Response format

Name Type Value Description
canDeposit boolean true true if this coin can be deposited via a crypto transaction
canWithdraw boolean true true if this coin can be withdrawn via a crypto transaction
canConvert boolean true
collateral boolean true
collateralWeight number 0.975
mint string EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
id string USDC

Get funding rates

Request

GET /funding_rates

Parameters

Name Type Value Description
page number 1 page
future string BTC-PERP optional

Response

{
  "success": true,
  "result": [
    {
      "date": "2022-06-27T10:00:00.000Z",
      "fundingIndex": 1195.925173,
      "fundingCollected": 0
    },
  ]
}

Response format(Array)

Name Type Value Description
date Date "2022-06-27T10:00:00.000Z"
fundingIndex number 1195.925173
fundingCollected number 0

User

Get account information

Request

GET /account

Response

{
  "success": true,
  "result": {
    "backstopProvider": false,
    "collateral": 3829.4851791035785,
    "freeCollateral": 0,
    "initialMarginRequirement": 0,
    "liquidating": false,
    "maintenanceMarginRequirement": 0,
    "makerFee": 0,
    "marginFraction": 1,
    "openMarginFraction": 1,
    "takerFee": 0.001,
    "totalAccountValue": 3829.4851791035785,
    "totalPositionSize": 0,
    "username": "7ryWXEx69xbDLoovrdvWRPhmUvHr6snf2Ama3vWqMrkj",
    "positions": []
  }
}

Response format

Name Type Value Description
backstopProvider boolean true whether or not the account is a registered backstop liquidity provider
collateral number 3568181.02691129 amount of collateral
freeCollateral number 1786071.456884368 amount of free collateral
initialMarginRequirement number 0.12222384240257728 average of initialMarginRequirement for individual futures, weighed by position notional. Cannot open new positions if openMarginFraction falls below this value.
liquidating boolean false True if the account is currently being liquidated
maintenanceMarginRequirement number 0.07177992558058484 Average of maintenanceMarginRequirement for individual futures, weighed by position notional. Account enters liquidation mode if margin fraction falls below this value.
makerFee number 0.0002 -
marginFraction number 0.5588433331419503 - ratio between total account value and total account position
notional.
openMarginFraction number 0.2447194090423075 Ratio between total realized account value and total open position
notional
takerFee number 0.0005
totalAccountValue number 3568180.98341129 total value of the account, using mark price for positions
totalPositionSize number 6384939.6992 total size of positions held by the account, using mark price
username string [email protected]
leverage number 10.0 Max account leverage
positions array See Get positions for details

Get positions

Request

GET /positions

Response

{
  "success": true,
  "result": [
    {
      "cost": 1.254856,
      "entryPrice": 41.82853333333333,
      "future": "SOL-PERP",
      "initialMarginRequirement": 0.1,
      "maintenanceMarginRequirement": 0.05,
      "netSize": 0.03,
      "openSize": 0,
      "longOrderSize": 0,
      "shortOrderSize": 0,
      "side": "buy",
      "size": 0.03,
      "unrealizedPnl": 0.002377999999911614,
      "collateralUsed": 0
    }
  ]
}

Parameters

Name Type Value Description
showAvgPrice boolean false optional

Response format

Name Type Value Description
cost number -31.7906 Amount that was paid to enter this position, equal to size * entry_price. Positive if long,
negative if short.
entryPrice number 138.22 Average cost of this position after pnl was last realized: whenever unrealized pnl gets realized, this field gets set to mark price, unrealizedPnL is set to 0, and realizedPnl changes by the previous value for unrealizedPnl.
future string ETH-PERP future name
initialMarginRequirement number 0.1 Minimum margin fraction for opening new positions
longOrderSize number 1744.55 Cumulative size of all open bids
maintenanceMarginRequirement number 0.04 Minimum margin fraction to avoid liquidations
netSize number -0.23 Size of position. Positive if long, negative if short.
openSize number 1744.32 Cumulative size of all orders
shortOrderSize number 1732.09 Cumulative size of all asks
side string sell sell if short, buy if long
size number 0.23 Absolute value of netSize
unrealizedPnl number 0.0
collateralUsed number 3.17906 Is equal to initialMarginRequirement * openSize * (mark price)

Get balances

Request

GET /wallet/balances

Response

{
  "success": true,
  "result": [
    {
      "coin": "USDC",
      "free": "2400.514835",
      "spotBorrow": 0,
      "total": 2400.514835,
      "usdValue": 2400.514835,
      "availableWithoutBorrow": "2400.514835"
    },
  ]
}

Response format

Name Type Value Description
coin string USDTBEAR coin id
free number 2320.2 free amount
spotBorrow number 0 amount borrowed using spot margin
total number 2340.2 total amount
usdValue number 2340.2 approximate total amount in USD
availableWithoutBorrow number 2320.2 amount available without borrowing

Get transfer history

Request

GET /wallet/transfers

Response

{
  "success": true,
  "result": [
    {
      "coin": "USDC",
      "size": 10,
      "type": "withdrawal",
      "status": "confirmed",
      "time": "2022-06-28T08:02:51.000Z"
    },
  ]
}

Request parameters

Name Type Value Description
page number 1 page of interest

Response format

Name Type Value Description
coin string BTC coin symbol
type string withdrawal or deposit coin symbol
size number 10
status string confirmed
time string 2019-06-27T15:24:03.101197+00:00

Withdraw

This call withdraws funds from the margin to the wallet account.

Request

GET /wallet/withdrawals

Response

{
  "success": true,
  "result": {
    "coin": "USDC",
    "status": "processed",
    "time": "2022-07-13T06:14:14.148Z",
    "txid": ""
  }
}

Parameters

Name Type Value Description
coin string BTC name of the market
size number 0 withdrawal size

Response format

Name Type Value Description
coin string BTC coin symbol
status string processed
txId string trade id
time string 2019-06-27T15:24:03.101197+00:00

Deposit

This call deposits asset from the wallet account to the margin account

Request

GET /wallet/deposits

Response

{
  "success": true,
  "result": {
    "coin": "USDC",
    "status": "processed",
    "time": "2022-07-148T06:20:52.693Z",
    "txid": ""
  }
}

Parameters

Name Type Value Description
coin string BTC name of the market
size number 0 deposit size

Response format

Name Type Value Description
coin string BTC coin symbol
status string processed
txId string trade id
time string 2019-06-27T15:24:03.101197+00:00

Get open orders

Request

GET /orders?market={market}

Response

{
  "success": true,
  "result": [
    {
      "future": "SOL-PERP",
      "id": "73805423038911909898768",
      "market": "SOL-PERP",
      "price": 40,
      "side": "buy",
      "size": 0.03,
      "status": "open",
      "type": "limit"
    },
  ]
}

Request parameters

Name Type Value Description
market string BTC-PERP optional; market to limit orders

Response format

Name Type Value Description
id number 9596912
market string XRP-PERP
type string limit
side string sell
price number 0.306525
size number 31431.0
status string open

Modify order

Request

POST /orders/{order_id}/modify
{
  "size": 31431,
  "price": 0.326525
}

Response

{
  "success": true,
  "result":  {
    "createdAt": "2022-07-18T06:22:31.332Z",
    "future": "SOL-PERP",
    "market": "SOL-PERP",
    "price": "50",
    "remainingSize": null,
    "side": "buy",
    "size": "0.03",
    "status": "open",
    "type": {
      "limit": {}
    },
    "reduceOnly": false,
    "ioc": false,
    "postOnly": false,
    "clientId": null
  }
}

Payload format

Name Type Value Description
price number 0.306525
size number 31431.0

Response format

Name Type Value Description
createdAt string 2019-03-05T11:56:55.728933+00:00
future string XRP-PERP
market string XRP-PERP
price number 0.326525
remainingSize number 31431.0
side string sell
size number 31431.0
status string open
type string limit
reduceOnly boolean false
ioc boolean false
postOnly boolean false
clientId string optional; client order id, if supplied

Get Order By Id

Request

GET /markets/{market_name}/trades

Response

{
  "success": true,
  "result": {
    "future": "SOL-PERP",
    "id": "73805423038911909898830",
    "market": "SOL-PERP",
    "price": 40,
    "side": "buy",
    "size": 0.01,
    "status": "open",
    "type": "limit"
  }
}

Parameters

Name Type Value Description
order_id string BTC-PERP name of the market

Response format

Name Type Value Description
id number 9596912
market string XRP-PERP
type string limit
side string sell
price number 0.306525
size number 31431.0
status string open

Cancel order

Request

DELETE /orders/{order_id}

Response

{
  "success": true,
  "result": "Order queued for cancellation"
}

Cancel order by client id

Request

DELETE /orders/by_client_id/{client_order_id}

Response

{
  "success": true,
  "result": "Order queued for cancellation"
}

Cancel All Orders

Request

DELETE /orders

Response

{
  "success": true,
  "result": "Orders queued for cancellation"
}

Close Position

This call closes position in its entirety.

Request

DELETE /positions/{market_name}

Response

{
  "success": true,
  "result": {
    "txId": "adsfgdsasdasd"
  }
}

Parameters

Name Type Value Description
market_name string BTC-PERP name of the market

Response format

Name Type Value Description
txId string trade id

Place order

Request

POST /orders
{
  "market": "XRP-PERP",
  "side": "sell",
  "price": 0.306525,
  "type": "limit",
  "size": 31431.0,
  "reduceOnly": false,
  "ioc": false,
  "postOnly": false,
  "clientId": null
}

Response

{
  "success": true,
  "result": {
    "txId": ""
  }
}

Payload format

Name Type Value Description
market string XRP-PERP e.g. "BTC/USD" for spot, "XRP-PERP" for futures
side string sell "buy" or "sell"
price number 0.306525 Send null for market orders.
type string limit "limit" or "market"
size number 31431.0
reduceOnly boolean false optional; default is false
ioc boolean false optional; default is false
postOnly boolean false optional; default is false
clientId string null optional; client order id

Response format

Name Type Value Description
txId string

Get trades history

Request

GET /orders/history?market={market}

Response

{
  "success": true,
  "result":  [
    {
      "future": "BTC-PERP",
      "liquidity": "taker",
      "market": "BTC-PERP",
      "price": 40027.9,
      "side": "sell",
      "size": 0.0002,
      "time": "2022-02-19T23:02:56.000Z"
    },
  ]
  "hasMoreData": false
}

Request parameters

Name Type Value Description
market string BTC-PERP
page number 1559881511 page of interest

Response format

Name Type Value Description
symbol string BTC-PERP
future string BTC-PERP
liquidity string taker or maker
price number 10135.25
size number 0.001
side string buy or sell
time string 2019-06-27T15:24:03.101197+00:00

Funding Payments

Request

GET /funding_payments
Name Type Value Description
page number 1 page
future string BTC-PERP optional

Response

{
  "success": true,
  "result": [
    {
      "future": "SOL-PERP",
      "payment": 0.0012200000001030276,
      "rate": 0.0006100000000515138,
      "date": "2022-07-17T14:00:00.000Z"
    },
  ]
}

Response format

Name Type Value Description
future string ETH-PERP
rate number 33830
payment number 0.0441342
date string 2019-05-15T18:00:00+00:00