Bitcoin Forum
June 29, 2024, 02:18:37 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Nova Exchange API  (Read 78 times)
hamburger (OP)
Full Member
***
Offline Offline

Activity: 241
Merit: 107



View Profile WWW
April 05, 2019, 07:00:30 AM
 #1

Hi,

I am looking for a PHP example to make use of the Nova Exchange API.

Each request send to the server need to be signed, the example provided is for Python;

Code:
#!/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" )

Any assistance appreciated.

H

Datacoin : DHZ6H91fsDoBHbdqED3ysCJJ2TUh3zRMZD
Krugercoin : Yz3A9sTMp2yh5QLuAL8YQyvS5PdjHRHkkf
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!