NAV Navbar
Python

Introduction

Welcome to the Vexbi API! We at Vexbi provide a simple and robust RESTful API to interact with our exchange.

At this time, we have language bindings for Python with more to come! You can view code examples on the right.

API Versions

All API calls are versioned, and the current Vexbi API is v1.0. We will never introduce any breaking changes within any version, but may add new, non-breaking features and enhancements from time to time.

Sandbox environment

For your convenience Vexbi offers a Sandbox environment where you can confidently test your code.

To start using the API in the Sandbox environment you need to first create an account at sandbox.vexbi.com.

Once you have an account you will need an APP_ID and an APP_SECRET which you can generate in sandbox.vexbi.com/access_tokens.

Just change the www.vexbi.com for sandbox.vexbi.com in every endpoint that you use.

Production environment

To start using the API in the Production environment you need to first create an account at vexbi.com.

Once you have an account you will need an APP_ID and an APP_SECRET which you can generate in vexbi.com/authentications.

Vexbi-supported SDKs

We currently suppport Python but are working on adding more languages.

Python

# Import the API Client 
from vexbi import API

# Configure Vexbi Library, you will 
# pass this to every call you make to our servers.
api = API(app_id='APP_ID', secret_key='APP_SECRET')

# If you want to make tests without impacting your funds
# you can use our sandbox environment with:
api.use_sandbox()

The best way to install the Vexbi lib is with PIP. To install the most recent version please run the following command.

pip install vexbi

You can find the repo at github.com/Vexbi/python-api-client

Authentication

When not using a Vexbi supported SDK, you need to authenticate manually to submit API calls. Vexbi uses SHA1 HMAC encryption to authenticate API calls. Each request has to be authenticated by following these steps:

  1. A canonical string is first created using your HTTP headers containing the content-type, content-MD5, request URI and the timestamp. You can replace content-type and content-MD5 with a blank string if needed. The timestamp must be a valid HTTP date. The canonical string is computed as follows:

canonical_string = 'http method,content-type,content-MD5,request URI,timestamp'

  1. This string is then used to create the signature, which is a Base64 encoded SHA1 HMAC, using the APP_SECRET key.

  2. This signature is then added as the Authorization HTTP header in the following form:

Authorization: APIAuth APP-ID:signature-from-step-2

Account

Interact with your profile and accounts.

Get Account Info

# Get Account Info
from vexbi import API
api = API(app_id='APP_ID', secret_key='APP_SECRET')

account_info = api.get_account_info()
email = account_info["email"]

Response from Vexbi:

{
  "sn": "SNDF3EF88F00",
  "email": "your@email.com",
  "accounts": [
    {
      "currency": "xrp",
      "balance": "5000.0",
      "locked": "0.0"
    },
    {
      "currency": "bch",
      "balance": "0.0574985",
      "locked": "0.0315"
    },
    {
      "currency": "ltc",
      "balance": "3.99",
      "locked": "0.0"
    },
    {
      "currency": "btc",
      "balance": "0.13012197",
      "locked": "0.05"
    },
    {
      "currency": "mxn",
      "balance": "97969.238561911",
      "locked": "0.0"
    }
  ]
}

Get your profile and accounts info.

HTTP Request

GET https://www.vexbi.com/api/v2/members/me

Responses
Code Description
200 Get your profile and accounts info.

Markets

Fetch information about markets.

Get Available Markets

# Get Available Markets
from vexbi import API
api = API(app_id='APP_ID', secret_key='APP_SECRET')

markets = api.get_available_markets()

Response from Vexbi:

[
  {
    "id": "btcmxn",
    "name": "BTC/MXN"
  },
  {
    "id": "ltcmxn",
    "name": "LTC/MXN"
  },
  {
    "id": "bchmxn",
    "name": "BCH/MXN"
  },
  {
    "id": "xrpmxn",
    "name": "XRP/MXN"
  }
]

Get all available markets.

HTTP Request

GET https://www.vexbi.com/api/v2/markets

Responses
Code Description
200 Get all available markets.

Get Tickers

# Get Tickers
from vexbi import API
api = API(app_id='APP_ID', secret_key='APP_SECRET')

tickers = api.tickers()

Response from Vexbi:


  "btcmxn": {
    "at": 1544814469,
    "ticker": {
      "buy": "68668.714434",
      "sell": "70000.0",
      "low": "71285.84813089",
      "high": "71285.84813089",
      "last": "71285.84813089",
      "vol": "0.1"
    }
  },
  "ltcmxn": {
    "at": 1544814469,
    "ticker": {
      ...
    }
  },
  "bchmxn": {
    "at": 1544814469,
    "ticker": {
      ...
    }
  },
  "xrpmxn": {
    "at": 1544814469,
    "ticker": {
      ...
    }
  }
}

Get tickers for all markets.

HTTP Request

GET https://www.vexbi.com/api/v2/tickers

Responses
Code Description
200 Get tickers for all markets.

Orders

Managing orders programatically can be done using the following methods.

Create Order

# Create Order
from vexbi import API
api = API(app_id='APP_ID', secret_key='APP_SECRET')

order_data = {
  'market': 'btcmxn', 
  'side': 'sell',
  'volume': '0.05',
  'price': '70000.0'
}
order = api.create_order(order_data=order_data)

Response from Vexbi:

{
  "id": 50790,
  "side": "sell",
  "ord_type": "limit",
  "price": "70000.0",
  "avg_price": "0.0",
  "state": "wait",
  "market": "btcmxn",
  "created_at": "2018-12-14T13:19:24-06:00",
  "volume": "0.05",
  "remaining_volume": "0.05",
  "executed_volume": "0.0",
  "trades_count": 0
}

Create and place a new sell/buy order.

HTTP Request

POST https://www.vexbi.com/api/v2/orders

Parameters
Field Type Description
market String Unique market id. It's always in the form of xxxyyy, where xxx is the base currency code, yyy is the quote currency code, for example 'BTCMXN'. All available markets can be found at /api/v2/markets.
side String Either 'sell' or 'buy'.
volume String The amount to sell or buy. Bear in mind that an order can be partially executed. For example a sell order of 5 BTC can be matched with a buy order for 3 BTC, resulting in an outstanding balance of 2 BTC waiting to be sold. For this scenario the order's volume would be '5.0', its remaining_volume would be '2.0' and its executed volume would be '3.0'.
price String Optional. (Defaults to market price) Price for each unit. For example If you want to sell/buy 1 BTC at 3000 MXN, the price is '3000.00'
Responses
Code Description
201 Create a Sell/Buy order.

Cancel an Order

# Cancel Order
from vexbi import API
api = API(app_id='APP_ID', secret_key='APP_SECRET')

order = api.delete_order(order_id=10)

Response from Vexbi:

{
  "id": 50790,
  "side": "sell",
  "ord_type": "limit",
  "price": "70000.0",
  "avg_price": "0.0",
  "state": "wait",
  "market": "btcmxn",
  "created_at": "2018-12-14T13:19:24-06:00",
  "volume": "0.05",
  "remaining_volume": "0.05",
  "executed_volume": "0.0",
  "trades_count": 0
}

Cancel an order already placed.

HTTP Request

POST https://www.vexbi.com/api/v2/order/delete

Parameters
Name Type Description
id Integer Unique order id.
Responses
Code Description
201 Cancel an order.

Cancel All Orders

# Cancel All Orders
from vexbi import API
api = API(app_id='APP_ID', secret_key='APP_SECRET')

clear_selection = { 'side': 'sell' }
result = api.clear_all(data=clear_selection)

Response from Vexbi:

[
  {
    "id": 50789,
    "side": "sell",
    "ord_type": "limit",
    "price": "70000.0",
    "avg_price": "0.0",
    "state": "wait",
    "market": "btcmxn",
    "created_at": "2018-12-14T13:16:34-06:00",
    "volume": "0.05",
    "remaining_volume": "0.05",
    "executed_volume": "0.0",
    "trades_count": 0
  },
  {
    "id": 50853,
    ...
  },
  ...
]

Cancel all your open orders or open orders for a specific side only.

HTTP Request

POST https://www.vexbi.com/api/v2/orders/clear

Parameters
Name Type Description
side String Optional. (sell or buy) If present, only sell orders (asks) or buy orders (bids) will be cancelled.
Responses
Code Description
201 Cancel all my orders.

Get Order

# Get Order
from vexbi import API
api = API(app_id='APP_ID', secret_key='APP_SECRET')

order = api.get_order(order_id=50792)
order["id"]
order["remaining_volume"]

Response from Vexbi:

{
  "id": 50792,
  "side": "sell",
  "ord_type": "limit",
  "price": "70000.0",
  "avg_price": "0.0",
  "state": "wait",
  "market": "btcmxn",
  "created_at": "2018-12-14T13:19:24-06:00",
  "volume": "0.05",
  "remaining_volume": "0.05",
  "executed_volume": "0.0",
  "trades_count": 0,
  "trades": []
}

Get an open order.

HTTP Request

GET https://www.vexbi.com/api/v2/order?id=_ID_

Parameters
Name Type Description
id String Unique order id.
Responses
Code Description
200 Get a specific order.

Get Orders (paginated)

# Get Orders (Paginated)
from vexbi import API
api = API(app_id='APP_ID', secret_key='APP_SECRET')

query = { 'limit': 30 }
orders = api.get_orders(market='btcmxn', query=query)

Response from Vexbi:

[
  {
    "id": 50792,
    "side": "sell",
    "ord_type": "limit",
    "price": "70000.0",
    "avg_price": "0.0",
    "state": "wait",
    "market": "btcmxn",
    "created_at": "2018-12-14T13:19:24-06:00",
    "volume": "0.05",
    "remaining_volume": "0.05",
    "executed_volume": "0.0",
    "trades_count": 0
  },
  ...
]

Get a list of existent orders.

HTTP Request

GET https://www.vexbi.com/api/v2/orders?market=_MKT_&limit=_LIMIT_

Parameters
Name Type Description
market String Unique market id. It's always in the form of xxxyyy, where xxx is the base currency code, yyy is the quote currency code, for example 'BTCMXN'. All available markets can be found at /api/v2/markets.
state String Optional. Filter order by state, default to 'wait' (open orders).
limit Integer Optional. (Defaults to 100) Limit the number of returned orders.
page Integer Optional. Specify the page of paginated results.
order_by String Optional. (Defaults to asc) If set, returned orders will be sorted in a specific order.
Responses
Code Description
200 Get a list of orders.

Trades

Fetch information about trades.

Get Market Trades

# Get Market Trades
from vexbi import API
api = API(app_id='APP_ID', secret_key='APP_SECRET')

query = {
  'limit': 80,
  'from': 10
}
trades = api.trades(market='btcmxn', query=query)

Response from Vexbi json [ { "id": 563, "price": "71285.84813089", "volume": "0.1", "funds": "7128.584813089", "market": "btcmxn", "created_at": "2018-12-14T12:46:15-06:00", "side": null, "type": "buy" }, { "id": 562, "price": "68668.714434", "volume": "0.00343854", "funds": "236.12012132988636", "market": "btcmxn", "created_at": "2018-12-12T16:48:18-06:00", "side": null, "type": "sell" }, ... ]

Get recent trades (each trade is included only once). Trades are sorted in order of most recent to least recent.

HTTP Request

GET https://www.vexbi.com/api/v2/trades

Parameters
Name Type Description
market String Unique market id. It's always in the form of xxxyyy, where xxx is the base currency code, yyy is the quote currency code, for example 'BTCMXN'. All available markets can be found at /api/v2/markets.
limit Integer Optional. Limit the number of returned trades. Default to 50.
timestamp Integer Optional. An integer represents the seconds elapsed since UNIX Epoch. If set, only trades executed before the time will be returned.
from Integer Optional. Trade id. If set, only trades created AFTER this will be returned.
to Integer Optional. Trade id. If set, only trades created BEFORE this will be returned.
order_by String Optional. If set, returned trades will be sorted in a specific order, defaulting to ‘desc’ (descending).
Responses
Code Description
200 Get recent trades on market.

Get My Trades

# Get My Trades
from vexbi import API
api = API(app_id='APP_ID', secret_key='APP_SECRET')

query = {
  'from': 10,
  'to': 120
}
trades = api.my_trades(market='btcmxn', query=query)

Response from Vexbi:

[
  {
    "id": 563,
    "price": "71285.84813089",
    "volume": "0.1",
    "funds": "7128.584813089",
    "market": "btcmxn",
    "created_at": "2018-12-14T12:46:15-06:00",
    "side": "bid",
    "order_id": 50787,
    "type": "buy"
  },
  {
    "id": 46,
    "price": "185000.0",
    "volume": "0.001",
    "funds": "185.0",
    "market": "btcmxn",
    "created_at": "2018-11-06T18:48:50-06:00",
    "side": "ask",
    "order_id": 1605,
    "type": "buy"
  },
  ...
]

Get your executed trades. Trades are sorted in order of most to least recent.

HTTP Request

GET https://www.vexbi.com/api/v2/trades/my

Parameters
Name Type Description
market String Unique market id. It's always in the form of xxxyyy, where xxx is the base currency code, yyy is the quote currency code, for example 'BTCMXN'. All available markets can be found at /api/v2/markets.
limit Integer Optional. Limit the number of returned trades. Default to 50.
timestamp Integer Optional. An integer represents the seconds elapsed since UNIX Epoch. If set, only trades executed before the time will be returned.
from Integer Optional. Trade id. If set, only trades created AFTER this will be returned.
to Integer Optional. Trade id. If set, only trades created BEFORE this will be returned.
order_by String Optional. If set, returned trades will be sorted in a specific order, defaulting to ‘desc’ (descending).
Responses
Code Description
200 Get your executed trades.