Zebpay Build is a platform where users can create their own applications for trading like other cryptocurrency trading applications.
Developers can create trading bots using Zebpay Build. Users can also build own applications (console/web/API) using our platform and will be able to:
1. Buy and Sell Crypto Assets.
2. Fetch the market data.
3. Fetch open/completed orders.
4. Cancel open orders.
5. Get the latest balance of crypto assets.
All Market and Trading related data/methods are available through REST-ful API.
To start using API, first you need to login or register with zebpay, then you need to create a new application. If you do not have zebpay account, you can sign up here.
To create new Application in zebpay build, go to the application section in build and then click on the create application button. Please fill all required details and click on the submit button and your application will be created.
Once your application is created, our team will review and approve it. After approval of application, you will get the client id and client secret key.
You also need the Authorization token to perform the API calls. You have to perform these API call in sequence
1) /user/login,
2) /user/verifyotp,
3) /user/verifypin
Please ensure above requests must contain the following headers.
Received after creating Application.
A timestamp for your request, in ticks.
application/json
A Unique GUID Request Token (Generate new request id on every request).
This API is used to authenticate the user. User will get the verification_code in response which needs to be used in /user/verifyotp API call.
POST /user/login
User country code for example: mt, au
User mobile number without country code
Received after creating Application.
Received after creating Application.
{
"verification_code": "Verification_code",
"access_token": null,
"expires_in": null,
"token_type": null,
"refresh_token": null,
"message": null,
"error": null,
"error_description": null
}
"statusCode": 200,
"statusDescription": "OK"
This API is used to authenticate verifyOtp call. User will get the verification_code in response which needs to be used in /user/verifypin API call.
POST /user/verifyotp
Received on user's mobile number.
Received in the /user/login API.
Received after creating Application.
Received after creating Application.
{
"verification_code": "Verification_code",
"access_token": null,
"expires_in": null,
"token_type": null,
"refresh_token": null,
"message": null,
"error": null,
"status": "pending"
}
"statusCode": 200,
"statusDescription": "success"
This API is used to authenticate VerifyPin. After the API is called successfully user will get the access_token which needs to be used in all API calls.
POST /user/verifypin
user_credentials
User account pin.
Daily trade limit.
Daily withdrawal limit.
total trade limit.
Total withdrawal limit.
verification_code received in the /user/verifyotp API.
Allowed scopes for the application.
For example trade:read, trade:create
Received after creating Application.
Received after creating Application.
{
"verification_code": null,
"access_token": "access_token",
"expires_in": "3600",
"token_type": "Bearer",
"refresh_token": null,
"message": null,
"error": null,
"error_description": "pending"
}
"statusCode": 200,
"statusDescription": "success"
User can place a limit order and it can be done only when there is sufficient amount of Quote currencies available in the account. On placing the order, the amount of quote currency for the given pair will be kept on hold for the duration of the order.
Received after creating Application.
A timestamp for your request, in ticks.
application/json
The bearer token, mandatory for all trade API's.
A Unique GUID Request Token (Generate new request id on every request).
POST /orders
Description
The trade pair must be valid matching product available in the list of pairs for trading. Eg. BTC-INR
It indicates the side at which the order is placed. Bid side indicates a downtick and conversely Ask side indicates the uptick.
Size indicates the amount of base currency required to Bid or Ask against the quote currency.
The price should be in a multiple of minimum tick size.
For example: BTC-INR pair will have the minimum tick size as 0.01 .
Possilbe values are 1, 2 and 3.
1 is for limit type of order, 2 is for market type of order and 3 is for stoploss type of order
Optional: Applicable if tradeType is of stopploss type of order(3).
Description
Order id
The price should be in a multiple of minimum tick size.
For example: BTC-INR pair will have the minimum tick size as 0.01 .
Size indicates the amount of base currency required to Bid or Ask against the quote currency.
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.
The trade pair must be valid matching product available in the list of pairs for trading. Ex:BTC-INR.
It indicates the side at which the order is placed. Bid side indicates a downtick and conversely Ask side indicates the uptick.
This indicates the Date and time when the order is placed.
The status of the order can be determined and then classified into 'pending' or 'complete'. Eg : A limit order will show pending unless "filled or cancelled"
{
"trade_pair": "btc-inr",
"side": "ask",
"size": 1,
"price": 2000000
}
{
"id": 555677,
"price": 2000000,
"size": 1,
"type": "limit",
"trade_pair": "btc-inr",
"side": "ask",
"created_at": 1538576785865,
"status": "pending"
}
The fastest way to get started is by importing our API collection into postman from the below link.
Overview and general information about the Zebpay Build API's.
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.
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.
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.
Bad Request – Invalid request format
Unauthorized – Invalid API Key
Forbidden – You do not have access to the requested resource
Not Found
Internal Server Error – We had a problem with our server
When a Rate limit is exceeded, a status of "429 Too Many Requests" will be returned.
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.
User 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.
We support pagination in 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.
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.
https://www.zebpay.co/api/v1
https://www.zebpay.co/pro/v1
Zebpay Build production environment is available for API connectivity and Web trading.
Login sessions and API keys are separate from production.
https://www.zebapi.com/api/v1
https://www.zebapi.com/pro/v1
Client libraries can help you integrate with our API quickly.
Github Repository
User will need to register on Application before getting started. Upon successful registration you will get the following information which needs to be saved.
This information will be used in the OAuth flow
A unique GUID which need to be provided for authentication.
A unique GUID which need to be provided for authentication.
It is used to generate the hash signature,by which user will get authenticated.
User must restrict the scope of Application.User can select this permission at the time of application registration.
Permission to read the trade.
Permission to execute the trade.
All Request must contain the following headers.
Received after creating Application.
A timestamp for your request, in ticks.
application/json
The bearer token, mandatory for all trade API's.
A Unique GUID Request Token (Generate new request id on every request).
Zebpay Build provides a page where developers can register the application as "web". At the time of application registration developers need to keep the following things in mind:
When creating .net MVC Core application, app.UseAuthentication() should be used for authentication.
http://xxxx-baseurl-xxx/signin-oidc
http://xxxx-baseurl-xxx/signout-callback-oidc
Code Sample for .net MVC Core application (developers 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;
});
Zebpay provides a page where developers 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 : /user/login, /user/verifyotp, /user/verifypin, /user/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.
We always need an access token to call any authenticated API. Considering a scenario where the client is a program/bot they will ideally need a manual intervention to key-in OTP in our authentication process. To get rid of this dependency we have an interactive UI where developers can generate access token and setup inside their program.
To generate access token, user needs to go to his/her application detail page, and then navigate to GenerateToken tab. You can generate token for all your scope or for a smaller set as well. System will prompt for a one time password to key-in before generating the actual token value.
This API is used to authenticate the user. User will get the verification_code in response which we need to be used in /user/verifyotp API call.
POST /user/login
User country code for example: mt, au
User mobile number without country code
Received after creating Application.
Received after creating Application.
{
"verification_code": "Verification_code",
"access_token": null,
"expires_in": null,
"token_type": null,
"refresh_token": null,
"message": null,
"error": null,
"error_description": null
"publicGuid": "36abcdea-3xyz-45e8-8efg-fb9d0293dabc"
}
"statusCode": 200,
"statusDescription": "OK"
This API is used to authenticate “verifyOtp”. User will get the verification_code in response which needs to be used in /user/verifypin API call.
POST /user/verifyotp
Received on user's mobile number.
Received in the /user/login API.
Received after creating Application.
Received after creating Application.
{
"verification_code": "Verification_code",
"access_token": null,
"expires_in": null,
"token_type": null,
"refresh_token": null,
"message": null,
"error": null,
"error_description": null
"publicGuid": ""
}
"statusCode": 200,
"statusDescription": "success"
This API is used to authenticate “VerifyPin”. After successful API call, user will get the access_token which needs to be used for all API calls.
POST /user/verifypin
user_credentials
User account pin.
Daily trade limit.
Daily withdrawal limit.
Total trade limit.
Total withdrawal limit.
Received in the /user/verifyotp API.
Allowed scopes for the application.
For example trade:read, trade:create
Received after creating Application.
Received after creating Application.
{
"verification_code": null,
"access_token": "access_token",
"expires_in": "3600",
"token_type": "Bearer",
"refresh_token": null,
"message": null,
"error": null,
"error_description": "pending"
"publicGuid": null
}
"statusCode": 200,
"statusDescription": "success"
This is used to logout from the application.
POST /user/logout
Access token generated in the /user/verifypin API.
Received after creating Application.
Received after creating Application.
{
"verification_code": null,
"access_token": null,
"expires_in": "null,
"token_type": null,
"refresh_token": null,
"message": success,
"error": null,
"error_description": null
"publicGuid": null
}
"statusCode": 200,
"statusDescription": "You have been successfully logged out!"
These APIs returns market details including ticker(s), book (pending orders), trades (executed orders) etc.
Users can get a list of 24 hr stats for available pair by this API. Volume is in base currency units.
GET /market
Description
Current Buy Rate
Current Sell Rate
Volume - Exchange
Volume for last 24 Hrs
Change in price
Highest Price in last 24 hours.
Lowest Price in last 24 hours.
Current trade pair
Currency
Volume - Quick trade
Note: Pass query string parameter ?group=singapore
[
{
"buy": "0",
"sell": "180.02",
"market": "180.02"
"volumeEx": 0,
"volume": 0,
"pricechange": "0.00",
"24hoursHigh": "180.02",
"24hoursLow": "180.02",
"pair": "1INCH-INR",
"virtualCurrency": "1INCH",
"currency": "INR"
"volumeQt": 0,
},
...
]
Users can get the ticker information for the current Trade Pair with daily volume and current Price by using this API.
GET /market/{tradepair}/ticker
Description
Example BTC-INR, ETH-INR etc.
Current Buy Rate
Current Sell Rate
Volume for last 24 Hrs
Change in price
Highest Price in last 24 hours.
Lowest Price in last 24 hours.
Volume on Exchange
Volume on Quick Trade
Current trade pair
Note: Pass query string parameter ?group=singapore
{
"buy": "271941.98",
"sell": "271500",
"volumeEx": 72.937237,
"market": "271843.6",
"volume": 77.759131,
"24hoursHigh": "278000",
"24hoursLow": "270000",
"pricechange": "0.33",
"pair": "ETH-INR",
"virtualCurrency": "ETH",
"currency": "INR",
"volumeQt": 4.821894
}
Users can get a list of open orders for a trade pair by using this API.
GET /market/{tradepair}/book
Description
Example BTC-INR, ETH-INR etc.
List of recent ask's Rates, with Price & Amount.
List of recent bid's Rates, with Price & Amount.
Current trade pair.
Note:
{
"asks": [
{
"price": "272497.11",
"amount": 9660000
}
],
"bids": [
{
"price": "271680.85",
"amount": 6250423
}
],
"pair": "ETH-INR"
}
This endpoint can be used to read order data as well as create a new order. User can also cancel a previously placed order.
User can place a limit order and it can be done only when there are sufficient amount of Quote currencies available in the account. On placing order, the amount of quote currency for the given pair will be kept on hold for the duration of the order.
POST /orders
Description
The trade pair must be a valid matching product available in the list of pairs for trading. Ex:BTC-INR
It indicates the side at which the order is placed.
Bid side indicates a downtick and conversely Ask side indicates the uptick.
It indicates the amount of base currency required to Bid or Ask against the quote currency.
The price should be in a multiple of minimum tick size.
For example: BTC-INR pair will have the minimum tick size as 0.01 .
1 = Limit, 2 = Market, 3 = Stoploss
Provide stopRate When tradeType is "Stoploss" else default value should be 0
Provide marketOrderValue when tradeType is "Market" else default value should be 0
Description
Order id
The price should be in a multiple of minimum tick size.
For example: BTC-INR pair will have the minimum tick size as 0.01 .
It indicates the amount of base currency required to Bid or Ask against the quote currency.
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.
The trade pair must be a valid matching product available in the list of pairs for trading. Ex:BTC-INR.
It indicates the side at which the order is placed. Bid side indicates a downtick and conversely Ask side indicates the uptick.
This indicates the date and time when the order is placed.
The status of the order can be determined and then classified into ‘pending’ or ‘complete’. Eg : A limit order will show pending unless "filled or cancelled"
{
"trade_pair": "btc-inr",
"side": "ask",
"size": 1,
"price": 2000000
}
{
"id": 555677,
"price": 2000000,
"size": 1,
"type": "limit",
"trade_pair": "btc-inr",
"side": "ask",
"created_at": 1538576785865,
"status": "pending"
}
Users can list their current orders and can also view open as well as settled orders. User needs to pass ORDER STATUS "Pending" to get all unsettled orders, "all" to get all orders.
GET /orders
Description
The trade pair must be valid matching product available in the list of pairs for trading. Ex:BTC-INR
Optional: Default value is 'pending'. The status of the order can be determined and then classified into 'pending' or 'complete'. Order will have 'complete' status if it is fully executed in other cases, status will be 'pending'.
Optional: Order Id
Optional: Page Number of the records to be seen.
Optional: Number of records to be fetch in Single Page
Description
Order Id
The price should be in a multiple of minimum tick size.
For example: BTC-INR pair will have the minimum tick size as 0.01 .
It indicates the amount of base currency required to Bid or Ask against the quote currency.
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.
The trade pair must be a valid matching product available in the list of pairs for trading.
It indicates the side at which the order is placed. Bid side indicates a downtick and conversely Ask side indicates the uptick.
This indicates the date and time when the order is placed.
Executed value is filled_size * [price]
Pending Quantity in crypto
Quantity of order executed
The status of the order can be determined and then classified into 'pending' or 'complete'. Eg : A limit order will show pending unless "filled or cancelled"
Market order amount when order type is Market Order
Stop price when order type is Stop Loss
[{
"id": 555583,
"price": 17,
"size": 0.5,
"type": "limit",
"trade_pair": "BTC-INR",
"side": "Ask",
"created_at": 1538576785865,
"executed_value": 8.5,
"open_size":0.00070000,
"filled_size": 0.5,
"status": "complete",
"market_order_amt": 0.00000000,
"stop_price": 0.00000000,
"reference_id":null
}]
Users can get a single order's detail/fills by order id by using this API
GET /orders/{orderid}/fills
Description
Valid Order Id
{
"orderDetail":{
"id": 555806,
"type": "Limit",
"side": "Bid",
"size": 1.00000000,
"openQty": 0.00000000,
"executedQty": 0.00000809,
"cancelQty": 0.99999191,
"price": 5000.00000000,
"orderValue": 0.000000,
"openOrderValue": 0.000000,
"totalFees": 0.00009500,
"avgExecutedPrice": 3999.38190000,
"effectivePrice": 4011.17920000,
"tradePair":"BTC-TUSD",
"feeCurrency": "TUSD",
"createDate": 1532608626000,
"status": "cancel",
"orderStatus": 40,
"marketOrderAmount": 0.00000000
}
},
"fills":[{
"orderId": 555806,
"size": 0.00000010,
"price": 4003.00000000,
"amount": 0.000400,
"feesType": "taker",
"fees": 0.00000100,
"intradayFees": 0.00000000,
"totalFees": 0.00000100,
"feeCurrency": "TUSD",
"createDate": 1538576785865
}]
Users can cancel previously placed order by using this API.
DELETE /orders/{orderid}
Description
Valid Order Id
{
"data": null,
"statusCode": 200,
"statusDescription": "success"
}
Users can cancel all the previously placed order(s) for trade pair by using this API.
DELETE orders/CancelAll?trade_pair = BTC-INR
*To cancel orders from all trade pairs use DELETE orders/CancelAll?tradepair=ALL
Description
Valid Trade Pair
{
"data": null,
"statusCode": 200,
"statusDescription": "success"
}
Provides TDS and Fees information
GET tradefees/BTC-INR
Description
Valid Trade Pair
buy/sell
{
"customerLevel":"Regular"
"feeProcessTitle": "How are Fees Processed?",
"feeProcessDescription": "You will be charged a Maker or Taker fee when your order is executed.........",
"tradeValue30Days": 2693.0,
"feeList": [
{
"id":1,
"feeTitle": "Maker Fee",
"feeDescription": "Maker Fee Description",
"fee": 0.15,
},
{
"id":2,
"feeTitle": "Taker Fee",
"feeDescription": "Taker Fee Description",
"fee": 0.25,
},
{
"id":3,
"feeTitle": "Intraday Fee",
"feeDescription": "Intraday Fee Description",
"fee": 0.1,
},
{
"id":4,
"feeTitle": "TDS",
"feeDescription": "TDS Description",
"fee": 0.0,
}
]}
The deepstream feed provides real-time market data updates for following events:
To connect to public deepstream
Deepstream documentation: https://deepstream.io/docs/
NPM Module: https://www.npmjs.com/package/deepstream.io-client-js
Use this CDN
https://cdnjs.cloudflare.com/ajax/libs/deepstream.io-client-js/2.3.0/deepstream.js
const ds = window.deepstream;
const config = {
password: "zebpay",
userName: "zebpay",
url: "wss://data.zebapi.com",
};
const client = ds(config.url, {
// Reconnect after 10, 20 and 30 seconds
reconnectIntervalIncrement: 10000,
// Try reconnecting every thirty seconds
maxReconnectInterval: 30000,
// We never want to stop trying to reconnect
maxReconnectAttempts: Infinity,
// Send heartbeats only once a minute
heartbeatInterval: 60000,
});
client.login(
{
username: config.userName,
password: config.password,
},
(success, data) => {
if (success) {
console.log("Login Success");
} else {
console.log("Login Failed");
}
}
);
client.on("error", (error, event, topic) => {
console.log("error", error, event, topic);
});
client.on("connectionStateChanged", (connectionState) => {
console.log("connection state", connectionState); // will be called with 'CLOSED' once the connection is successfully closed.
});
Once the connection is established, user can request a “record” with the respective topic name. The Format for event names are as follows:
Event | Event Name Format | Example |
---|---|---|
Ticker | ticker_singapore/{tradepair} | ticker_singapore/BTC-INR |
Orderbook | book_singapore/{tradepair} | book_singapore/BTC-INR |
History | history_singapore/{tradepair} | history_singapore/BTC-INR |
Instant Rates | traderates/{tradepair} | traderates/BTC-INR |
Ticker (To subscribe realtime ticker event for BTC-INR)
Event:ticker_singapore/{tradepair}
let tickerRecord = client.record.getRecord('ticker_singapore/BTC-INR');
tickerRecord.subscribe(data => {
console.log(data)
})
Sample response for ticker data
{
high24hr: "4200000"
low24hr: "4180000"
marketPrice: "4200000"
priceChangePercent24hr: "0.48"
topBuy: "4200000"
topSell: "4180000"
volumeTotal24hr: "0"
volumeTraded24hr: "1120880"
}
Order book (To subscribe realtime order book event for BTC-INR)
Event:book_singapore/{tradepair}
let bookRecord = client.record.getRecord('book_singapore/BTC-INR');
bookRecord.subscribe(data => {
console.log(data)
})
Sample response for order book data
{
"bids": [
{
"price": "4180000.00000000",
"amount": 48872613
},
{
"price": "3300000.00000000",
"amount": 3207453
}
],
"asks": [
{
"price": "4200000.0",
"amount": 4471192
},
{
"price": "4300000.0",
"amount": 600000
}
]
}
Trade history (To subscribe realtime trade history event for BTC-INR)
Event:{tradepair}-txHistory_singapore
client.event.subscribe('BTC-INR-txHistory_singapore', data => {
console.log(data)
});
Sample response for trade history data
{
"trans_id": 49,
"fill_qty": 6120,
"fill_price": 4180000,
"fill_flags": 1,
"inbound_order_filled": true,
"currencyPair": "BTC-INR",
"lastModifiedDate": 1649187243341
}
Note:-The amount and fill_qty in orderbook and trade history are represented in the lower denomination. To convert to standard denomination it should be divided by 10^tradeCurrencyDisplayDecimalPlaces.
The value for tradeCurrencyDisplayDecimalPlaces for respective tradepair can be fetched using the tradepair API.
Endpoint: https://www.zebapi.com/api/v1/tradepairs/{country_code}
Example: https://www.zebapi.com/api/v1/tradepairs/IN
Instant Rates
Event: traderates/{tradepair}
let bookRecord = client.record.getRecord('traderates/KAVA-INR');
bookRecord.subscribe(data => {
console.log(data)
})
Sample response
{
BuyRate: 322.8211668,
SellRate: 321.05697108
}