Introduction

Zebpay Build is a platform on the top of which users can create their own applications, similar to Zebpay or any other cryptocurrency trading applications. Developers can even create trading bots using Zebpay Build. Users can also build other types of applications(console/web/API) using our platform and can: Buy and sell digital currencies. Import transactions details on open and closed orders, past trade history. Integrate live price charts of bitcoin, ether and other altcoins. Fetch detailed information like volume, last trade, spread for each coin. Create crypto portfolio of digital assets. Build a customized watchlist. Set alerts basis change in percentage in custom interval. Sync wallet balance and create a wallet overview.

All Market and Trading related data/methods is available at this time through REST-ful API.

General

General Trading Overview and Zebpay Build details.

Getting started

Overview and general information about the Zebpay Build API's.

Requests

All our API requests and responses are application/json content type and follow typical HTTP response status codes for success and failure. All API requests are called by the standard HTTPS. All POST calls need to specify the parameters of the format to x-www-form-urlencoded.

Success

A successful response is indicated by HTTP status code 200 and may contain an optional body. If the response has a body it will be documented under each API.

Error Handling

Unless otherwise stated, errors to bad requests will respond with HTTP 4xx or status codes. The body will also contain a message parameter indicating the cause. Your language's http library should be configured to provide message bodies for non-2xx requests so that you can read the message field from the body.

Following table gives more details about error code and description.

400

Bad Request – Invalid request format

401

Unauthorized – Invalid API Key

403

Forbidden – You do not have access to the requested resource

404

Not Found

500

Internal Server Error – We had a problem with our server

Rate Limits

When a rate limit is exceeded, a status of 429 Too Many Requests will be returned.

DateTime Format

All our Datetime properties has value as "Unique Timestamp in milliseconds" (Unix time, also known as POSIX time[citation needed] or UNIX Epoch time[1]) is a system for describing a point in time, defined as an approximation of the number of seconds that have elapsed since 00:00:00 Coordinated Universal Time (UTC), Thursday, 1 January 1970.

Consumer can convert the same to any timezone. Please note that, in case your library supports only seconds, divide the value by 1000 before converting to date object.

Pagination Support

We support pagination in the API's which return a list. User has to pass the value parameterized like "?limit=10&page=1". By default system will limit the record to 20, and fetch the latest data.

For example

Tradepair History (/market/{tradepair}/trades).

Get Order (/orders).

Sandbox

A public sandbox is available for testing API connectivity and web trading. The sandbox environment provides all of the functionality of the production exchange and allows you to play around with API.

Login sessions and API keys are separate from production. Use the sandbox web interface to create keys in the sandbox environment.

REST API

https://www.zebpay.co/api/v1

Market REST API

https://www.zebpay.co/pro/v1

Websocket Feed

https://ws-feed.zebapi.com/marketdata

Production

Zebpay Build production environment is available for API connectivity and web trading.

Login sessions and API keys are separate from production.

REST API

https://www.zebapi.com/api/v1

Market REST API

https://www.zebapi.com/pro/v1

Websocket Feed

https://ws-feed.zebapi.com/marketdata

Client Libraries

Client libraries can help you integrate with our API quickly.

Github Repository

Coins (Virtual Currencies)

We supports almost all major/leading Cryptocurrencies, and are adding a new virtual currency every week. Current supported coins are:

BTC

Bitcoin

BCH

Bitcoin Cash

ETH

Etherium

LTC

Litecoin

XRP

Ripple

EOS

EOS

OMG

OmiseGO

TRX

TRON

GNT

Golem

ZRX

0X

REP

Augur

BAT

Basic Attention Token

AE

Aeternity

ZIL

Zilliqa

NCASH

NCASH

KNC

Kyber

IOST

IOSToken

CMT

CyberMiles

TUSD

TrueUSD

BTG

Bitcoin Gold

Authentication

Generating Api Key

You'll need to register your app before getting started.Upon registration you will get following piece of information which need to be remember.

which will be used in the OAuth flow

Client Id

Client Id is unique GUID which need to be provided for authentication.

Client Secret

Unique GUID which need to be provided for authentication.

Api Secret

Api secret key is used to generate the hash signature,by which user will get authenticated.

Subscription Key

This key is used to identify that user is subscribed with the the zebpay in which plan.

Scope Permission

User must restrict the scope of Application.This permission user can select at time of application registration.

Trade:read

Permission to read the trade.

Trade:Create

Permission to execute the trade.

API - Request Headers

All Request must contain the following headers.

Zebpay-Subscription-Key

The Zebpay subscription key, received after creating Application.

client_id

The client Id, received after creating Application.

timestamp

A timestamp for your request, in ticks.

API signature

The base64-encoded SHA256 signature (see details in below section).

Authorization

The bearer token, mandatory for all trade API's.

RequestId

A Unique GUID Request Token (Generate new request id on every request).

Generating API signature

The API signature header is generated by creating a sha256 HMAC using the base64-decoded secret key on the prehash string

                        
                        POST + Seprator(\n) + timestamp +seprator+targeturl+seprator+bodydata+seprator+client_Id:client_Id
                       
                      
( where + represents string concatenation) and base64-encode the output.

The timestamp value is the same as the timestamp in header.

For all authenticated API's we also return a signature back ti the caller in response header with key "x-hmac". The value is hashed using the same API secret key, and response body as payload message. Calling application can use this hashed value to verify if the response is returned from the trusted zebpay server.

Signature Generation

 
                    
                    var separator = "\n";
                    var targetUrl = request.url.trim();
                    var bodyData = "{}";
                    if(request.method == "POST") {
                    bodyData = request.data;
                        }
                    var payLoadMessage = 'POST' + separator + timestamp + separator + targetUrl + separator + bodyData + separator + 'client_Id:' + "xxxx-xxx";
                    var hashValue = CryptoJS.HmacSHA256(CryptoJS.enc.Utf8.parse(payLoadMessage), CryptoJS.enc.Utf8.parse(pm.variables.get("APISecretKey")));
                    var actualHash(APISignature) = CryptoJS.enc.Base64.stringify(hash);
                        
                      

Web Application

Zebpay Build provide a page where developer can register the application as "web". At time of application registration developer need to keep following things in mind:

When creating .net MVC Core application, app.UseAuthentication() should be used for Authentication.

Call Back Url

http://xxxx-baseurl-xxx/signin-oidc

PostLogoutUrl

http://xxxx-baseurl-xxx/signout-callback-oidc

Code Sample for .net MVC Core application (developer should use Authorize attribute on Controller)

             
                    
                  .AddOpenIdConnect("oidc", options => {
                    
options.SignInScheme = "Cookies"; options.Authority = "Auth server Url"; options.RequireHttpsMetadata = true; options.ClientId = "ClientID"; options.ClientSecret = "ClientSecret"; options.ResponseType = "id_token"; options.Events.OnRemoteFailure = OnRemoteFailure; //Mandatory Scopes options.Scope.Add("openid"); options.Scope.Add("profile"); //IMplemented scopes (custom) options.Scope.Add("wallet:transactions:read"); options.Scope.Add("trade:read"); options.Scope.Add("trade:create"); options.SaveTokens = true; options.GetClaimsFromUserInfoEndpoint = true;
});

Backend/Console Application

Zebpay provide a page where developer can register the application as "Console".

Zebpay provides a series of API's for login purpose.

The API's need to be called in a sequence : /login, /verifyotp, /verifypin, /logout. See User API for detail request/response.

After successfull authentication user will get access_token and user can use this access_token to access API.

Market API

These API's returns market details including ticker(s), book (pending orders), trades (executed orders) etc.

Market

Get the list of tickers. Get 24 hr stats for the product. volume is in base currency units. open, high, low are in quote currency units, for all trade pairs.

Request URL

GET /market

Scope

Param

Description

buy

Current Buy Rate

sell

Current Sell Rate

volume

Total Volume with Zebpay at this time

pricechange

Price change

24hoursHigh

Highest Price in last 24 hour.

24hoursLow

Lowest Price in last 24 hour.

pair

Current tradepair

Sample Response

                    
                    [
{ "pair": "", "virtualCurrency": "", "volume": null }, { "buy": "0", "sell": "0", "volume": 0, "pricechange": "0.00", "24hoursHigh": "0", "24hoursLow": "0", "pair": "AE-BTC", "virtualCurrency": "AE", "currency": "BTC" },
... ]

Ticker

Get the ticker information for the current Trade Pair, with daily volume and current Price.

Request URL

GET /market/{tradepair}/ticker

Scope

Param

Description

Tradepair

Example XRP-BTC, ETH-BTC etc..

buy

Current Buy Rate

sell

Current Sell Rate

volume

Total Volume with Zebpay at this time

pricechange

Price change

24hoursHigh

Highest Price in last 24 hour.

24hoursLow

Lowest Price in last 24 hour.

pair

Current tradepair

Sample Response

                    
                        {
"buy": "0", "sell": "0.00050000", "market": "0.0005", "volume": 4.95532, "24hoursHigh": "0.0005", "24hoursLow": "0.0005", "pricechange": "0.00", "pair": "xrp-btc", "virtualCurrency": "xrp", "currency": "btc"
}

Book

Get a list of open orders for a trade pair.

Request URL

GET /market/{tradepair}/book

Scope

Param

Description

Tradepair

Example XRP-BTC, ETH-BTC etc..

asks

List of recent ask's Rates, with Price & Amount.

bids

List of recent bid's Rates, with Price & Amount.

pair

Current tradepair.

Sample Response

                    
                        {
                    
"asks": [ ], "bids": [ { "price": "0.00050000", "amount": 20044680 } ], "pair": "xrp-btc"
}

History

Get the trade History information for the current Trade Pair.

Request URL

GET /market/{tradepair}/trades

Scope

Param

Description

Tradepair

Example XRP-BTC, ETH-BTC etc..

trans_id

Transaction Id maintained uniquely at zebpay.

fill_qty

Total volume at the point of transaction.

fill_price

Price at which the transaction executed.

fill_flags

Ask(1)/Bid(2).

currencyPair

Current tradepair.

lastModifiedDate

Timestamp.

Sample Response

                    
                    [
                    
{ "trans_id": 13, "fill_qty": 1000000, "fill_price": 0.0005, "fill_flags": 1, "currencyPair": "XRP-BTC", "lastModifiedDate": 1538576785865 }
... ]

Trade API

This endpoint can be used to read order data as well as create a new order. You can also cancel your previously placed order.

Place a New Order

User can place limit order and it can be done only when there is sufficient amount of Quote currencies available in the account. On placing order, the amount of quote currency for the given pair will be on hold for the duration of the order.

Request URL

POST /orders

Request parameters
Param

Description

trade_pair

The trade pair must be valid matching product available in the list of pairs for trading. Ex:BTC-INR

side

Side indicates the side at which the order is placed. Bid side indicates a downtick and conversely Ask side indicates the uptick.

size

Size indicates the amount of base currency required to Bid or Ask against the quote currency.

price

The price must be specified in the minimum order tick price. For the BTC/TUSD product the minimum order tick price is 0.01. Prices lesser than the minimum tick will not be accepted.

Responses
Param

Description

id

Order id

price

The price must be specified in the minimum order tick price. For the BTC/TUSD product the minimum order tick price is 0.01. Prices lesser than the minimum tick will not be accepted.

size

Size indicates the amount of base currency required to Bid or Ask against the quote currency.

type

Limit order is the Default order type which requires specifying the price and size. If the limit order is not seen filled , it will become the part of the order book unless filled or cancelled by the user.

trade_pair

The trade pair must be valid matching product available in the list of pairs for trading. Ex:BTC-INR.

side

Side indicates the side at which the order is placed. Bid side indicates a downtick and conversely Ask side indicates the uptick.

created_at

This indicates the Date and time when the order is placed.

status

The status of the order can be determined and then classified into ‘pending’ or ‘completed’. Eg : A limit order will show pending unless “filled or cancelled”

Request

                    
                        {
"trade_pair":"xrp-btc", "side":"ask", "size":1, "price":0.0005
}

Response

                    
                        {
"id": 555677, "price": 0.0005, "size": 1, "type": "limit", "trade_pair": "xrp-btc", "side": "ask", "created_at": 1538576785865, "status": "pending"
}

List Trade Orders

List your current orders. You can view open as well as settled orders. We need to pass ORDER STATUS "Pending" to get all un-settled orders, "all" to get all orders.

Request URL

GET /orders

Request parameters
Param

Description

trade_pair

Optional : The trade pair must be valid matching product available in the list of pairs for trading. Ex:BTC-INR

status

Optional : The status of the order can be determined and then classified into ‘pending’ or ‘completed’. Eg : A limit order will show pending unless “filled or cancelled”

orderid

Optional : Order Id

page

Optional : Page Number of the records to be seen.

limit

Optional : Number of records to be fetch in Single Page

Response parameters
Param

Description

id

Order Id

price

The price must be specified in the minimum order tick price. For the BTC/TUSD product the minimum order tick price is 0.01. Prices lesser than the minimum tick will not be accepted.

size

Size indicates the amount of base currency required to Bid or Ask against the quote currency.

type

Limit order is the Default order type which requires specifying the price and size. If the limit order is not seen filled , it will become the part of the order book unless filled or cancelled by the user.

trade_pair

The trade pair must be valid matching product available in the list of pairs for trading.

side

Side indicates the side at which the order is placed. Bid side indicates a downtick and conversely Ask side indicates the uptick.

created_at

This indicates the Date and time when the order is placed.

executed_value

Executed value is filled_size * [price]

cancel_value

Amount of cancel value by price

fill_fees

Fee applicable

filled_size

Quantity of order executed

status

The status of the order can be determined and then classified into ‘pending’ or ‘completed’. Eg : A limit order will show pending unless “filled or cancelled”

settled

Order is settled or in progress

                    

                        {
                    
"id": 555583, "price": 17, "size": 0.5, "type": "limit", "trade_pair": "BTG-USDT", "side": "Ask", "created_at": 1538576785865, "executed_value": 8.5, "cancel_value": 0, "fill_fees": 0.025, "filled_size": 0.5, "status": "complete", "settled": true
}

Fills

Get a single order's detail/fills by order id.

Request URL

GET /orders/{orderid}/fills

Scope

Param

Description

orderid

Valid Order Id

size

Size indicates the amount of base currency required to Bid or Ask against the quote currency.

price

The price must be specified in the minimum order tick price. For the BTC/TUSD product the minimum order tick price is 0.01. Prices lesser than the minimum tick will not be accepted.

amount

Amount shows the total executed value of order placed by the user.

feesType

Orders which provide liquidity are charged different fees from orders taking liquidity. Makers are charged differently than the market takers.

fees

Zebpay operates a maker-taker model. The fee is assessed as a percentage of the match amount (price * size).

intradayFees

Orders of equivalent quantity executed on both sides of the book on same day attract exclusive intraday fees of 0.1%.

totalFees

Total fees is calculated on 24-hour cycle which is cumulated of market maker, taker and intraday fees. Any excessive fees charged attracts rebate at the end of the time-cycle.

feeCurrency

Fees for a given pair will be charged always in terms of the quote currency. Eg: For the pair ETHBTC, the attracted trade fee on the given pair will be in BTC.

createDate

This indicates the Date and time when the order is placed.

                    

                        {
                        
"orderId":555806, "size": 0.5, "price": 17, "amount": 8.5, "feesType": "taker", "fees": 0, "intradayFees": 0.01, "totalFees": 0.01, "feeCurrency": "USDT", "createDate": 1538576785865
}

Cancel Trade Order

Cancel a previously placed order.

Request URL:

DELETE /orders/{orderid}

Scope:

Param

Description

orderid

Valid Order Id

data

Success

                    

                        {
                    
"data": null, "statusCode": 200, "statusDescription": "success"
}

Trade Pair

"Pair-Trading" in cryptocurrency in simple language means "exchanging one virtual currency for another". Every cryptocurrency in today's world is associated a value, which is a multiple of value of domestic fiat currency. The same concept is applied while "Crypto-Crypto trading" where the base value of the relative alternative coins is decided to that of the Bitcoin.

Left Hand Side will be the currency we want to trade:

BCH-BTC

Bitcoin Cash - Bitcoin

ETH-BTC

Ether - Bitcoin

XRP-BTC

Ripple - Bitcoin

LTC-BTC

Litecoin - Bitcoin

TRX-BTC

TRON - Bitcoin

EOS-BTC

EOS - Bitcoin

To know more about our tradepairs please visit Zebpay Blog

Websocket Feeds

The websocket feed provides real-time market data updates for orders(book), tickers and trades(history).

Websocket Feeds Endpoint URL
ws://ws-feed.zebpay.co/marketdata

Connection Overview

To connect to Zebpay websocket feed you have include socket.io library depending on your client. For example to use it just as a cross-browser WebSocket include js lib (you can download or refer from cdn )- and run below code in javascript:

                    
                    var socket = io('ws://ws-feed.zebpay.co/marketdata',{transports: ['websocket']});
                           socket.on('connect', function () {
                    
console.log('Connected!').on socket.on('message', function (msg) { // my msg
}); });

Event Subscription

Once the connection is established between your client and server, you can subscribe to different event by simply emitting a 'subscribe' events with the respective event names. The Format for event names are as follows:

Event Name Base Url Example Url ticker ticker/{tradepair} ticker/BTC-INR book book/{tradepair} book/BTC-INR history history/{tradepair} history/BTC-INR

Once you have the event names, you need to emit the subscribe event with the respective event name and server will start sending real time data.

                    ws.emit('subscribe', 'ticker/BTC-INR');
                    

Realtime Event Data

To capture the data for any event, you have to simply add a socket listener for that event.

                    
                            ws.on('ticker/BTC-INR', (data) => {
                            console.log('in event ticker/BTC-INR', data);
                            });
                          
                        

Note - To capture data from any event make sure you have emitted a subscribe event for that event name.

For debugging purpose and catching socket server errors, you can directly listen for the ‘error’ event. No need to subscribe.

                    
                            ws.on(‘error’, (message) => {
                            console.error(‘Error from socket server’, message);
                            });