API Documentation
Our API allows you to programmability interact with our exchange system. This documentation is for our REST API.
We also have a Websocket API available for realtime trade and orderbook data.
The API is divided into two sections
- Public API: Which allows anyone to lookup market data about the exchange; such as rates, order book volume, etc...
- Private API: Which requires users to have an account with us; the private API allows users to interact with their account; such look balance inquiry, place orders, canceling orders, viewing history, etc...
Public API
To use the public API no authentication is required; simply access any of the public API URLs and JSON encode data will be returned.
Market Data (Ticker)
GET: https://bx.in.th/api/
Returns a list of all currency pairings including:
- primary_currency
- secondary_currency
- last_price
- volume_24hours
- orderbook
Currency Pairings
GET: https://bx.in.th/api/pairing/
Returns a list of all available currency pairings, including their "pairing_id" which is required for some API calls. Will also include the minimum order amount for primary and secondary currency in each pairing market.
Order Book (Full)
GET: https://bx.in.th/api/orderbook/?pairing={pairing_id}
Example: https://bx.in.th/api/orderbook/?pairing=1
Returns a list of all buy and sell orders in the order book for the selected pairing market.
Recent Trades
GET: https://bx.in.th/api/trade/?pairing={pairing_id}
Example: https://bx.in.th/api/trade/?pairing=1
Returns a list of 10 most recent trades, and top 10 asks and bids in orderbook
Historical Trade Data
GET: https://bx.in.th/api/tradehistory/?pairing={pairing_id}&date={date}
Example: https://bx.in.th/api/tradehistory/?pairing=1&date=2014-10-21
Returns Weighted Average, Volume, Open, Close, Low and High prices for the specified date.
Private API
To use the private API you must generate an API Key in your account area. Each API key generated will have an "API Key" and an "API Secret".
Every query to the private API must include the following POSTed fields:
key
- API Keynonce
- Noncesignature
- Signaturetwofa
- 2Factor Auth. Code *
API Key
The API Key in found in the "API Key" column when you generate your API keys.
Nonce
This is an integer value that must increase with every API call you make, for example if your first API call uses nonce=1
then the next API call must use a nonce
of 2 or greater
A common practice is to use unix time for that parameter.
Signature
A SHA-256 hash of the following data api_key + nonce + api_secret
A PHP example:
$signature = hash('sha256',$api_key.$nonce.$api_secret);
2Factor Auth. Code
Only required if you have enabled two factor authentication on the API key
Create Order
POST: https://bx.in.th/api/order/
POSTed fields (in addition to the standard key
, nonce
, signature
fields:
Field | Description | Possible Values | |
---|---|---|---|
Required | pairing |
Currency pairing ID | int Example: BTC/LTC trades using "2" |
Required | type |
Order type | buy / sell |
Required | amount |
Amount in primary currency for buy order Amount in secondary currency for sell order |
float |
Required | rate |
Exchange rate | float |
Returned JSON values:
Field | Description | Possible Values |
---|---|---|
success |
Order placement was successful | true / false |
order_id |
Order ID number (if order is immediately executed order ID will be 0) | int |
history_id |
History Order ID which will be unique across all order books | int |
error |
If success is false; this is the reason | string |
Cancel Order
POST: https://bx.in.th/api/cancel/
POSTed fields (in addition to the standard key
, nonce
, signature
fields:
Field | Description | Possible Values | |
---|---|---|---|
Required | pairing |
Currency pairing ID | int Example: BTC/LTC trades using "2" |
Required | order_id * |
Order ID number | int or string |
* If you want to cancel multiple orders include them in the "order_id" field as comma separated string (Example: order_id=1,4,9 ). Limit of 10 orders per cancelation request
Returned JSON values:
Field | Description | Possible Values |
---|---|---|
success |
Order cancellation was successful | true / false |
error |
If success is false; this is the reason | string |
Get Balances
POST: https://bx.in.th/api/balance/
POST only the standard authentication fields key
, nonce
, signature
Returned JSON values (for each currency)
available
- Available balancetotal
- Total balance (including orders, pending withdrawals and pending deposits)orders
- Open orders balancewithdrawals
- Pending withdrawals balancedeposits
- Pending deposits balance
Get Orders
POST: https://bx.in.th/api/getorders/
POSTed fields (in addition to the standard key
, nonce
, signature
fields:
Field | Description | Possible Values | |
---|---|---|---|
Optional | pairing |
Currency pairing ID | int Example: BTC/LTC trades using "2" |
Optional | type |
Order type | buy / sell |
Returned JSON values (for each order):
Field | Description | Possible Values |
---|---|---|
pairing_id |
Currency Pairing ID | int |
order_id |
Order ID number | int |
order_type |
Order type | buy / sell |
amount |
Order Amount | float |
rate |
Order Exchange Rate | float |
date |
Date order was placed | datetime |
Transaction History
Get your own balance affecting transaction history, such as trades, withdrawals and deposits.
POST: https://bx.in.th/api/history/
POSTed fields (in addition to the standard key
, nonce
, signature
fields:
Field | Description | Possible Values | |
---|---|---|---|
Optional | currency |
Only transactions for this currency | string Example: BTC |
Optional | type |
Transaction type | trade / fee / deposit / withdraw |
Optional | start_date |
Only transactions after this date | datetime YYYY-mm-dd H:i:s |
Optional | end_date |
Only transactions before this date | datetime YYYY-mm-dd H:i:s |
Returned JSON values (for each transaction):
Field | Description | Possible Values |
---|---|---|
transaction_id |
Unique transaction ID | int |
currency |
Transaction currency | string |
amount |
Transaction Amount | float |
date |
Transaction Date | datetime |
type |
Transaction Type | trade / fee / deposit / withdrawal |
ref_id |
Can be used to link history items | int |
Get Deposit Address
POST: https://bx.in.th/api/deposit/
POSTed fields (in addition to the standard key
, nonce
, signature
fields:
Field | Description | Possible Values | |
---|---|---|---|
Required | currency |
3 letter currency code | string Example: BTC |
Optional | new |
Generate a new address | true / false |
Returned JSON values:
address
Request Withdrawal
POST: https://bx.in.th/api/withdrawal/
POSTed fields (in addition to the standard key
, nonce
, signature
fields:
Field | Description | Possible Values | |
---|---|---|---|
Required | currency |
3 letter currency code | string |
Required | amount |
Amount to withdraw | float |
Required for crypto | address |
Address for crypto-withdrawals | string |
Required for fiat | bank_id |
Bank ID (found here) | string |
Returned JSON values:
Field | Description | Possible Values |
---|---|---|
success * |
Withdrawal was successfully placed | true / false |
withdrawal_id |
Withdrawal ID number | int |
error |
If success is false; this is the reason | string |
* Successful withdrawal means that the withdrawal was successfully added to queue for processing. It does not mean the transaction has been broadcast to the blockchain yet
Withdrawal History
POST: https://bx.in.th/api/withdrawal-history/
POST only the standard authentication fields key
, nonce
, signature
Returned JSON values (for each withdrawal)
withdrawal_id
- Unique ID of withdrawaldate_requested
- Date/time of withdrawl requestwithdrawal_status
- Status of withdrawal (Pending, Canceled, Completed)amount
- Amount of withdrawalcurrency
- Currency code of withdrawaladdress
- Address withdrawal was sent totransaction_id
- External network transaction ID, for example Bitcoin Transaction ID
Private Bill Payment API
List Bill Payment Types/Groups
POST: https://bx.in.th/api/billgroup/
POST only the standard authentication fields key
, nonce
, signature
Returned JSON values (for each payment group type)
id
- Unique ID of payment group typename
- Name of the payment group type
List Bill Payment Service Providers
POST: https://bx.in.th/api/biller/
POSTed fields (in addition to the standard key
, nonce
, signature
fields:
Field | Description | Possible Values | |
---|---|---|---|
Required | group_id |
Unique ID of payment group type | int |
Returned JSON values (for each service provider)
id
- Unique ID of service providername
- Name of the service providerfee
- Fee associated with service provider (possible float value or % percent value)amount
- If service provider requires specific payment amounts only this will contain an array of values
Create Bill Payment
Note that bill payment requests behave in the same way as a withdrawal and status can be checked using the withdrawal history API
POST: https://bx.in.th/api/billpay/
POSTed fields (in addition to the standard key
, nonce
, signature
fields:
Field | Description | Possible Values | |
---|---|---|---|
Required | biller |
Service provider ID from biller API list | int |
Required | amount |
Amount to payment | float |
Required | account |
Phone number or Account # for payment | string |
Returned JSON values:
Field | Description | Possible Values |
---|---|---|
success * |
Withdrawal was successfully placed | true / false |
withdrawal_id |
Withdrawal ID number | int |
error |
If success is false; this is the reason | string |
Public Options API
Get Available Options
GET: https://bx.in.th/api/options/?pairing={pairing_id}&date={YYYY-mm-dd}
Example: https://bx.in.th/api/options/?pairing=1&date=2014-10-31
NOTE: The date must be a valid future option expiration date (should a Friday in the future)
Returns all Calls and Puts expiring on the specific date.
Returned JSON values (for each option):
Field | Description | Possible Values |
---|---|---|
strike |
Strike price | float |
volume |
Volume amount | float |
expire |
Expiration Date | date (YYYY-mm-dd) |
qty |
Quantity | int |
bid |
Highest Bid | float (or null) |
ask |
Lowest Ask | float |
ids |
Unique IDs for each individual option | comma separated int |
Options Orderbook
GET: https://bx.in.th/api/optionbook/?id={option_id}
Example: https://bx.in.th/api/optionbook/?id=203
The id
field should be populated with an option ID returned in the ids
field of the Get Available Options API call
Returns all bid and ask orders for the option bucket.
Returned JSON values (for each order):
Field | Description | Possible Values |
---|---|---|
option_id |
Unique option ID | int |
pairing_id |
Currency Pairing ID | int |
option_type |
1 = Call, 2 = Put | int |
strike |
Strike price | float |
volume |
Volume amount | float |
expire |
Expiration Date | date (YYYY-mm-dd) |
qty |
Quantity | int |
price_type |
Bid or Ask | bid ask |
price |
Ask/Bid price | float |
Private Options API
Issue Option
All private option API calls must be authenticated in the same way described in the Private API section above
POST: https://bx.in.th/api/option-issue/
POSTed fields (in addition to the standard key
, nonce
, signature
fields:
Field | Description | Possible Values | |
---|---|---|---|
Required | pairing |
Currency pairing ID | int Example: BTC/LTC pairing = "2" |
Required | type |
Option type | call / put |
Required | strike |
Option strike price (Primary Currency) | float |
Required | volume |
Option volume (Secondary Currency) | float |
Required | qty |
Number of options to issue | int |
Required | expire |
Option Expiration | date (YYYY-mm-dd) |
Required | ask |
Asking price (Primary Currency) | float |
Returned JSON values:
Field | Description | Possible Values |
---|---|---|
success |
Option issuance was successful | true / false |
option_id |
Unqiue ID of the option | int |
error |
If success is false; this is the reason | string |
Bid on Option
Cancel option function can be used to cancel any option you have listed for sale, or any open bids
POST: https://bx.in.th/api/option-bid/
POSTed fields (in addition to the standard key
, nonce
, signature
fields:
Field | Description | Possible Values | |
---|---|---|---|
Required | option_id |
Unique Option ID | int |
Required | bid |
Bid Price (Primary Currency) | int |
Required | qty |
Number of options to buy | int |
Optional | fill_kill |
Fill all order or kill it | false (default) / true |
Returned JSON values:
Field | Description | Possible Values |
---|---|---|
success |
Option cancellation was successful | true / false |
filled |
IDs of filled bids | array |
open |
IDs of open bids | array |
error |
If success is false; this is the reason | string |
Sell an Option / Change Ask Price
Sell an option function is used to put an option, that you own, back up for sale
This function can also be used to change the ask price of issuance
POST: https://bx.in.th/api/option-sell/
POSTed fields (in addition to the standard key
, nonce
, signature
fields:
Field | Description | Possible Values | |
---|---|---|---|
Required | option_id |
Unique Option ID | int |
Required | ask |
Ask Price (Primary Currency) | int |
Returned JSON values:
Field | Description | Possible Values |
---|---|---|
success |
Option cancellation was successful | true / false |
sold |
Was option sold (or remains open for sale) | true / false |
error |
If success is false; this is the reason | string |
Get My Issuances
POST: https://bx.in.th/api/option-myissue/
POSTed fields (in addition to the standard key
, nonce
, signature
fields:
Field | Description | Possible Values | |
---|---|---|---|
Required | pairing |
Currency pairing ID | int Example: BTC/LTC pairing = "2" |
Optional | expire |
Expiration Date | date (YYYY-mm-dd) |
Optional | type |
Option Type | call put |
Returned JSON values (for each option):
Field | Description | Possible Values |
---|---|---|
pairing_id |
Pairing ID | int |
type |
Option Type | call put |
option_id |
Unique ID for option | int |
strike |
Strike price | float |
volume |
Volume amount | float |
expire |
Expiration Date | date (YYYY-mm-dd) |
status |
Current Status | open sold exercised expired canceled |
price |
Ask/Sold price | float |
Get My Bids
POST: https://bx.in.th/api/option-mybid/
POSTed fields (in addition to the standard key
, nonce
, signature
fields:
Field | Description | Possible Values | |
---|---|---|---|
Required | pairing |
Currency pairing ID | int Example: BTC/LTC pairing = "2" |
Optional | expire |
Expiration Date | date (YYYY-mm-dd) |
Optional | type |
Option Type | call put |
Returned JSON values (for each option):
Field | Description | Possible Values |
---|---|---|
pairing_id |
Pairing ID | int |
option_id |
Unique ID for option | int |
strike |
Strike price | float |
volume |
Volume amount | float |
expire |
Expiration Date | date (YYYY-mm-dd) |
status |
Current Status | open expired cancel |
price |
Bid price | float |
Get My Options
POST: https://bx.in.th/api/option-myoptions/
POSTed fields (in addition to the standard key
, nonce
, signature
fields:
Field | Description | Possible Values | |
---|---|---|---|
Required | pairing |
Currency pairing ID | int Example: BTC/LTC pairing = "2" |
Optional | expire |
Expiration Date | date (YYYY-mm-dd) |
Optional | type |
Option Type | call put |
Returned JSON values (for each option):
Field | Description | Possible Values |
---|---|---|
pairing_id |
Pairing ID | int |
option_id |
Unique ID for option | int |
strike |
Strike price | float |
volume |
Volume amount | float |
expire |
Expiration Date | date (YYYY-mm-dd) |
status |
Current Status | for sale exercisable exercised expired canceled |
price |
Price Paid | float |
ask |
Sale ask price | float |
bid |
Highest bid | float |
Exercise Options
POST: https://bx.in.th/api/option-exercise/
POSTed fields (in addition to the standard key
, nonce
, signature
fields:
Field | Description | Possible Values | |
---|---|---|---|
Required | option_id |
Unique Option ID | int |
Returned JSON values:
Field | Description | Possible Values |
---|---|---|
success |
Option exercise was successful | true / false |
error |
If success is false; this is the reason | string |
Cancel Option Sale or Bid
Cancel option function can be used to cancel any option you have listed for sale, or any open bids
POST: https://bx.in.th/api/option-cancel/
POSTed fields (in addition to the standard key
, nonce
, signature
fields:
Field | Description | Possible Values | |
---|---|---|---|
Required | option_id |
Unique Option/Bid IDs | int comma separated list for multiple |
Returned JSON values:
Field | Description | Possible Values |
---|---|---|
success |
Option cancellation was successful | true / false |
error |
If success is false; this is the reason | string |
Get Option History
Get the general option trading history on your account
POST: https://bx.in.th/api/option-history/
POSTed fields (in addition to the standard key
, nonce
, signature
fields:
Field | Description | Possible Values | |
---|---|---|---|
Required | pairing |
Currency pairing ID | int Example: BTC/LTC pairing = "2" |
Returned JSON values (for each history line):
Field | Description | Possible Values |
---|---|---|
action |
History Action | Bought Sold Exercised Issued Canceled |
option_type |
Option Type | call put |
qty |
Quantity of options | int |
price |
Ask/Sold Price | float |
strike |
Strike price | float |
volume |
Volume amount | float |
date |
Action Date | date (YYYY-mm-dd) |
Example PHP API Class
Download on Github: https://github.com/bitcoincoltd/bitexthai/