I'm looking for a simple API description to get some basic stats from the huobi.com exchange. Mainly the last trading price, and current orderbook (bids & asks).

They seem to have an API: http://www.huobi.com/help/index.php?a=api_help but this page doesn't help me much (even after translating it with Google, as I can't read Chinese).

Does anyone know how to use this API?

  • Were you able to find any such API ? – Mandeep Singh Jun 12 '16 at 1:20

I had some trouble finding it there but then I found it in "reference" https://github.com/huobiapi/API_Docs_en/wiki/REST_Reference

You can use normal http queries like on other exchanges so to get an orderbook you use this for example: https://api.huobi.pro/market/depth?symbol=ethbtc&type=step1


Huobi API documentation is https://huobiapi.github.io/docs/spot/v1/en/#introduction

import requests
import json

#Get Latest Aggregated Ticker, 
#retrieves the latest ticker with some important 24h aggregated market data
url = 'https://api.huobi.pro/market/detail/merged?symbol=ethusdt'
response = requests.request('GET', url)
r = json.loads(response.text)

To get all accounts, use endpoint GET /v1/account/accounts

from datetime import datetime
import requests
import json
import hmac
import hashlib
import base64
from urllib.parse import urlencode

#Get all Accounts of the Current User
AccessKeyId = 'xxxxx-xxxxx-xxxxx-xxxxx'
SecretKey = 'xxxxx-xxxxx-xxxxx-xxxxx'
timestamp = str(datetime.utcnow().isoformat())[0:19]
params = urlencode({'AccessKeyId': AccessKeyId,
                    'SignatureMethod': 'HmacSHA256',
                    'SignatureVersion': '2',
                    'Timestamp': timestamp
method = 'GET'
endpoint = '/v1/account/accounts'
base_uri = 'api.huobi.pro'
pre_signed_text = method + '\n' + base_uri + '\n' + endpoint + '\n' + params
hash_code = hmac.new(SecretKey.encode(), pre_signed_text.encode(), hashlib.sha256).digest()
signature = urlencode({'Signature': base64.b64encode(hash_code).decode()})
url = 'https://' + base_uri + endpoint + '?' + params + '&' + signature
response = requests.request(method, url)
accts = json.loads(response.text)

I think this is the newest api on github


  • That doesn't appear to answer the question. – Mine Feb 2 '18 at 2:29
  • @Mine this is the exact file that you can use to get data through websocket, it's on huobi's github github.com/huobiapi/WebSocket-API-demos/blob/master/… – Mingrui Jiang Feb 5 '18 at 4:29
  • @Mingrui_Jiang technically he wasn't asking if there was a new one. He was asking how to use it. – Mine Feb 6 '18 at 16:05
  • Yes the API demos on within shows you exactly how to use it – Mingrui Jiang Feb 8 '18 at 8:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.