Introduction

ZebPay Build is a platform where users can create their own applications for trading like other crypto trading applications. Developers can create trading bots using ZebPay Build. Users can also build their 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 their crypto assets.

All Market and Trading related data/methods are available through RESTful API.

Quick Start

To start using the API, you first need to log in or register with ZebPay and create a new application. If you don't have a ZebPay account, you can sign up here.

Create Application

To create a new application in ZebPay Build, go to the Application section in Build and click on the "Create Application" button. Fill in all the required details, then click the "Submit" button, and your application will be created.

Create Application

Get it Approved

Once your application is created, our team will review and approve it. After the application is approved, you will receive the client ID and client secret key.

You will also need the authorisation token to perform API calls. The API calls must be performed in the following sequence:
1) /user/login
2) /user/verifyotp
3) /user/verifypin

Please ensure that the requests contain the following headers.

client_id

Received after creating Application.

timestamp

A timestamp for your request, in ticks.

Content-Type

application/json

RequestId

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

Get it Approved

Login

This API is used to authenticate the user. The user will receive a verification_code in the response, which needs to be used in the /user/verifyotp API call.

Request URL

POST /user/login

Request parameters

country_code

User country code for example: mt, au

mobile_number

User mobile number without country code

client_id

Received after creating Application.

client_secret

Received after creating Application.

Sample Response

                    
                                {
"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"

OTP

This API is used to authenticate the verify-OTP call. The user will receive a verification_code in the response, which needs to be used in the /user/verifypin API call.

Request URL

POST /user/verifyotp

Request parameters

otp

Received on user's mobile number.

verification_code

Received in the /user/login API.

client_id

Received after creating Application.

client_secret

Received after creating Application.

Sample Response

                    
                                {
"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"

PIN

This API is used to authenticate VerifyPin. After a successful API call, the user will receive an access_token, which must be used in all subsequent API calls.

Request URL

POST /user/verifypin

Request parameters

grant_type

user_credentials

pin

User account pin.

daily_trade_limit

Daily trade limit.

daily_withdraw_limit

Daily withdrawal limit.

total_trade_limit

total trade limit.

total_withdraw_limit

Total withdrawal limit.

verification_code

verification_code received in the /user/verifyotp API.

scope

Allowed scopes for the application.
For example trade:read, trade:create, wallet:transactions:read

client_id

Received after creating Application.

client_secret

Received after creating Application.

Sample Response

                    
                                {
"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"

Example API call

User can place a limit order only when there is a sufficient amount of quote asset available in the account. Upon placing the order, the amount of quote assets for the given pair will be held for the duration of the order.

Request Headers
client_id

Received after creating Application.

timestamp

A timestamp for your request, in ticks.

Content-Type

application/json

Authorization

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

RequestId

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

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. Eg. BTC-INR

side

It 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 should be in a multiple of minimum tick size.
For example: BTC-INR pair will have the minimum tick size as 0.01 .

tradeType

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

stopRate

Optional: Applicable if tradeType is of stopploss type of order(3).

Responses
Param

Description

id

Order id

price

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

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

It 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 'complete'. Eg : A limit order will show pending unless "filled or cancelled"

Sample Request

                    
                            {
"trade_pair": "BTC-INR", "side": "ask", "size": 1, "price": 2000000
}

Sample Response

                    
                            {
"id": 555677, "price": 2000000, "size": 1, "type": "limit", "trade_pair": "BTC-INR", "side": "ask", "created_at": 1538576785865, "status": "pending"
}

Overview

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

Requests

All our API requests and responses use the application/json content type and follow standard HTTP response status codes for success and failure. All API requests are made over HTTPS. All POST requests must specify the parameters in x-www-form-urlencoded format.

Success

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

Error Handling

Unless otherwise stated, bad requests will respond with HTTP 4xx status codes. The response body will also contain a message parameter indicating the cause of the error. Ensure that your language's HTTP library is configured to provide message bodies for non-2xx responses, so you can read the message field from the body. The following table provides more details about error codes and their descriptions.

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 the rate limit is exceeded, a status of "429 Too Many Requests" will be returned.

Date/Time Format

All our Date/Time properties are represented as a 'Unique Timestamp in milliseconds' (Unix time, also known as POSIX time or UNIX Epoch time). This system describes a point in time as the number of seconds that have elapsed since 00:00:00 Coordinated Universal Time (UTC) on Thursday, January 1, 1970. Users can convert this value to any timezone. Please note that if your library supports only seconds, divide the value by 1000 before converting it to a date object.

Pagination Support

We support pagination in APIs that return a list. Users need to pass parameters like ?limit=10&page=1. By default, the system will limit the records to 20 and fetch the latest data.

Sandbox

A public sandbox is available for testing API connectivity and web trading. The sandbox environment offers the full functionality of the production exchange, allowing you to experiment with the API. Login sessions and API keys are separate from the production environment. Use the sandbox web interface to create keys specifically for sandbox use.

REST API

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

Market REST API

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

Production

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

Login sessions and API keys are distinct from the production environment.

REST API

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

Market REST API

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

Client Libraries

Client libraries can help you integrate with our API quickly.

Github Repository

Authentication

Generating API Key

Users need to register on the application before getting started. Upon successful registration, they will receive the following information, which must be saved.

This information will be used in the OAuth flow:

Client ID

A unique GUID that must be provided for authentication.

Client Secret

A unique GUID that must be provided for authentication.

API Secret

Used to generate the hash signature, which will authenticate the user.

Scope Permission

Users must restrict the scope of the application. They can select the appropriate permissions during the application registration process:

Trade

Permission to read trade data.

Trade

Permission to execute trades.

wallet:transactions

Permission to view wallet balances.

API - Request Headers

All requests must contain the following headers:

client_id

Received after creating the application.

timestamp

A timestamp for your request, in ticks.

Content-Type

application/json

Authorization

The bearer token, mandatory for all trade APIs.

RequestId

A unique GUID request token (generate a new request ID for every request).

Web Application

ZebPay Build provides a page where developers can register their application as 'web'. When registering the application, developers should keep the following in mind:

For .NET MVC Core applications, app.UseAuthentication() must 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 (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;
});

Backend/Console Application

ZebPay provides a page where developers can register their application as 'Console'.

A series of APIs are available for login purposes, which need to be called in the following sequence:

/user/login,
/user/verifyotp,
/user/verifypin,
/user/logout.

Refer to the User API documentation for detailed request and response information.

Upon successful authentication, the user will receive an access_token, which can be used to access other APIs.



UI to generate Access-Token

An access token is always required to call any authenticated API. In scenarios where the client is a program or bot, manual intervention is typically needed to input an OTP during the authentication process. To eliminate this dependency, we offer an interactive UI where developers can generate an access token and integrate it into their program.

To generate an access token, users must go to their application detail page and navigate to the 'Generate Token' tab. You can generate a token for all scopes or a specific subset. The system will prompt you to input a one-time password before generating the token.

Websocket collection

There are two segments in Websocket collection:

1. Market
2. User

Websocket Market

Users can subscribe to the WebSocket to receive real-time updates on market data, such as the order book, trades, and ticker information.


Websocket Endpoint:
socket.zebapi.com/api/v1/websocket/public


Live Subscribing/Unsubscribing
The following data can be sent through the WebSocket instance to subscribe or unsubscribe.

Request to Subscribe

                    
{
                    "request": <request-path>
}
                    

Request to Unsubscribe

                    
{
                    "request": <request-path>,
                    "subscribe": false,
}
                    

Exchange

It pushes the order book snapshot, trade data, and ticker information for a trading pair.

Request path: exchange/<symbol>


Sample Request

                    
{
                    "request": "exchange/BTC-INR"
}
                     

Sample Response

                    
// Last 24 hour Price Change percentage
{
                    "data": -1.78,
                    "requestType": "BTC-INR",
                    "type": "exchange-pricechange"
}

// Last 24 hour volume
{
                    "data": 1.5,
                    "requestType": "BTC-INR",
                    "type": "exchange-volumechange"
}

// Last 24 hour exchange high price
{
                    "data": 6299991,
                    "requestType": "BTC-INR",
                    "type": "exchange-high"
}

// Last 24 hour exchange low price
{
                    "data": 4899108.005,
                    "requestType": "BTC-INR",
                    "type": "exchange-low"
}

// Order book snapshot
{
                    "data": {
                    "asks": [
          {
                    "amount": 6000,
                    "price": "5885000"
          },
          {
                    "amount": 7347,
                    "price": "5907694.21"
          },
          {
                    "amount": 126049,
                    "price": "5950000"
          },
         …
      ],
                    "bids": [
          {
                    "amount": 579032,
                    "price": "5882166.82"
          },
          {
                    "amount": 169454,
                    "price": "5880000"
          },
          …
      ]
  },
                    "requestType": "BTC-INR",
                    "type": "exchange-book"
}

// Executed trades
{
                    "data": {
                    "fill_flags": 1,
                    "fill_price": 2102991,
                    "is_buyer": "maker" or "taker",
                    "fill_qty": 4758,
                    "inbound_order_filled": true,
                    "lastModifiedDate": 1677154922164,
                    "trans_id": 871549,
  },
                    "requestType": "BTC-INR",
                    "type": "exchange-fill"
}

// Top Buy Price
{
                    "data": 5885000,
                    "requestType": "BTC-INR",
                    "type": "exchange-topbuy"
}

// Top Sell Price
{
                    "data": 5882166.82,
                    "requestType": "BTC-INR",
                    "type": "exchange-topsell"
}

// Last traded price
{
                    "data": 5882166.82,
                    "requestType": "BTC-INR",
                    "type": "exchange-marketprice"
}
                     

Quick Trade

The buy and sell prices in Quick Trade can be retrieved by subscribing to the Quick Trade updates.

Request path: qt/<symbol>


Sample Request

                    
{
                    "request": "qt/BTC-INR"
}
                    

Sample Response

                    
{
                    "data": {
                    "BTC-INR": {
                    "BuyRate": 5969972.00442825,
                    "LTP": 5902775.445,
                    "PercentChange": "0.15",
                    "SellRate": 5864271.73969875
       }
   },
                    "type": "qt-instant-trade-rate"
}
                    

Exchange Trending

The ticker data for all pairs on the exchange can be retrieved by subscribing to Exchange Trending updates.

Request path: exchange/trending/<mother_currency>/<quote_currency>/data


Sample Request

                    
{
                    "request": "exchange/trending/INR/INR/data"
}
                    

Sample Response

                    
{
                    "data": [
       {
                    "CurrencyCode": "BTC",
                    "CurrencyHoverImage": "https://static.zebpay.com/multicoins/ic_coin_bitcoin_hover.png",
                    "CurrencyName": "Bitcoin",
                    "IsNew": false,
                    "MessageText": "",
                    "PercentDiff": -2.42,
                    "Rate": 5840000,
                    "Sender": "Zrevamp.Trade",
                    "Sequence": 4,
                    "TradeValue": 451291.13,
                    "Volume": 0.07727588
       },
       {
                    "CurrencyCode": "MATIC",
                    "CurrencyHoverImage": "https://static.zebpay.com/multicoins/ic_coin_polygon_hover.png",
                    "CurrencyName": "Polygon",
                    "IsNew": false,
                    "MessageText": "",
                    "PercentDiff": -28.75,
                    "Rate": 65.19725,
                    "Sender": "Zrevamp.Trade",
                    "Sequence": 5,
                    "TradeValue": 421320.26,
                    "Volume": 6462.2398
       },
      ...
   ],
                    "requestType": "INR/INR",
                    "type": "exchange-trending"
}
                    

Quick Trade Trending

The ticker data for all pairs in Quick Trade can be retrieved by subscribing to Quick Trade Trending updates.

Request path: qt/trending/<mother_currency>/<quote_currency>/data


Sample Request

                    
{
                    "request": "qt/trending/INR/INR/data"
}
                    

Sample Response

                    
{
                    "data": [
       {
                    "CurrencyCode": "BTC",
                    "CurrencyName": "Bitcoin",
                    "IsNew": false,
                    "MessageText": "",
                    "PercentDiff": -2.06,
                    "Rate": 5902484.56,
                    "SellRate": 5798607.26,
                    "Sender": "Zrevamp.Trade",
                    "Sequence": 10,
                    "TradeRateBefore24Hours": 6027030.1005408,
                    "TradeValue": 1080140.15,
                    "Volume": 0.18299754
       },
       {
                    "CurrencyCode": "ETH",
                    "CurrencyName": "Ether",
                    "IsNew": false,
                    "MessageText": "",
                    "PercentDiff": -0.86,
                    "Rate": 290244.25,
                    "SellRate": 285124.2,
                    "Sender": "Zrevamp.Trade",
                    "Sequence": 11,
                    "TradeRateBefore24Hours": 292788.076028,
                    "TradeValue": 1004865.33,
                    "Volume": 3.46213681
       },
      ...
   ],
                    "requestType": "INR/INR",
                    "type": "qt-trending"
}
                    

Ping Pong


Sample Request

                    
{ 
                    "request": "PING" 
}
                    

Sample Response

                    
{
                    "response": "PONG"
}
                    

Abort Connection

The client disconnects the socket connection if no messages are sent or received for 1 minute.

To disconnect or close the socket connection, you can send the following request.


Sample Request

                    
{
                    "request": "STOP"
}
                     

Websocket User

User can listen to websocket for fetching the real time updates on user data like balance and order.


Websocket Endpoint:
socket.zebapi.com/api/v1/websocket/public


Live Subscribing/Unsubscribing:
The following data can be sent through the websocket instance in order to subscribe/unsubscribe.

Request to Subscribe

                    
{
                    "request": <request-path>,
                    "token": <auth_token>
}
                    

Request to Unsubscribe

                    
{
                    "request": <request-path>,
                    "subscribe": false
}
                    

Balance

It provides wallet balance information whenever there is a change in the wallet balance.

Request path: balance


Sample Request

                    
{
                    "request": "balance"
                    "token": "<auth_token>"
}
                     

Sample Response

                    

{
                    "data": [
            {
                    "currency": "INR",
                    "balance": "6280469.9",
                    "last_updated": "1723805866866",
                    "pending_trade_balance": "769.4",
                    "isVirtual": false,
                    "lending_balance": "0",
                    "pack_balance": "0",
                    "qt_locked_balance": "15420.44"
            },
            {
                    "currency": "BTC",
                    "balance": "2501.86179663",
                    "last_updated": "1723805866866",
                    "pending_trade_balance": "0",
                    "isVirtual": true,
                    "lending_balance": "4.60763963",
                    "pack_balance": "0.0113988",
                    "qt_locked_balance": "0"
            }
         ],

                    "type": "BALANCE"
}

                     

Order

It provides information related to orders.

Request path: order


Sample Request

                    
{
                    "request": "order"
                    "token": "<auth_token>"
}
                     

Sample Response

                    

{
                    "data": [
            {
                    "id": 5781331,
                    "tradePair": "BTC-INR",
                    "status": "OPEN",
                    "side": "Bid",
                    "orderType": "LIMIT",
                    "avgPrice": "0",
                    "price": "5883917.16",
                    "size": "0.00013",
                    "volumeOpen": "0.00013",
                    "volumeExecuted": "0",
                    "fee": "0",
                    "tradeValue": "0",
                    "marketOrderAmount": "0",
                    "stopPrice": "0",
                    "tax": "0",
                    "tds": "0",
                    "createdAt": 1723642482773
            },
            {
                    "id": 5781451,
                    "tradePair": "ETH-INR",
                    "status": "OPEN",
                    "side": "Bid",
                    "orderType": "LIMIT",
                    "avgPrice": "0",
                    "price": "408121.98",
                    "size": "0.002",
                    "volumeOpen": "0.002",
                    "volumeExecuted": "0",
                    "fee": "0",
                    "tradeValue": "0",
                    "marketOrderAmount": "0",
                    "stopPrice": "0",
                    "tax": "0",
                    "tds": "0",
                    "createdAt": 1723806235036
            },
            {
                    "id": 5781450,
                    "tradePair": "ETH-INR",
                    "status": "OPEN",
                    "side": "Bid",
                    "orderType": "LIMIT",
                    "avgPrice": "0",
                    "price": "408121.98",
                    "size": "0.001",
                    "volumeOpen": "0.001",
                    "volumeExecuted": "0",
                    "fee": "0",
                    "tradeValue": "0",
                    "marketOrderAmount": "0",
                    "stopPrice": "0",
                    "tax": "0",
                    "tds": "0",
                    "createdAt": 1723806192664
            }
         ],

                    "type": "ORDER"
}

                    

Ping Pong


Sample Request

                    
{ 
                    "request": "PING" 
}
                    

Sample Response

                    
{
                    "response": "PONG"
}
                    

Abort Connection

The client disconnects the socket connection if no messages are sent or received for 1 minute.

To disconnect or close the socket connection, you can send the following request.


Sample Request

                    
{
                    "request": "STOP"
}
                     





Futures Websockets

There are two segments in Futures websocket collection:

1. Market
2. User

Futures Websocket Market

Market Data Streams provide real-time access to essential market information through WebSocket connections. By subscribing to specific streams, users can receive live updates on various market metrics. Following streams are available to subscribe to:

1. Depth Update (Order Book)
2. Kline (Candlestick)
3. Agg Trade (Aggregate Trade)
4. Mark Price Update
5. 24hr Ticker Update
6. All Contract Details

Connection Setup:
To access public market data streams, establish a WebSocket connection to the following URL using a socket client like socket.io

WS URL: wss://futuresws.zebpay.com/socket.io

Namespace: /


Subscribing & Unsubscribing to Data Streams:
The WebSocket connection allows users to subscribe to different data streams and receive real-time updates on market events.

Subscribe to Data Streams:
Send a message with the "subscribe" action, specifying the streams you want to receive in the params list

Unsubscribe from Data Streams:
To stop receiving data from a specific stream, send an unsubscribe message specifying the stream names in the params list.

Listening to Events:
Upon successful subscription, the WebSocket server will emit events whenever there is new data for the subscribed streams. Each event type has a unique payload structure as detailed below.

Request to Subscribe

                    
                        Action: send
                        Message Name: "subscribe"
                        Message Data:
                        {
                            "params":[
                                "btcinr@kline_1m",
                                "btcinr@markPrice" //streamsto subscribe to
                            ]
                        }
                    
                    


Request to Unsubscribe

                    
                        Action: send
                        Message Name: "unsubscribe"
                        Message Data:
                        {
                              "params": [
                                "btcinr@kline_1m",
                                "btcinr@markPrice" //streams to unsubscribe from
                              ]
                        }
                    
                    

Depth Update (Order Book)

Provides real-time updates to the order book's bids (buy orders) and asks (sell orders) for a specific symbol, showing the depth of market liquidity.


Stream Name: <symbol>@depth_<depthGrouping>

Example: btcinr@depth_0.1

Listening Event Name: depthUpdate

Event Structure

                        
  Action: receive
  Message Name: "depthUpdate"
  Message Data:
    {
         "e": "depthUpdate",       // Event type
         "E": 1707636353921,       // Event time (in ms)
         "T": 1707636353915,       // Transaction time (in ms)
         "s": "BTCINR",            // Symbol
         "U": 3960811287130,       // First update ID in event
         "u": 3960811297623,       // Last update ID in event
         "pu": 3960811281312,      // Previous final update ID
         "b": [                    // Bids (buy orders) array
           ["4240107.8", "0.710"], // [Price, Quantity]
           ["4240116.5", "0.230"]
         ],
         "a": [                    // Asks (sell orders) array
          ["4240353.6", "17.892"], // [Price, Quantity]
          ["4240362.4", "1.206"]
         ]
    }
                        
                    

Kline (Candlestick)

Provides real-time candlestick data for a specified trading interval, including open, close, high, low, and volume information.


Stream Name: <symbol>@kline_<interval>

Example: btcinr@kline_1m

Listening Event Name: kline

Event Structure

                    
    Action: receive
    Message Name: "kline"
    Message Data:
    {
      "e": "continuous_kline",        // Event type
      "E": 1730749500239,             // Event time
      "ps": "ETHINR",                 // Symbol
      "ct": "PERPETUAL",              // Contract type
      "k": {
        "t": 1730749500000,           // Kline start time
        "T": 1730750399999,           // Kline close time
        "i": "1m",                   // Interval (15 minutes)
        "f": 1,                       // First update ID
        "L": 1,                       // Last update ID
        "o": "211211",                // Open price
        "c": "211224",                // Close price
        "h": "211467",                // High price
        "l": "211188",                // Low price
        "v": "778.018",               // Volume
        "n": 1,                       // Number of trades
        "x": false,                   // Is this kline closed?
        "q": null,                    // Quote asset volume (null here)
        "V": null,                    // Taker buy volume (null here)     
        "Q": null,                    // Taker buy quote asset volume 
        "B": null                     // Ignore
      }
    }
    
    

Agg Trade (Aggregate Trade)

Real-time details of aggregated trades grouped by price for a specific symbol.


Stream Name: <symbol>@aggTrade

Example: btcinr@aggTrade

Listening Event Name: aggTrade

Event Structure

                    
    Action: receive
    Message Name: "aggTrade"
    Message Data:
    {
      "e": "aggTrade",          // Event type
      "E": 1730749897776,       // Event time
      "a": 1828600727,          // Aggregate trade ID
      "s": "ETHINR",            // Symbol
      "p": "211156",            // Price
      "q": "0.211",             // Quantity
      "f": 4586488827,          // First trade ID
      "l": 4586488828,          // Last trade ID
      "T": 1730749897666,       // Trade time
      "m": true                 // Is the buyer the market maker?
    }
                    
                    

Mark Price Update

Provides the mark price, index price, and funding rate for a specific symbol.


Stream Name: <symbol>@markPrice

Example: btcinr@markPrice

Listening Event Name: markPriceUpdate

Event Structure

                    
    Action: receive
    Message Name: "markPriceUpdate"
    Message Data:
    {
      "e": "markPriceUpdate",          // Event type
      "E": 1707634490000,              // Event time
      "s": "BTCINR",                   // Symbol
      "p": "4334823.66859808",         // Market price
      "P": "4335379.542328075",        // Estimated settle price
      "i": "4336589.925536482",        // Index price
      "r": "-0.0027",                  // Funding rate
      "T": 1707638400000               // Next funding time
    }
                    
                    

24hr Ticker Update

Provides rolling 24-hour price statistics, including last trade price, highest/lowest prices, and volume.


Stream Name: <symbol>@ticker

Example: btcinr@ticker

Listening Event Name: 24hrTicker

Event Structure

                    
    Action: receive
    Message Name: "24hrTicker"
    Message Data:
    {
      "e": "24hrTicker",               // Event type
      "E": 1707635719309,              // Event time
      "s": "BTCINR",                   // Symbol
      "p": "87845.124",                // Price change over 24 hours
      "P": "2.116",                    // Price change percentage
      "w": "4188295.5225",             // Weighted average price
      "c": "4239633.639",              // Last price
      "Q": "0.003",                    // Last quantity
      "o": "4151788.515",              // Open price
      "h": "4267566",                  // High price
      "l": "4112704.2840000005",       // Low price
      "v": "222797.117",               // Base asset volume
      "q": "10626810856.19",           // Quote asset volume
      "O": 1707549300000,              // Open time
      "C": 1707635719307,              // Close time
      "F": 4575372791,                 // First trade ID
      "L": 4578191477,                 // Last trade ID
      "n": 2818668                     // Number of trades
    }

                    
                    

All Contract Details

Provides general details for all contracts, including last trade price, market price, and 24-hour price change percentage.


Stream Name: N/A (No specific symbol-based stream name is required for this event)

Listening Event Name: allContractDetails

Event Structure

                    
    Action: receive
    Message Name: "allContractDetails"
    Message Data:
    {
      "XRPINR": {
        "lastPrice": "46.2545",           // Last trade price
        "marketPrice": "46.2366455382",   // Current market price
        "priceChangePercent": "0.725",    // 24-hr price change %age per
        "baseAssetVolume": "487166675.8"  // base asset volume in 24 hrs
      },
      "MATICINR": {
        "lastPrice": "74.9827",
        "marketPrice": "75.02073812399999",
        "priceChangePercent": "0.845",
        "baseAssetVolume": "236293682"
      },
      // Additional symbols...
    }


                    
                    

Futures Websocket User

The private socket API enables real-time access to user-specific data such as order updates, position status, and balance changes. This secure data stream requires authentication via the access_token.



Connection Setup:
To access private user order specific data streams, establish a WebSocket connection to the following URL using a socket client like socket.io

WS URL: wss://futuresws.zebpay.com/socket.io

Namespace: /auth-stream

Authentication:
The private socket requires clients to pass an access_token and client_type during the handshake. The token should be included as part of the auth object in the WebSocket client’s connection request.


Listening to Events:
To listen for events, establish a WebSocket connection with the required authentication token and client type fields. Each event type has its own payload structure as defined below.

Example Connection Request

                        
    {
      "url": "wss://futuresws.zebpay.com/socket.io",
      "namespace": "/auth-stream",
      "transport": "websocket",
      "auth": {
        "token": "access_token",    // JWT token for authentication
        "clientType": "api"         // 'api' for api client type
      }
    }
                        
                    

Order events

Order-related events for actions like filled, partially filled, canceled, failed, and new orders.


Listening Event Name:

1. newOrder: New active order in the open order book.
2. orderFilled: Order fully filled, removed from open orders.
3. orderPartiallyFilled: Update filled amount with cumulative quantity (cumQty).
4. orderCancelled: Triggered when an order is cancelled by the user.
5. orderFailed: Triggered when an order placement fails and removed from open orders.

All order events share the same message data structure.

Event Structure (newOrder)

                    
    Action: receive
    Message Name: "newOrder" or “orderFilled or “orderPartiallyFilled”, “orderCancelled” or “orderFailed”
    Message Data:
    {
      "eventTime": "1696425435000000000",
      "accountId": 5,
      "orderId": 3133,
      "clientOrderId": "07227f7c2236b71b4b31-5-ext",
      "time": "2024-05-10T13:26:00.144Z",
      "updateTime": "2024-05-10T13:26:00.237Z",
      "symbol": "BTCINR",
      "baseAsset": "BTC",
      "quoteAsset": "INR",
      "contractType": "PERPETUAL",
      "type": "MARKET",
      "side": "BUY",
      "price": 5739874,
      "status": "NEW",
      "avgPrice": 0,
      "executedPrice": 0,
      "orderAmount": 0.002,
      "executedAmount": 0,
      "filledAmount": 0,
      "cumQty": 0,
      "linkId": "07227f7c2236b71b4b31-5-ext",
      "linkType": "ORDER",
      "subType": "PRIMARY",
      "placeType": "ORDER_FORM",
      "market": "INR",
      "marginAsset": "INR"
    }
                    
                     

Position Events

Position-related events for new, updated, and closed positions.

Event Types:

1. newPosition: Creates a new entry in the position book.
2. updatePosition: Updates an existing position in the position book.
3. closePosition: Closes a position from the position book.


All position events share the same message data structure.

Event Structure

                    
    Action: receive
    Message Name: "newPosition" or "updatePosition" or "closePosition"
    Message Data:
    {
        "eventTime": "1696425435000000000",
        "accountId": 5,
        "contractPair": "BTCINR",
        "contractType": "PERPETUAL",
        "entryPrice": 5705246,
        "leverage": 10,
        "liquidationPrice": 5199116,
        "marginType": "ISOLATED",
        "margin": 3441.36,
        "positionAmount": 0.002,
        "positionId": "3aa3b75a-20fb-4f1f-a49f-333bc45559c3",
        "positionSize": 34231.48,
        "positionStatus": "OPEN",
        "positionType": "LONG",
        "realizedProfit": 0,
        "quantity": 0.006,
        "market": "INR",
        "marginAsset": "INR",
        "marginConversionRate": 1,
        "marginSettlementRate": 1,
        "marginInMarginAsset": 3441.36,
        "realizedProfitInMarginAsset": 0
    }

                    
                     

Balance Events

Real-time updates to user balances, including total, locked, and available balances.

Event Types:

balanceUpdate: Provides any update to the user’s wallet balances.

All position events share the same message data structure.

Event Structure

                    
    Action: receive
    Message Name: "balanceUpdate"
    Message Data:
    {
      "eventTime": "1696425435000000000", // Event timestamp in nanosecs
      "accountId": 7,                     // account ID
      "updatedWalletBalance": 1989.26,    // Total balance after update
      "updatedLockedBalance": 1053.18,    // Balance currently locked
      "updatedAvailableBalance": 936.08,  // Balance available for use
      "asset": "INR"                    // Asset in which bal is updated
    }
                    
                     

Trade Events

Triggered when a new trade is executed for a specific account. Provides details of the trade.

Listening Event Name: newTrade

Event Structure

                    
    Action: receive
    Message Name: "newTrade"
    Message Data:
    {
      "eventTime": "1696425435000000000", // in nanosecs
      "accountId": 5,                     // ID of the user account
      "tradeId": 2616,                    // Unique trade identifier
      "clientOrderId": "be9c210d2934b67b7a82-5-ext",   
      "tradeTime": "2024-05-10T13:28:36.377Z", 
      "symbol": "BTCINR",                 // Trading pair symbol
      "side": "BUY",                    
      "executedPrice": 5701423,        
      "executedQuantity": 0.029,         
      "fee": 0,                           // Fee for the trade 
      "realizedPnl": 0,
      "role": "maker",                            
      "market": "INR",                  
      "marginAsset": "INR",              
      "positionId": "examplePositionId"   // Position ID linked to trade 
    }

                    
                     

Liquidation Events

Events triggered to notify the user when they are over leveraged or have been liquidated.

Event Types:

1. marginCallAlert: Triggered when the utilisation ratio hits 80%
2. liquidationAlert: Triggered when liquidation of a position is initiated.

Event Structure (marginCallAlert)

                        
   Action: receive
   Message Name: "marginCallAlert"
   Message Data:
   {
     "eventTime": "1696425435000000000", // margin call ts in nanosecs
     "accountId": 7,                     
     "contractPair": "BTCINR",           
     "marginRequired": 500.00,  // margin reqd to prevent liquidation
     "currentMargin": 200.00,   // current margin level for the position
     "positionType": "LONG",            
     "positionId": "88e19883-e7e2-4318-95ba-bb9db39117ad",  
   }

                        
                     


Event Structure (liquidationAlert)

                    
    Action: receive
    Message Name: "liquidationAlert"
    Message Data:
    {
      "eventTime": "1696425435000000000", // liquidation ts in nanosecs
      "accountId": 7,                    
      "contractPair": "BTCINR",         
      "liquidationPrice": 3448000.64,     
      "positionType": "LONG",            
      "quantity": 0.003,                  // Qty of asset liquidated
      "positionId": "88e19883-e7e2-4318-95ba-bb9db39117ad"
    }