API


What is an API?

BTCXIndia’s Application Programming Interface (API) allows our clients to access and control their accounts using custom software.

PUBLIC DATA FUNCTIONS

TICKER

Access at https://api.btcxindia.com/ticker/


• BTC _INR                      –  Bitcoin to Indian Rupee

• high                               –  Today’s high price

• low                                 –  Today’s low price

• avg                                –  Today’s average price

• total_volume_24h          –  Total volume for the last 24 hours

• current_volume             –   Last traded volume

• last_traded_price          –   Last traded price

• bid                                 –  Highest buy order

• ask                                –   Lowest sell order

• last_traded_time           –   Last traded time in Indian standard time( IST)


HOURLY TICKER

Access at https://api.btcxindia.com/ticker_hour/

Returns a JSON dictionary code, the same as at https://api.btcxindia.com/ticker/, but calculated values are from within an hour.

ORDER BOOK

Access at https://api.btcxindia.com/order_book/

Returns JSON dictionary with "bids" and "asks".

Each is a list of open orders and each order is represented as a list of amounts, price and number of orders.

Example:

{ "timestamp":1441437690, //Indian Standard Time "bids": ["0.5", "16200", 1 ],"asks": ["4.6", "16300", 5]}


TRADES

Access at https://api.btcxindia.com/trades

Returns a JSON dictionary with "time stamp" ,"trade­ id", “volume” and “price”.

Example:

[{"time":"2015-09-05 13:09:38","trade_id":"a23ec8ae2fed6aeb1b10deaa9b2f5b605a9cb01c","volume":"0.5","price":"15000"}]



PRIVATE FUNCTIONS


API AUTHENTICATION

All private API calls require authentication.

You need to provide 3 types of data to authenticate a request:

• API key

• Nonce

• Signature

API KEY

To get an API key, a customer must send a request to support@btcxindia.com. The support team will then issue an API key

NONCE

Nonce is a regular integer number. It must be increasing with every request you make. A common practice is to use unix time for that parameter.

Your nonce must be within 30 seconds of the API service time or your request will be considered expired and rejected.

SIGNATURE

Signature is a HMAC­SHA256 encoded message containing: Nonce, Client ID and API key. The HMAC­SHA256 code must be generated using a secret key; that will be forwarded with your API key.

Example ( NodeJS) :

var nonce = new Date().getTime();

var Data = nonce + APIkey + Client ID;

var hmac = crypto.createHmac('sha256', Secrete key);

var signature= hmac.update(Data).digest('base64');



ACCOUNT BALANCE

Access at https://api.btcxindia.com/ac_balance/

Paramaters:

• key                  - API key

• signature         - Signature

• nonce              - Nonce

Returns JSON dictionary:

Status                - Success/error*

inr                      - INR balance

btc                     - BTC balance

pending_btc      - Sell Volume(BTC)

pending_inr       - Buy Volume(INR)

trade_fee          - Trade fee in %

*error                 - error message



MY PENDING ORDERS

Access at https://api.btcxindia.com/my_pending_orders/

Paramaters:

• key                  - API key

• signature         - Signature

• nonce              - Nonce

Returns JSON dictionary:

time                      - Order Tme stamp

order_id               - Order ID

order_type           - Buy or Sell

volume                 - BTC Volume

inr_btc                 - 1 BTC Price in INR



CANCEL ORDER

Access at https://api.btcxindia.com/cancel_order/

Paramaters :

• key                  -  API key

• signature         - Signature

• nonce              - Nonce

• order_id          - Order ID


Returns status message 'success' if order has been found and canceled.

After, you will also receive the message 'Your order has been cancelled'



TRADE

Access at https://api.btcxindia.com/trade/

Paramaters:

• key                  - API key

• signature         - Signature

• nonce              - Nonce

• type                 - buy (or) sell

• volume            - Bitcoin Volume

• price                - 1 BTC Price in INR


Returns status message 'success' if sufficient funds in the wallet



TRANSACTIONS

Access at https://api.btcxindia.com/transactions/

Paramaters:

• key                  -  API key

• signature         - Signature

• nonce              - Nonce

• type                 - trade (or) deposit (or) withdrawal

Returns JSON dictionary:

(If type is trade)

time                   - Order match time stamp*

transaction_id   - Transaction ID

type                   - bought ( or) sold

btc                     - Order volume in BTC

inr_btc               - 1 BTC Price in INR

order_amount   - btc*inr_btc //example: if 1 btc price is INR 15000 and bought 0.5 btc then it will return
                                                               INR 7500

commission       - Trade fee

net_amount       - if bought order_amount+commission ; if sold order_amounnt-commission

(If type is deposit, Returns)

time                   - Order match time stamp*

transaction_id   - Transaction ID

type                   - BTC ( or) INR

amount              - Amount in BTC (or) INR

(If type is withdrawal, Returns)

time                       - Order match time stamp*

transaction_id       - Transaction ID

type                       - BTC ( or) INR

amount                  - Amount in BTC (or) INR

withdrawl_address - receive address     // if withdrawal in BTC

tx_id                       - Block chain Transaction     // if withdrawal in BTC



WITHDRAWAL INITIATE

Access at https://api.btcxindia.com/withdrawal_initiate/

Paramaters :

• key                  - API key

• signature         - Signature

• nonce              - Nonce

• type                 - BTC (or) INR

• amount            - Amount to withdraw

• address           - Bitcoin address if withdrawal is in BTC

Returns JSON dictionary:

Return status message 'verified' if balance is available

Also, returns message 'Withdrawal code has been forwarded to your mobile.'



WITHDRAWAL CONFIRM

Access at https://api.btcxindia.com/withdrawal_confirm/

Paramaters:

• key                        - API key

• signature              - Signature

• nonce                   - Nonce

• withdrawal_code   - Enter code sent to mobile

Returns JSON dictionary:

Return status ' success' if code is valid.



WALLET

Access at https://api.btcxindia.com/wallet/

Params:

• key                  - API key

• signature         - Signature

• nonce              - Nonce

• type                 - btc (or) inr

Returns JSON dictionary:

wallet_ address  - IIf order type is BTC, wallet address will be shown

bank_name        - Bank Name - If order type is INR

bank_account    - Bank Account Number

bank_ifsc           - IFSC Code

branch               - Bank Branch

ac_type             - Account Type



WEBSOCKET

WHAT IS WEBSOCKET?

WebSocket is a protocol providing full­ duplex communications channels over a single TCP connection.

HOW TO CONNECT?

BTCXIndia uses socket.io for real time websocket streaming.

You can find an example for each stream below.


LIVE TRADES

EVENT: live_trades

JSON dictionary:

date        - trade time stamp

volume    - trade volume

price        - trade price in btcinr

Examle : live_trades.html

LIVE ORDER BOOK

EVENTS: buy_orders

                sell_orders

JSON dictionary:

date        - trade time stamp

volume    - trade volume

price       - trade price in btcinr

Examle : live_order_book.html