Python example to make use of the Nova Exchange API
#!/usr/bin/python
import time
import hmac
import hashlib
import base64
import requests
API_KEY = "YOUR_API_KEY"
API_SECRET = "YOUR_API_SECRET"
public_set = set([ "markets", "market/info", "market/orderhistory", "market/openorders" ]) # optional
private_set = set([ "getbalances", "getbalance", "getdeposits", "getwithdrawals", "getnewdepositaddress", "getdepositaddress", "myopenorders", "myopenorders_market", "cancelorder", "withdraw", "trade", "tradehistory", "getdeposithistory", "getwithdrawalhistory", "walletstatus" ])
url = "https://novaexchange.com/remote/v2/"
def api_query( method, req = None ):
url = "https://novaexchange.com/remote/v2/"
if not req:
req = {}
if method.split('/')[0][0:6] == 'market':
r = requests.get( url + method + '/', timeout = 60 )
elif method.split('/')[0] in private_set:
url += 'private/' + method + '/' + '?nonce=' + str( int( time.time() ) )
req["apikey"] = API_KEY
req["signature"] = base64.b64encode( hmac.new( API_SECRET, msg = url, digestmod = hashlib.sha512 ).digest() )
headers = {'content-type': 'application/x-www-form-urlencoded'}
r = requests.post( url, data = req, headers = headers, timeout = 60 )
return r.text
# Eample usage:
# Public:
# print api_query( "markets" )
print api_query( "market/orderhistory/" + "LTC_DOGE" )
# etc...
# Private:
print api_query("getbalances")
# print api_query( "trade/" + "LTC_DOGE", { 'tradebase': 0, 'tradetype': "BUY", 'tradeprice': 0.000001, 'tradeamount': 1000 } )
# print api_query( 'cancelorder/' + str( 1426936 ) )
# print api_query( 'tradehistory' )
# etc...
Important
Use the trailing slash on every request or your API Auth will fail. The URL listed is the exact URL needed to access Nova Exchange by API.
The binary signature of the request has to be a base64 encoded string before sent to the server.
Nonce is enforced on private API calls in APIv2 and has to be included in url before signing it with your secret key.
List markets summary, including cached tickerdata (Limited to 1 request per minute).
URL: /remote/v2/markets/
Request limits: 15 per minute
Params: None
Expected response
{
"status": "success",
"message": "Markets listed at Nova Exchange",
"markets":
[{
"currency": "LTC",
"low24h": 0.00000000,
"marketname": "LTC_BTC",
"high24h": 0.00000000,
"ask": 0.00000000,
"bid": 0.00000000,
"change24h": 0.00000000,
"last_price": 0.00000000,
"volume24h": 0.00000000,
"basecurrency": "BTC",
"marketid": 20,
"disabled": 1
},
{
"currency": "NYAN",
"low24h": 0.00000000,
"marketname": "BTC_LTC",
...
}]
}
List markets summary for base currency.
URL: /remote/v2/markets/<base-currency>
Request limits: 2 per minute
Params: None
Expected response
{
"status": "success",
"message": "Markets listed at Nova Exchange",
"markets":
[{
"basecurrency": "DOGE",
"ask": "9999999.00000000",
"bid": "600000.00000000",
"change24h": "0.0",
"currency": "42",
"disabled": 0,
"high24h": "7133133.10000000",
"last_price": "7133133.10000000",
"low24h": "7133133.10000000",
"marketid": 7049,
"marketname": "DOGE_42",
"volume24h": "0.000"
},
{
"ask": "0.00000000",
"basecurrency": "DOGE",
"bid": "0.30000001",
...
}]
}
Market summary for a single market
URL: /remote/v2/market/info/<market>/
Request limits: 20 per second
Params: None
Expected response
{
"status": "success",
"message": "Info for market: BTC_XZC",
"markets": [{
"bid": "0.00880000",
"last_price": "0.00873000",
"volume24h": "133.955",
"marketid": 3198,
"currency": "XZC",
"marketname": "BTC_XZC",
"ask": "0.00890067",
"low24h": "0.00750000",
"change24h": "-0.8",
"high24h": "0.01285006",
"basecurrency": "BTC",
"disabled": 0
}]
}
Ticker / Order history for market
URL: /remote/v2/market/orderhistory/<market>/
Request limits: 20 per second
Params: None
Expected response
{
"status": "success",
"message": "Order history for market: LTC_MEOW",
"items":
[{
"tradetype": "BUY",
"baseamount": 0.0084,
"price": 0.00000007,
"currency": "MEOW",
"amount": 120000.0,
"datestamp": "2016-03-20 16:12",
"basecurrency": "LTC"
}, {
"tradetype": "BUY",
"baseamount": 0.0056,
"price": 0.00000007,
...
}]
}
Open orders for market
URL: /remote/v2/market/openorders/<market>/<ordertype>/
Request limits: 20 per second
Params:
Ordertype can be: SELL, BUY or BOTH
Expected response
{
"status": "success",
"buyorders":
[{
"currency": "MEOW",
"amount": "440050.01000000",
"price": "0.00000006",
"basecurrency": "LTC",
"baseamount": "0.02640300"
}],
"sellorders":
[{
"currency": "MEOW",
"amount": "2040408.15913683",
"price": "0.00000007",
"basecurrency": "LTC",
"baseamount": "0.14282857"
},
{
"currency": "MEOW",
"amount": "100000.00000000",
"price": "0.00000008",
...
}]
}
Private calls - API Keys required, with permissions set accordingly.
List balances in account
URL: /remote/v2/private/getbalances/
Request limits: 2 per minute
Params: None
Expected response
{
"status": "success",
"message": "Your currency balances",
"balances":
[{
"currencyid": 1,
"currency": "BTC",
"currencyname": "Bitcoin",
"amount": "0.00189703",
"amount_trades": "0.00000000",
"amount_lockbox": "0.00000000",
"amount_total": "0.00189703"
},
{
"currencyid": 2,
"currency": "LTC",
...
}]
}
List a specific currency balance
URL: /remote/v2/private/getbalance/<currency>/
Request limits: 15 per minute
Params: None
Expected response
{
"status": "success",
"message": "Your MEOW balance",
"balances":
[{
"currency": "MEOW",
"amount": "2761401.22909113",
"amount_trades": "1661726.92791246",
"currencyid": 5,
"amount_reserved": "0.00000000",
"amount_total": "4423128.15700359",
"currencyname": "Kittehcoin",
"amount_lockbox": "0.00000000"
}]
}
Get current incoming deposits
URL: /remote/v2/private/getdeposits/
Request limits: 20 per second
Params: None
Expected response
{
"status": "success",
"message": "Your incoming deposits",
"depositqueue":
[{
"confirmations_needed": 20,
"tx_address": "AURSLfipnFudU4GaEwuEEr5mybvz9UbB8W",
"currencyid": 24,
"is_confirmed_date": "None",
"tx_amount": "2.50000474",
"currency": "ANC",
"is_accounted": 0,
"is_accounted_date": "None",
"tx_txid": "175a83822ea45d04561ffe9ff419f6202139bbc6ddb1ca5d211529fe9fb77269",
"tx_confirmations": "2.50000474",
"is_confirmed": 0,
"tx_timereceived": "2016-03-24 00:02:00"
},
{
"confirmations_needed": 30,
"tx_address": "BScpntUqc4PYTNkKtCAmKGwokeH7sxEEUx",
...
}]
}
Get current outgoing withdrawals
URL: /remote/v2/private/getwithdrawals/
Request limits: 20 per second
Params: None
Expected response
{
"status": "success",
"message": "Your outgoing transactions",
"depositqueue":
[{
"status": 1,
"confirmations_needed": 3,
"tx_address": "KAZYLd6hqCQkWN1srZGVWzg13s8fUDGVcx",
"currencyid": 5,
"is_confirmed_date": "None",
"tx_amount": "3997.99000000",
"currency": "MEOW",
"tx_confirmations": 0,
"approved": 1,
"tx_txid": "cb4839d9ad1e8e87b20ee77372ecd9332add91842ed101c029d1b4787595dc5a",
"date_requested": "2016-03-24 00:02:00",
"is_confirmed": 0,
"date_sent": "2016-03-24 13:27:41"
},
{
"status": 1,
"confirmations_needed": 3,
...
}]
}
Create a new deposit address for currency
URL: /remote/v2/private/getnewdepositaddress/<currency>/
Request limits: 20 per second
Params: None
Expected response
{
"status": "success",
"message": "New deposit address for TRUMP",
"address": "TD7UbTSWx9gZEXTN2xS1F6DRTB8iSKva1S"
}
Deposit address for currency
URL: /remote/v2/private/getdepositaddress/<currency>/
Request limits: 20 per second
Params: None
Expected response
{
"status": "success",
"message": "Deposit your TRUMP to this address",
"address": "TF6UXNy2QFr4pWKLLeLm9nQLnNM1Pu2Ku1"
}
My open orders
URL: /remote/v2/private/myopenorders/
Request limits: 20 per second
Params: 1
page: 1 (optional, will return page 1 default)
Expected response
{
"status": "success",
"total_items": 121,
"perpage": 100,
"page": 1,
"message": "Your open orders with recent first",
"pages": 2,
"items":
[{
"orderid": 348,
"fromamount": "2467567.37261500",
"fromcurrency": "SPN",
"ordertype": "SELL",
"price": "0.00000001",
"tocurrency": "BTC",
"orderdate": "2016-03-30 10:42",
"market": "BTC_SPN",
"toamount": "0.02467567"
},
{
"orderid": 347,
"fromamount": "4095.80432940",
"fromcurrency": "YACC",
...
}]
}
My open orders on a Market
URL: /remote/v2/private/myopenorders_market/<market>/
Request limits: 20 per second
Params: None
Expected response
{
"status": "success",
"message": "Your open orders for BTC_ARI with recent first",
"items":
[{
"orderid": 258,
"fromamount": "189703.00000000",
"fromcurrency": "ARI",
"ordertype": "BUY",
"price": "0.00000001",
"tocurrency": "BTC",
"orderdate": "2016-03-28 23:46",
"market": "BTC_ARI",
"toamount": "0.00189703"
},
{
"orderid": 257,
"fromamount": "1994.49480298",
"fromcurrency": "ARI",
...
}]
}
Cancel order
URL: /remote/v2/private/cancelorder/<orderid>/
Request limits: 2 per second
Params: None
Expected response
{
'status': 'ok',
'message': 'Order canceled'
}
Withdraw
URL: /remote/v2/private/withdraw/<currency>/
Request limits: 20 per second
Params: 3
currency: MEOW
amount: 1000.12345678
address: KF2yLFLcZwYigRDw5Uo9U4B9hEaLqwkVxL
Expected response
{
"status": u"success",
"amount_after_withdraw": u"500243.25012310",
"amount": u"1000.00000000",
"tx_fee": u"0.01000000",
"amount_in_orders": u"3217070.76321477",
"currency": u"MEOW",
"amount_sent": u"999.49000000",
"address": u"KF2yLFLcZwYigRDw5Uo9U4B9hEaLqwkVxL",
"amount_before_withdraw": u"501243.25012310",
"message": u"Withdrawal requested successfully",
"wd_fee": u"0.50000000"
}
Trade
URL: /remote/v2/private/trade/<market_name>/
Request limits: 2 per seconds
Params: 4
tradetype: BUY or SELL
tradeamount: 8000.00000000
tradeprice: 0.00000008
tradebase: 0 (Set as 0 for market currency or 1 for basecurrency as tradeamount)
Expected response
{
'status': 'success',
'message': 'Trade details as follows',
'tradetype': 'SELL',
'fee_currency': 'LTC',
'tradeitems':
[{
'type': 'trade',
'price': '0.00000006',
'tocurrency': 'LTC',
'toamount': '0.00011994',
'net_total': '0.00011970',
'fromcurrency': 'MEOW',
'tradefee': '0.00000024',
'fromamount': '1999.00000000',
'orderid': 1234
},
{
'type': 'created',
'price': '0.00000006',
'tocurrency': 'LTC',
'orderid': 1234,
'toamount': '0.00036006',
...
}]
}
Trade history
URL: /remote/v2/private/tradehistory/
Request limits: 20 per second
Params: 1
page: 1 (optional, will return page 1 default)
Expected response
{
"status": "success",
"total_items": 175,
"perpage": 100,
"page": 1,
"message": "Your trade history with recent first",
"pages": 2,
"items":
[{
"tradetype": "BUY",
"tradeid": 437,
"price": "0.00000003",
"toamount": "0.00368630",
"fromamount": "123123.00000000",
"fee": "0.00000739",
"tocurrency": "LTC",
"trade_time": "2016-03-22 14:06",
"fromcurrency": "BUN",
"orig_orderid": 229,
"basecurrency": "LTC"
},
{
"tradetype": "SELL",
"tradeid": 436,
"price": "0.00000003",
...
}]
}
Deposit history
URL: /remote/v2/private/getdeposithistory/
Request limits: 20 per second
Params: 1
page: 1 (optional, will return page 1 default)
page: integer
Expected response
{
"status": "success",
"total_items": 10316,
"perpage": 100,
"page": 1, "message":
"Your deposit history with recent first",
"pages": 104,
"items":
[{
"status": "Incoming",
"time_seen": "2016-03-30 03:31:03",
"tx_address": "1FmqcxNueLm6SBZw3WrCy8H4tQ2y5NTgz2",
"currencyid": 55,
"tx_amount": "767.89570223",
"currency": "BTCS",
"tx_txid": "ab02e505f852729fe7da8c828e03a328eb0bcd10802010eeb7cc1f89b2891b48"
},
{
"status": "Accounted",
"time_seen": "2016-03-30 00:04:08",
"tx_address": "S5gjyKK2TsW3FdChWj8Ex2ZkLWtyujeqRG",
...
}]
}
Withdrawal history
URL: /remote/v2/private/getwithdrawalhistory/
Request limits: 20 per second
Params: 1
page: 1 (optional, will return page 1 default)
Expected response
{
"status": "success",
"perpage": 100,
"pages": 1,
"message": "Your withdrawal history with recent first",
"page": 1,
"total_items": 20,
"items":
[{
"status": "Confirmed",
"currency": "MEOW",
"time_requested": "2016-03-24 13:19:50",
"tx_address": "KAZYLd6hqCQkWN1srZGVWzg13s8fUDGVcx",
"currencyid": 5,
"time_sent": "2016-03-24 13:27:41",
"tx_amount": "3997.99000000",
"tx_txid": "cb4839d9ad1e8e87b20ee77372ecd9332add91842ed101c029d1b4787595dc5a"
},
{
"status": "Confirmed",
"currency": "BRDD",
"time_requested": "2016-03-19 18:48:35",
...
}]
}
Coininfo and Wallet status
URL: /remote/v2/private/walletstatus/
Params: None
Wallet status numbers:
0 - Wallet OK
1 - Wallet in maintenance
2 - Wallet not in sync
3 - Wallet not available
4 - Wallet offline?! Daemon dead?
5 - Unknown status...
6 - Wallet being delisted, please withdraw your coins.
Expected response
{
status': success',
message': WalletInfo for all listed wallets',
coininfo': [
{
peers': 4,
wallet_online': 1,
tx_fee': 0.01000000',
confirmations_needed': 18,
wallet_status': 0,
currency': $$$',
wallet_lastblock': 2016-06-21 21:28:42',
version': 80702',
wallet_available': 1,
wallet_insync': 1,
wallet_version': 60000',
wallet_maintenance': 0,
wd_fee': 0.00050000',
height': 1466269,
currencyname': Money',
id': 30,
wallet_deposit': 1,
wallet_withdrawal': 1
},
{
...
}
]
}
Coininfo and Wallet status for a specific wallet
URL: /remote/v2/private/walletstatus/<currency>/
Request limits: 20 per second
Params: None
Wallet status numbers:
0 - Wallet OK
1 - Wallet in maintenance
2 - Wallet not in sync
3 - Wallet not available
4 - Wallet offline?! Daemon dead?
5 - Unknown status...
6 - Wallet being delisted, please withdraw your coins.
Expected response
{
status': success',
message': WalletInfo for: BTC',
coininfo':
{
peers': 20,
wallet_online': 1,
tx_fee': 0.00050000',
confirmations_needed': 6,
wallet_status': 0,
currency': BTC',
wallet_lastblock': 2016-06-21 21:26:23',
version': 120100',
wallet_available': 1,
wallet_insync': 1,
wallet_version': 60000',
wallet_maintenance': 0,
wd_fee': 0.00050000',
height': 417396,
currencyname': Bitcoin',
id': 1,
wallet_deposit': 1,
wallet_withdrawal': 1
}
}