NAV
python

Introduction

This API Documentation Introduces How To Use REST API for OneChain CryptoCurrency Exchange.

API Key

API Key Restrictions

Rate Limit

Limit number of requests per second.

Public API - 10 requests per second.

Private API - 10 requests per second.

Endpoints

Authentication

You need HMAC Authentication in order to use Private APIs.

When you read the instructions below, as there are many steps needed to make correct request, you may find HMAC authentication process complicated. Try to think about the purpose of your task and proceed then you will find this process a bit more simple.

Purpose of using HMAC

The purpose of using HMAC is to prevent data forgery. Hackers can always manipulate data for all requests.

When requests are manipulated before they reach our server, unintended operations can be taken place.

When you use HMAC authentication, the client will send un-encrypted plaintext request data attached with encrypted request data. Then, use the received two data to determine whether the data have been manipulated.

Essential Components and Procedures for HMAC Request

Header should contain 3 keys (API-KEY, Signature, Nonce).

  1. API-KEY is an API-KEY that the OneChain exchange website issued in raw format.

  2. Signature is an encrypted data chain. The data chain is composed as follows: original_text = "{nonce}\n{method}\n{origin}\n{path_with_query_string}\n{body}"
    How to use original_text to generate Signature:

    1. Sign original_text with SHA512 encrypted Secret Key.
    2. Convert signed text into base64.
  3. Nonce is UUID to distinguish unique request. Nonce is non-reusable. If you send a request with previously used Nonce value, the request will get rejected.

Example for Endpoints without Body

How to generate Signature

import base64
import hmac
import hashlib
from uuid import uuid4


API_KEY = "11c3e0ea78259ca8a47cb7238fa263d30e7e31184372d6bc"
SECRET_KEY = "afba10eeff85c3fbeef32527d248fddda6b125f6e8756247"

key = base64.b64decode(SECRET_KEY)

nonce = str(uuid4())

method = 'GET'

origin = 'openapi.onechain.pro'

path_with_query_string = '/v1/accounts/'

original_text = f'{nonce}\n{method}\n{origin}\n{path_with_query_string}'
"""
1a653055-7aeb-43c9-a865-86cf89322f22
GET
openapi.onechain.pro
/v1/accounts/
"""
signed_text = hmac.new(key, original_text.encode('utf-8'), hashlib.sha512)
signature = base64.b64encode(signed_text.digest()).decode('utf-8')
# signature
# /1N6D7qagGzEgZMjXBtJMmKArIucmRMD2gh7GBtxk+1Whu6lPsvkuQeDISm5/bPt793+iuWz6aRQCfVn4smuSw==

Send data with Signature

import requests

url = 'https://openapi.onechain.pro/v1/accounts/'

headers = {
    'API-KEY': '11c3e0ea78259ca8a47cb7238fa263d30e7e31184372d6bc',
    'Signature': '/1N6D7qagGzEgZMjXBtJMmKArIucmRMD2gh7GBtxk+1Whu6lPsvkuQeDISm5/bPt793+iuWz6aRQCfVn4smuSw=='
    'Nonce': '1a653055-7aeb-43c9-a865-86cf89322f22',
}

res = requests.get(url, headers=headers)
json_res = res.json()
print(json_res)

HTTP Request

GET /v1/accounts/

Header

Name Description
API-KEY API-KEY that the OneChain exchange website issued in raw format
Signature Signature Value
Nonce UUID

Request Parameters

Name Type Mandatory Description
symbols STRING NO If set to symbol, the result will only symbol.

Example for Endpoints with Body

How to generate Signature

import base64
import hmac
import hashlib
from uuid import uuid4
import json


API_KEY = "11c3e0ea78259ca8a47cb7238fa263d30e7e31184372d6bc"
SECRET_KEY = "afba10eeff85c3fbeef32527d248fddda6b125f6e8756247"

key = base64.b64decode(SECRET_KEY)
nonce = str(uuid4())

method = 'POST'

origin = 'openapi.onechain.pro'

path_with_query_string = '/v1/orders/'

data = {
    "trading_pair": "ETH-BTC",
    "side": "BUY",
    "order_type": "LIMIT",
    "volume": 0.1,
    "price": 0.0352
}

body = json.dumps(data)

original_text = f'{nonce}\n{method}\n{origin}\n{path_with_query_string}\n{body}'

"""
44566ac0-3bba-4acd-9895-651bf3574644\nPOST\nopenapi.onechain.pro\n/v1/orders/\n[{"trading_pair": "ETH-BTC", "side": "BUY", "order_type": "LIMIT", "volume": 0.1, "price": 0.0352}]
"""
signed_text = hmac.new(key, original_text.encode('utf-8'), hashlib.sha512)
signature = base64.b64encode(signed_text.digest()).decode('utf-8')
# signature
# X4X2bolowMU7EzwY85Zfp6u8RRzqAAx+qU21Vskd689tmYItontLGKNnlcY8SI/WJ09xeod9mlKBa/poqLYkUg==

Send data with Signature

import requests

url = 'https://openapi.onechain.pro/v1/orders/'

headers = {
    'API-KEY': '11c3e0ea78259ca8a47cb7238fa263d30e7e31184372d6bc',
    'Signature': 'X4X2bolowMU7EzwY85Zfp6u8RRzqAAx+qU21Vskd689tmYItontLGKNnlcY8SI/WJ09xeod9mlKBa/poqLYkUg=='
    'Nonce': '44566ac0-3bba-4acd-9895-651bf3574644',
}

data = {
    "trading_pair": "ETH-BTC",
    "side": "BUY",
    "order_type": "LIMIT",
    "volume": 0.1,
    "price": 0.0352
}

res = requests.post(url, headers=headers, json=data)
json_res = res.json()
print(json_res)

HTTP Request

POST /v1/orders/

Header

Name Description
API-KEY API-KEY that the OneChain exchange website issued in raw format
Signature Signature Value
Nonce UUID

Request Parameters(Body)

Name Type Mandatory Description
trading_pair STRING YES
side STRING YES 'BUY', 'SELL'
price DECIMAL YES
volume DECIMAL YES Amount
order_type STRING YES 'LIMIT', 'MARKET'

Stream

Introduction

Token Authentication

Token Authentication is a security measure implemented to protect the communication between a WebSocket client and server.
The above measures are prevent unauthorized access and data interception.

Token for stream can be obtained through Token API.

Stream Connect Using Token

Example

wscat -c wss://ws.onechain.pro/v1/ws --header="Authorization:Bearer fYHKZ6PjCmcGFnJ3bn2iMLzq0esYaO"

Message Type

Message

[
    "topic name",
    "sub topic name",
    [DATA]
]

Available Topics

MainTopic SubTopic Public DataType Description
ACCOUNT Symbol X ALONE Receive when there is a change in Symbol
TRADE TradingPair O ARRAY Receive all transactions for that trading pair.
PERSONAL_TRADE TradingPair X ARRAY Receive transactions associated with user order.
ORDER TradingPair X ARRAY Receive status changes of user order.
ORDERBOOK TradingPair O ALONE Receive a snapshot of the order book of a trading pair.
TICKER TradingPair O ALONE Receive the ticker (summary information) of the trading pair.
SYS INFO O By default, subscribed and receive system-related messages.
OP RESULT O By default, subscribed and receives the result of the command.

Operation

Operation(SUBSCRIBE)

{"op":"SUBSCRIBE","arg":["TRADE:*"],"id":"ec0f011c-4856-4a02-b6f4-ad6573d86dff"}

Operation(UNSUBSCRIBE)

{"op":"UNSUBSCRIBE","arg":["TRADE:*"],"id":"ec0f011c-4856-4a02-b6f4-ad6573d86dff"}

Operation(SUBSCRIPTIONS)

{"op":"SUBSCRIPTIONS","arg":[],"id":"ec0f011c-4856-4a02-b6f4-ad6573d86dff"}

Operation(AUTH)

{"op":"AUTH","arg":["Bearer", "fYHKZ6PjCmcGFnJ3bn2iMLzq0esYaO"],"id":"ec0f011c-4856-4a02-b6f4-ad6573d86dff"}

Response (Success)

[
    "OP",
    "RESULT",
    [true,"3c835d43-6e11-4848-9c6b-17d7e9fc79a3","SUBSCRIBE",["TRADE:BTC-KRW"],"SUCCESS",1001]
]

Response (Fail)

[
    "OP",
    "RESULT",
    [false,"3c835d43-6e11-4848-9c6b-17d7e9fc79a3","SUBSCRIBE",["TRADE:ETH-BTC"],"topic name dose not exist",8004]
]

can subscribe/unsubscribe to various events through Opeation Stream.

Request

Field Description
op Excute command
arg List of arguments that must be entered into the command
id will be returned the same as the value being responded to (a new UUID value is recommended for each request).

Operations

Operation Arguments Description
SUBSCRIBE Topic Name Subscribe to Topic
UNSUBSCRIBE Topic Name UnSubscribe to Topic
SUBSCRIPTIONS Get a list of topics you are currently subscribed to.
AUTH Auth Type, Key Token Authorization

Public Streams

Trade Stream

Request

{"op":"SUBSCRIBE","arg":["TRADE:*"],"id":"ec0f011c-4856-4a02-b6f4-ad6573d86dff"}

Response

[
   "TRADE",
   "BTC-KRW",
   [
      [
         "c62b307b-e082-40f7-a764-7a079e747b86",
         1569592070447,
         "BUY",
         "9648000",
         "0.01036484"
      ],
      ….
   ]
]

Response

index Type Description
0 String Main Topic Name
1 String Sub Topic Name
2 Array Datas

Response(Datas)

index Type Description
0 String UUID
1 Timestamp MTS
2 String Side(BUY, SELL)
3 String Price
4 String Volume

Orderbook Stream

Request

{"op":"SUBSCRIBE","arg":["ORDERBOOK:*"],"id":"ec0f011c-4856-4a02-b6f4-ad6573d86dff"}

Response

[
   "ORDERBOOK",
   "BTC-KRW",
   [
      [
         ["9600000","0.0314344"],
         ["9500000","0.11842105"],
         ["9479000","0.05274818"],
         ["9469000","0.019"],
         ["9468000","0.061"],
         ["9466000","0.02"],
         ["9465000","0.001"],
         ["9464000","0.356"],
         ["9461000","0.061"],
         ["9460000","0.008"],
         ["9459000","0.102"],
         ["9458000","0.192"],
         ["9457000","0.059"],
         ["9400000","0.07978723"],
         ["9300000","0.08064516"]
      ],
      [
         ["9662000","0.155"],
         ["9664000","0.155"],
         ["9667000","0.025"],
         ["9670000","0.155"],
         ["9672000","0.01"],
         ["9674000","0.013"],
         ["9676000","0.078"],
         ["9677000","0.017"],
         ["9678000","0.017"],
         ["9679000","0.103"],
         ["9844000","0.026"],
         ["10008000","0.019"],
         ["10173000","0.02"],
         ["10337000","0.024"],
         ["10502000","0.021"]
      ]
   ]
]

Response

index Type Description
0 String Main Topic Name
1 String Sub Topic Name
2 Array Datas

Response(Datas)

index Type Description
0 Array BID
1 Array ASK

Response(BID, ASK)

index Type Description
0 String Price
1 String Volume

Ticker Stream

Request

{"op":"SUBSCRIBE","arg":["TICKER:*"],"id":"ec0f011c-4856-4a02-b6f4-ad6573d86dff"}

Response

[
   "TICKER",
   "·NET-KRW",
   [
      "1250",
      "1370",
      "945",
      "1030",
      "8243537097.2456408",
      "7419594.16954943",
      "FALL",
      "-0.176",
      "-220",
      1570182619475
   ]
]

Response

index Type Description
0 String Main Topic Name
1 String Sub Topic Name
2 Array Datas

Response(Datas)

index Type Description
0 String OpenPrice
1 String HighPrice
2 String LowPrice
3 String ClosePrice
4 String AccTradeValue
5 String AccTradeVolume
6 String Change
7 String ChangeRate
8 String ChangePrice
9 TimeStamp Created

Private Streams

Account Stream

Request

{"op":"SUBSCRIBE","arg":["ACCOUNT:*"],"id":"ec0f011c-4856-4a02-b6f4-ad6573d86dff"}

Response

[
   "ACCOUNT",
   "KRW",
   [
      "1000",
      "1000",
      "0",
      "0",
      "0",
      "0"
   ]
]

Response

index Type Description
0 String Main Topic Name
1 String Sub Topic Name
2 Array Datas

Response(Datas)

index Type Description
0 String Balance
1 String Liquid
2 String PendingOrder
3 String PendingWithdrawal
4 String AvgFiatBuyPrice
5 String StakingAmount

Personal Trade Stream

Request

{"op":"SUBSCRIBE","arg":["PERSONAL_TRADE:*"],"id":"ec0f011c-4856-4a02-b6f4-ad6573d86dff"}

Response

[
   "PERSONAL_TRADE",
   "BTC-KRW",
   [
      [
         "48c63ff8-2d95-4080-8e9e-d9b99355f25c",
         1569592070447,
         "BUY",
         "9648000",
         "0.01036484"
         "CROSS"
      ],
      [
         "cf2a1731-53bf-4d0e-beb6-84755f92425e",
         1569592070447,
         "BUY",
         "9648000",
         "0.01036484"
         "MAKER"
      ],
      [
         "d829a5a6-686e-4089-a0f5-30532f280895",
         1569592070447,
         "BUY",
         "9648000",
         "0.01036484"
         "TAKER"
      ],
      ….
   ]
]

Response

index Type Description
0 String Main Topic Name
1 String Sub Topic Name
2 Array Datas

Response(Datas)

index Type Description
0 String UUID
1 String MTS
2 String Side(BUY,SELL)
3 String Price
4 String Volume
5 String Type (MAKER,TAKER,CROSS)

Order Stream

Request

{"op":"SUBSCRIBE","arg":["ORDER:*"],"id":"ec0f011c-4856-4a02-b6f4-ad6573d86dff"}

Response

[
   "ORDER",
   "BTC-KRW",
   [
      [
         "e7975c66-5de2-4009-9ac8-6801b8570cd3",
         "BUY",
         "9452000",
         "0.00052898",
         "0.00052898",
         "PLACED",
         1569592722764
      ],
      [
         "2517e0ca-a6b5-4a46-beda-6642821b6a96",
         "BUY",
         "9352000",
         "0.00052898",
         "0.00052898",
         "CANCELLED",
         1569592722765
      ],
      ….
   ]
]

Response

index Type Description
0 String Main Topic Name
1 String Sub Topic Name
2 Array Datas

Response(Datas)

index Type Description
0 String UUID
1 String Order Type
2 String Side
3 String Price
4 String Volume
5 String Remain Volume
6 String Order Status
7 TimeStamp MTS

Public API

GET Fetch Assets

Request

import requests

url = "https://openapi.onechain.pro/v1/assets/"

res = requests.get(url)
json_res = res.json()
print(json_res)

Response

[
    {
        "symbol": "USDT",
        "withdrawal_fee": "0.00000000000000000000",
        "min_deposit_amount": "0.00000000000000000000",
    }
]

Fetch All Assets of User

HTTP Request

GET /v1/assets/

Request Parameters

Name Type Mandatory Description
symbol STRING NO If set to symbol, the result will only symbol.

Response

Field Type Description
symbol STRING
withdrawal_fee STRING
min_deposit_amount STRING

GET Fetch Withdrawal Limits

Request

import requests

url = "https://openapi.onechain.pro/v1/withdrawal_limits/"

res = requests.get(url)
json_res = res.json()
print(json_res)

Response


[
    {
        "user_type": "LOCAL_INDIVIDUAL",
        "time_range": "ONE_DAY",
        "level" : 1,
        "currency_type": "FIAT",
        "amount": "1000.00000000000000000000"
    },
]

Fecth Withdrawal Limits

HTTP Request

GET /v1/withdrawal_limits/

Response

Field Type Description
user_type STRING "LOCAL_INDIVIDUAL", "FOREGIN_INDIVIDUAL"
time_range STRING "ONE_DAY", "AT_ONCE"
level INT 0-6
currency_type STRING "FIAT", "CRYPTO"
amount STRING

GET Fetch TradingPairs

Request

import requests

url = "https://openapi.onechain.pro/v1/trading_pairs/"

res = requests.get(url)
json_res = res.json()
print(json_res)

Response

[
    {
        "symbol": "BTC-USDT",
        "minimum_order_amount": "0.00005000000000000000",
        "orderable_volume_decimal": "0.00010000",
        "orderable_price_decimal": "0.00010000",
    }
]

Fetch All Trading Pairs

HTTP Request

GET /v1/trading_pairs/

Request Parameters

Name Type Mandatory Description
quote_symbol STRING NO

Response

Field Type Description
symbol STRING
minimum_order_amount STRING
orderable_volume_decimal STRING
orderable_price_decimal STRING

GET Fetch TradingPair OrderBooks

Request

import requests

url = "https://openapi.onechain.pro/v1/trading_pairs/orderbook/"

res = requests.get(url)
json_res = res.json()
print(json_res)

Response

{
    "buys": [
        {
            "price": "26565.00000000000000000000",
            "volume": "0.274"
        }
    ],
    "sells": [
                {
            "price": "26565.00000000000000000000",
            "volume": "0.274"
        }
        ]
}

Fetch TradingPair Orderbooks

HTTP Request

GET /v1/trading_pairs/orderbook/

Request Parameters

Name Type Mandatory Description
trading_pair_name STRING YES

Response

Name Type Description
buys Array[Map] Buy Pricies
sells Array[Map] Sell Pricies

Response (buys, sells)

Field Type Description
price STRING
volume STRING

GET Fetch TradingPair Best Price

Request

import requests

url = "https://openapi.onechain.pro/v1/trading_pairs/best/"

res = requests.get(url)
json_res = res.json()
print(json_res)

Response

{
    "best_bid_price": 26565.0,
    "best_ask_price": 26565.0
}

Fecth TradingPair Best Price

HTTP Request

GET /v1/trading_pairs/best/

Request Parameters

Name Type Mandatory Description
trading_pair_name STRING YES

Response

Field Type Description
best_bid_price STRING
best_ask_price STRING

GET Tickers

Request

import requests

url = "https://openapi.onechain.pro/v1/tickers/"

res = requests.get(url)
json_res = res.json()
print(json_res)

Response

[
    {
        "symbol": "BTC-USDT",
        "open_price": "0.00000000000000000000",
        "high_price": "0.00000000000000000000",
        "low_price": "0.00000000000000000000",
        "close_price": "100.00000000000000000000",
        "change": "0",
        "change_price": "0.00000000000000000000",
        "change_rate": "0.00000000000000000000",
        "signed_change_price": "0.00000000000000000000",
        "signed_change_rate": "0.00000000000000000000",
        "trade_volume": "0.00000000000000000000",
        "acc_trade_value_24h": "0.00000000000000000000",
        "acc_trade_volume_24h": "0.00000000000000000000",
    }
]

Fecth All Trading Pair Tickers

HTTP Request

GET /v1/tickers/

Request Parameters

Name Type Mandatory Description
quote_symbol STRING NO

Response

Field Type Description
symbol STRING
open_price STRING
high_price STRING
low_price STRING
close_price STRING
change STRING
change_price STRING
change_rate STRING
signed_change_price STRING
signed_change_rate STRING
trade_volume STRING
acc_trade_value_24h STRING
acc_trade_volume_24h STRING

Private API

GET Fetch Accounts

Request

import requests

url = "https://openapi.onechain.pro/v1/accounts/"
headers = {
  'nonce': 'UUID',
  'signature': 'STRING',
  'api-key': 'STRING'
}
res = requests.get(url, headers=headers)
json_res = res.json()
print(json_res)

Response:

[
    {
        "symbol": "USDT",
        "balance": "0.00000000000000000000",
        "pending_order_amount": "0.00000000000000000000",
        "pending_withdrawal_amount": "0.00000000000000000000",
        "staking_amount": "0.00000000000000000000",
    },
]

Fetch All Accounts of User

HTTP Request

GET /v1/accounts/

Permission

Read

Request Parameters

Name Type Mandatory Description
symbols STRING NO If set to symbol, the result will only symbol.

Response

Field Type Description
symbol STRING
balance STRING
pending_order_amount STRING
pending_withdrawal_amount STRING
staking_amount STRING

GET Fecth Crypto Wallets

Request

import requests

url = "https://openapi.onechain.pro/v1/crypto_wallets/"
headers = {
  'nonce': 'UUID',
  'signature': 'STRING',
  'api-key': 'STRING'
}
res = requests.get(url, headers=headers)
json_res = res.json()
print(json_res)

Response

[
    {
        "network_name": "RIPPLE",
        "symbol": "XRP",
        "min_deposit_amount": "0.00000000000000000000",
        "min_withdrawal_amount": "0.00000000000000000000",
        "withdrawal_fee": "0.00000000000000000000",
                "is_depositable": true,
        "is_withdrawable": true,
    }
]

Fetch Crypto Wallets

HTTP Request

GET /v1/crypto_wallets/

Permission

Read

Request Parameters

Name Type Mandatory Description
symbol STRING NO If set to symbol, the result will only symbol.

Response

Field Type Description
network_name STRING
symbol STRING
min_deposit_amount STRING
min_withdrawal_amount STRING
withdrawal_fee STRING
is_depositable BOOL
is_withdrawable BOOL

GET Fetch Crypto Addresses

Request

import requests

url = "https://openapi.onechain.pro/v1/crypto_addresses/"
headers = {
  'nonce': 'UUID',
  'signature': 'STRING',
  'api-key': 'STRING'
}
res = requests.get(url, headers=headers)
json_res = res.json()
print(json_res)

Response

{
    "network": "RIPPLE",
    "symbol": "XRP",
    "address": "rnJxK4AdiTLXCgaPBuw1zyuEypqJwJUDJ9",
    "memo": "948247417"
}

Fecth Crypto Addresses

HTTP Request

GET /v1/crypto_addresses/

Permission

Read

Request Parameters

Name Type Mandatory Description
symbol STRING YES

Response

Field Type Description
network STRING
symbol STRING
address STRING
memo STRING this field is optional, if not memo response to None

POST Issue Crypto Address

Request

import requests

url = "https://openapi.onechain.pro/v1/crypto_addresses/"
headers = {
  'nonce': 'UUID',
  'signature': 'STRING',
  'api-key': 'STRING'
}
data = {
  "symbol": "XRP",
  "network": "RIPPLE"
}
res = requests.post(url, headers=headers, json=data)
json_res = res.json()
print(json_res)

Response

{
    "network": "RIPPLE",
    "symbol": "XRP",
    "address": "rnJxK4AdiTLXCgaPBuw1zyuEypqJwJUDJ9",
    "memo": "948247417"
}

Issue Crypto Address

HTTP Request

POST /v1/crypto_addresses/

Permission

Trasnfer

Request Parameters

Name Type Mandatory Description
network STRING YES
symbol STRING YES

Response

Field Type Description
network STRING
symbol STRING
address STRING
memo STRING this field is optional, if not memo response to None

GET Fetch Crypto Tasnfers

Request

import requests

url = "https://openapi.onechain.pro/v1/crypto_transfers/"
headers = {
  'nonce': 'UUID',
  'signature': 'STRING',
  'api-key': 'STRING'
}
res = requests.get(url, headers=headers)
json_res = res.json()
print(json_res)

Response

{
    "next": null,
    "previous": null,
    "results": [
        {
            "transfer_type": "DEPOSIT",
            "symbol": "USDT",
            "network_name": "ETHEREUM",
            "transaction_id": null,
            "fee": "0.80000000000000000000",
            "amount": "1000.80000000000000000000",
            "receiver_address": "0xEC56d399A5BA67276390966CAcc213995a24BBac",
                        "sender_address": "0xEC72N5aA5BA67276390966CAcc213995a24Bvm2X",
            "memo": null,
            "crypto_transfer_status": "PENDING",
            "transaction_done_at": null,
            "created": "2023-11-21T01:32:12.488698Z"
        }
    ]
}

Fetch Deposit/Withdrawal Transfers with Pagination.

HTTP Request

GET /v1/crypto_transfers/

Permission

Read

Request Parameters

Name Type Mandatory Description
network STRING NO
type STRING YES "DEPOSIT", "WITHDRAWAL"

Response

Name Type Description
next STRING Next Page
previous STRING Previous Page
results transfers Results (Array)

Response (results)

Field Type Description
transfer_type STRING
symbol STRING
network_name STRING
transaction_id STRING
fee STRING
amount STRING
receiver_address STRING
sender_address STRING
memo STRING this field is optional, if not memo response to None
crypto_transfer_status STRING "PENDING", "FINALIZED", "CANCELLED", "FAIL"
transaction_done_at STRING
created STRING

POST Request Crypto Withdrawal

Request

import requests

url = "https://openapi.onechain.pro/v1/crypto_withdrawals/"
headers = {
  'nonce': 'UUID',
  'signature': 'STRING',
  'api-key': 'STRING'
}
data = {
    "symbol": "XRP",
    "volume": "40",
    "receiver_address": "rnJxK4AdiTLXCgaPBuw1zyuEypqJwJUDJ9",
    "otp_code": "925897",
    "memo": "783548507",
    "network_name": "RIPPLE"
}
res = requests.post(url, headers=headers, json=data)
json_res = res.json()
print(json_res)

Response

{
  "symbol": "XRP",
  "network_name": "RIPPLE",
  "receiver_address": "rnJxK4AdiTLXCgaPBuw1zyuEypqJwJUDJ9",
  "memo": "783548507",
  "transaction_id": "E8A5CD93A3CD7D7F217A6D1A2D621991EF43E890E55965FE4F5C75BEF071E357",
  "volume": "40.00000000000000000000",
  "fee": "0.00000000000000000000",
  "created": "2023-11-21T02:20:58.578Z"
}

Request Crypto Withdrawal

HTTP Request

POST /v1/crypto_withdrawals/

Permission

Transfer

Request Parameters

Name Type Mandatory Description
symbol STRING YES
volume STRING YES
receiver_address STRING YES
otp_code STRING YES
memo STRING YES
network_name STRING YES

Response

Field Type Description
symbol STRING
network_name STRING
receiver_address STRING
memo STRING this field is optional, if not memo response to None
transaction_id STRING
volume STRING
fee STRING
created STRING

GET Fetch Orders

Request

import requests

url = "https://openapi.onechain.pro/v1/orders/"
headers = {
  'nonce': 'UUID',
  'signature': 'STRING',
  'api-key': 'STRING'
}
res = requests.get(url, headers=headers)
json_res = res.json()
print(json_res)

Response


{
    "next": null,
    "previous": null,
    "results": [
        {
                "uuid": "0102be88-b51b-489c-b328-41b4bd7a8389",
                "symbol": "BTC-USDT",
                "side": "BUY",
                "volume": "0.00000000000000000000",
                "price": "0.00000000000000000000",
                "stop_price": "0.00000000000000000000",
                "amount": "0.00000000000000000000",
                "volume_filled": "0.00000000000000000000",
                "volume_remaining": "0.00000000000000000000",
                "order_status": "PENDING",
                "order_type": "LIMIT",
                "created": "2023-11-21T03: 01: 54.676096Z",
            }
    ]
}

Fetch All Orders of User With Pagination.

HTTP Request

GET /v1/orders/

Permission

Read

Request Parameters

Name Type Mandatory Description
state STRING NO "WAIT", "DONE", "CANCEL"
trading_pair_name STRING NO

Response

Name Type Description
next STRING Next Page
previous STRING Previous Page
results orders Results (Array)

Response (results)

Field Type Description
uuid STRING
symbol STRING
side STRING "BUY", "SELL"
volume STRING
price STRING
stop_price STRING
amount STRING
volume_filled STRING
volume_remaining STRING
order_status STRING "PENDING", "PLACED", "PARTIALLY_FILLED", "CANCELLED", "FILLED", "REJECTED"
order_type STRING "LIMIT", "MARKET", "STOP_LIMIT", "STOP"
created STRING

GET Fetch Order Detail

Request

import requests

ORDER_UUID = "0102be88-b51b-489c-b328-41b4bd7a8389"

url = f"https://openapi.onechain.pro/v1/orders/{ORDER_UUID}/"
headers = {
  'nonce': 'UUID',
  'signature': 'STRING',
  'api-key': 'STRING'
}
res = requests.get(url, headers=headers)
json_res = res.json()
print(json_res)

Response


{
    "uuid": "0102be88-b51b-489c-b328-41b4bd7a8389",
    "symbol": "BTC-USDT",
    "side": "BUY",
    "volume": "0.00000000000000000000",
    "price": "0.00000000000000000000",
    "stop_price": "0.00000000000000000000",
    "amount": "0.00000000000000000000",
    "volume_filled": "0.00000000000000000000",
    "volume_remaining": "0.00000000000000000000",
    "order_status": "PENDING",
    "order_type": "LIMIT",
    "created": "2023-11-21T03: 01: 54.676096Z",
}

Fecth Detail Order

HTTP Request

GET /v1/orders/{UUID}/

Permission

Read

Request Parameters

Name Type Mandatory Description
state STRING NO "WAIT", "DONE", "CANCEL"
trading_pair_name STRING NO

Response

Field Type Description
uuid STRING
symbol STRING
side STRING 'BUY', 'SELL'
volume STRING
price STRING
stop_price STRING
amount STRING
volume_filled STRING
volume_remaining STRING
order_status STRING 'PENDING', 'PLACED', 'PARTIALLY_FILLED', 'CANCELLED', 'FILLED', 'REJECTED'
order_type STRING 'LIMIT', 'MARKET', 'STOP_LIMIT', 'STOP'
created STRING

POST Place Order

Request(LIMIT Order)

import requests

url = f"https://openapi.onechain.pro/v1/orders/"
headers = {
  'nonce': 'UUID',
  'signature': 'STRING',
  'api-key': 'STRING'
}
data = {
    "trading_pair": "BTC-USDT",
    "side": "BUY",
    "price": "45652",
    "volume": "0.01",
    "order_type": "LIMIT"
}
res = requests.post(url, headers=headers, json=data)
json_res = res.json()
print(json_res)

Request (MARKET Order)

import requests

url = f"https://openapi.onechain.pro/v1/orders/"
headers = {
  'nonce': 'UUID',
  'signature': 'STRING',
  'api-key': 'STRING'
}
data = {
    "trading_pair": "BTC-USDT",
    "side": "SELL",
    "amount": "456.52",
    "order_type": "MARKET"
}
res = requests.post(url, headers=headers, json=data)
json_res = res.json()
print(json_res)

Response


{
    "uuid": "0102be88-b51b-489c-b328-41b4bd7a8389",
    "symbol": "BTC-USDT",
    "side": "BUY",
    "volume": "0.00000000000000000000",
    "price": "0.00000000000000000000",
    "stop_price": "0.00000000000000000000",
    "amount": "0.00000000000000000000",
    "volume_filled": "0.00000000000000000000",
    "volume_remaining": "0.00000000000000000000",
    "order_status": "PENDING",
    "order_type": "LIMIT",
    "created": "2023-11-21T03: 01: 54.676096Z",
}

Place Order for a specific trading pair

HTTP Request

POST /v1/orders/

Permission

Trade

Request Parameters(Body)

Name Type Mandatory Description
trading_pair STRING YES
side STRING YES
price STRING NO LIMIT Order Required
volume STRING NO LIMIT Order Required
order_type STRING YES
amount STRING NO MARKET Order Required

Response

Field Type Description
uuid STRING
symbol STRING
side STRING 'BUY', 'SELL'
volume STRING
price STRING
stop_price STRING
amount STRING
volume_filled STRING
volume_remaining STRING
order_status STRING 'PENDING', 'PLACED', 'PARTIALLY_FILLED', 'CANCELLED', 'FILLED', 'REJECTED'
order_type STRING 'LIMIT', 'MARKET', 'STOP_LIMIT', 'STOP'
created STRING

DELETE Cancel Order

Request

import requests

ORDER_UUID = "0102be88-b51b-489c-b328-41b4bd7a8389"
url = f"https://openapi.onechain.pro/v1/orders/{ORDER_UUID}"
headers = {
  'nonce': 'UUID',
  'signature': 'STRING',
  'api-key': 'STRING'
}
res = requests.delete(url, headers=headers)
print(res.text)

Cancel Order

HTTP Request

DELETE /v1/orders/{UUID}/

Permission

Trade

Returns HTTP status 200 on a successful order cancellation.

If send the request for an order that has already been cancelled, then HTTP status 204 is returned.

DELETE Cancel All Orders

Request

import requests

url = f"https://openapi.onechain.pro/v1/orders/cancel_all/"
headers = {
  'nonce': 'UUID',
  'signature': 'STRING',
  'api-key': 'STRING'
}
res = requests.delete(url, headers=headers)
print(res.text)

Cancel All Orders

HTTP Request

DELETE /v1/orders/cancel_all/

Permission

Trade

GET Fetch Trainsaction Histories

Request

import requests

url = "https://openapi.onechain.pro/v1/transaction_histories/"
headers = {
  'nonce': 'UUID',
  'signature': 'STRING',
  'api-key': 'STRING'
}
res = requests.get(url, headers=headers)
json_res = res.json()
print(json_res)

Response

{
    "next": null,
    "previous": null,
    "results": [
        {
            "transaction_type": "BUY",
            "base_symbol": "XRP",
            "quote_symbol": "USDT",
            "volume": "25.00000000000000000000",
            "price": "0.00000000000000000000",
            "order_price": "0.00000000000000000000",
            "amount": "0.00000000000000000000",
            "fee": "0.00000000000000000000",
            "transaction_created": "2023-11-14T09:51:39.026656Z",
            "ordered_at": "2023-11-14T09:51:39.026659Z"
        }
    ]
}

Fecth All Transaction Histories of User With Pagination

HTTP Request

GET /v1/transaction_histories/

Permission

Read

Request Parameters

Name Type Mandatory Description
transaction_type STRING NO 'BUY', 'SELL', 'DEPOSIT', 'WITHDRAW', 'GIVEOUT', 'TAKEAWAY'
trading_pair_name STRING NO

Response

Name Type Description
next STRING Next Page
previous STRING Previous Page
results transaction_histories Results (Array)

Response

Field Type Description
transaction_type STRING 'BUY', 'SELL', 'DEPOSIT', 'WITHDRAW', 'GIVEOUT', 'TAKEAWAY'
base_symbol STRING
quote_symbol STRING
volume STRING
price STRING
order_price STRING
amount STRING
fee STRING
transaction_created STRING
ordered_at STRING

GET Fetch Token

Request

import requests

url = "https://openapi.onechain.pro/v1/stream/tokens/"
headers = {"api-key": "11c3e0ea78259ca8a47cb7238fa263d30e7e31184372d6bc"}
res = requests.get(url, headers=headers)
json_res = res.json()
print(json_res)

Response

{
    "token": "607499c1-0927-4c9c-80aa-6b94b67006f7",
    "expiration_time": "2023-12-07T08:54:15.994601Z",
}

Fetch Stream Token of User

HTTP Request

GET /v1/stream/tokens/

Headers

Field Type Description
authorization STRING Login Access Token

Response

Field Type Description
token STRING
expiration_time STRING

POST Issue Token

Request

import requests

url = "https://openapi.onechain.pro/v1/stream/tokens/"
headers = {"api-key": "11c3e0ea78259ca8a47cb7238fa263d30e7e31184372d6bc"}

res = requests.post(url, headers=headers)
json_res = res.json()
print(json_res)

Response

{
    "token": "0d1d40cd-8ecd-4c6d-bfdf-21759f010326",
    "expiration_time": "2023-12-07T09:07:08.469046Z",
}

Issue Stream Token or extend validity

HTTP Request

POST /v1/stream/tokens/

Headers

Field Type Description
authorization STRING Login Access Token

Response

Field Type Description
token STRING
expiration_time STRING

DELETE Token

Request

import requests

token = "0102be88-b51b-489c-b328-41b4bd7a8389"
url = f"https://openapi.onechain.pro/v1/stream/tokens/{token}"
headers = {"api-key": "11c3e0ea78259ca8a47cb7238fa263d30e7e31184372d6bc"}
res = requests.delete(url, headers=headers)
print(rex.text)

Delete Stream Token

HTTP Request

DELETE /v1/stream/tokens/{token}/

Headers

Field Type Description
authorization STRING Login Access Token

Errors

User Exceptions

Error Code Meaning
2124 Register Otp First

Accounts Exceptions

Error Code Meaning
3000 Balance is not enough.
3001 Withdrawal amount exceeds current balance.
3002 User already has a warm wallet for this account
3018 Volume is less than minimum withdrawal amount
3022 Negative Value Not Allowed
3023 Not Supported Crypto Asset.
3030 Withdrawal Not Available
3033 Withdrawal Amount Exceeds Overdraft Limit
3036 Withdraw Forbidden for blacklisted user
3046 Problem with your accounts
3047 Decimal Bigger Than Should Be

Trade Exceptions

Error Code Meaning
4000 Price is 0 or negative
4001 Input price is wrong based on unit price.
4004 The minimum order amount is not met.
4005 Trading Pair Is Not Available Yet.
4009 Is Not Available Value
4011 State Not Found
4012 Given Order Type Is Not Supported
4013 Volume Provided in Order is Out of Allowed Decimal Place

Withdrawal Exceptions

Error Code Meaning
5003 Withdrawal XRP request Must Contain Valid DestinationTag

Wallet Exceptions

Error Code Meaning
8006 Invalid Wallet Address
8008 Withdrawal To Own Wallet Not Allowed

OpenAPI Exceptions

Error Code Meaning
20000 Wrong Permission
20010 API Key Is Expired
20011 IP Is Not Whitelisted
20012 Signature Not Correct
20013 Nonce Is Already Used
20015 API Key Not Existent
20016 API Key Not In Header
20017 Nonce Cannot Be Null
20018 Signature Cannot Be Null
20019 OpenAPI Forbidden For BlackListed User