Post
Topic
Board Announcements (Altcoins)
Re: [ANN][RIC] Riecoin: constellations POW *CPU* HARD FORK successful, world record
by
guytp
on 27/06/2018, 21:05:51 UTC
Do you have an API available?

You asked about APIs for market making a couple of weeks ago.  We've now added a way to do this into Zapple without needing to authenticate with your username and password and by restriction API keys to specific roles as you requested.  We've still not got formal docs for API written up but the below should help to give you enough for a market making bot.  Excuse the lack of formatting in the post - wanted to get something up before I get to bed today.

First login to Zapple, go to Settings and click on Manage API Keys.  Give it a name and an optional expiry.  For roles if you want the bot to be able to get balances you want "Account Info", to access information about trades (history, open trades, etc.) check "Trade History" and to open and close trades you want "Trading".  Click "Add" and you'll be given a long secret string.  Keep this safe.

For you bot to login it must make a PUT to https://zapple.com/api/auth/1/api-keys/authenticate

The body should be JSON object as below.

{
  "Username": "Your Username",
  "Key": "What You Got Above",
  "ApplicationName": "Name Of Your Bot Software - Can Be Anything"
}


You will get a response back which includes a few pieces of information.  The main one is "JsonWebToken".  You need this to authenticate against other methods.


For every other request you need to use this JsonWebToken (JWT) to authenticate.  To do so add the header:

Authorization: BEARAR YourJwtHere

Replacing YourJwtHere with what you got in the authenticate step.



Every 15 minutes the token you just got given will time out.  You can either log back in when you get a 401 or after 10 minutes or thereabout call a GET to https://zapple.com/api/auth/1/renew including the authorization header.  You'll get a new response back of the same format as authenticate but with a newly extended JWT valid for another 15 minutes.


You can test these methods out with a UI at: https://lts-api.com/dev/auth/1/_md/index#/ApiKey


You can view a list of all possible exchange API methods at https://zapple.io/exchange/1/_md/.  You authenticate against these in the same way - with the Authorization header.


The main methods you care about will be these below.  You can see example calls and full data returned at the above URL.

Get a list of balances: GET https://zapple.io/exchange/1/balances

Get the order-book for RICBTC: GET https://zapple.io/exchange/1/order-book/RICBTC

Get recent trades for RICBTC: GET https://zapple.io/exchange/1/trades/RICBTC

Get full details for one of your orders: GET https://zapple.io/exchange/1/orders/YourOrderId

Createa a new order: POST https://zapple.io/exchange/1/orders/NewOrderId
   The NewOrderId should be a UUID that you generate
   The body is as follows:
{
  "InstrumentId": 6,
  "QuantityOrdered": XXX,
  "Side": "Buy or Sell",
  "LimitPrice": XXX or null
}

Cancel an open order: DELETE https://zapple.io/exchange/1/orders/YourOrderId

Get a list of all orders you have open: GET https://zapple.io/exchange/1/orders?instrument=RICBTC