Note:
Steps 1: Get your access token from https://auth-api.hyblockcapital.com/oauth2/token
grant_type: "client_credentials" //it is constant
client_id: <your-client-id>
client_secret: <your-client-secret>
Content-Type: "application/x-www-form-urlencoded" //it is constant
Steps 2: Hit your API with url https://api1.hyblockcapital.com/v1
"coin": "BTC",
"timeframe": "1m",
"exchange": "Binance",
"limit": 5
"Authorization": "Bearer <your-access-token>"
"x-api-key": <your API Key>
Python Script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import requests
client_id = <your client id>
client_secret = <your client secret>
api_key = <your API Key>
grant_type = "client_credentials" #this is constant
amazon_auth_url = 'https://auth-api.hyblockcapital.com/oauth2/token'
auth_data = {
"grant_type": grant_type,
"client_id": client_id,
"client_secret": client_secret,
}
def update_access_token():
auth_response = requests.post(
amazon_auth_url, data=auth_data, headers={'Content-Type': "application/x-www-form-urlencoded"})
return auth_response.json()
def get_data(path, base_url, query_params):
auth_response_json = update_access_token()
auth_token_header = {
"Authorization": "Bearer %s" % auth_response_json["access_token"],
"x-api-key": api_key
}
url = base_url + path
response = requests.get(url, params=query_params, headers=auth_token_header)
print(response.json())
return response.json()
base_url = 'https://api1.hyblockcapital.com/v1'
orderbook_path = '/bidAsk'
query = {
"timeframe": "1m",
"coin": "BTC",
"exchange": "Binance",
"limit": 5
}
get_data(orderbook_path, base_url, query)
Javascript (NodeJS) Script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
const axios = require('axios')
const client_id = <your client id>
const client_secret = <your client secret>
const api_key = <your api key>
const grant_type = "client_credentials" //this is constant
const amazon_auth_url = 'https://auth-api.hyblockcapital.com/oauth2/token'
async function get_access_token() {
const auth_data = {
"grant_type": grant_type,
"client_id": client_id,
"client_secret": client_secret,
}
const response = await axios({ method: 'post', url: amazon_auth_url, data: auth_data, headers: { 'Content-Type': "application/x-www-form-urlencoded" } })
return response.data
}
const getData = async (path, base_url, queries) => {
let auth_response_json = await get_access_token()
const url = base_url + path
const response = await axios({
method: "get",
url: url,
params: queries,
headers: {
"Authorization": `Bearer ${auth_response_json["access_token"]}`,
"x-api-key": api_key
}
})
console.log(response.data)
}
const base_url = 'https://api1.hyblockcapital.com/v1'
const orderbook_path = '/bidAsk'
const query = {
"coin": "BTC",
"timeframe": "1m",
"exchange": "Binance",
"limit": 5
}
getData(orderbook_path, base_url, query);