Liquid API
Search…
Authentication
Authentication requires 2 parameters: API Token ID and API Secret. These parameters can be obtained from API Setting page. We use JSON Web Token open standard for Authentication. First you need to build an auth payload.

Auth Payload Parameters

Parameters
Description
path
the request path e.g. /orders?product_id=1
nonce
a strictly increasing number, uniquely created for each request. We recommend using a millisecond timestamp at the time of making request e.g. 1459142524488
token_id
Token ID
After constructing the auth payload, you need to sign it with your secret using HMAC-SHA256 (HS256). JWT.encode(auth_payload, user_secret, 'HS256') You can choose to manually sign by following JWT specs. But we highly recommend using a JWT library, which is available in a wide range of programming languages.

Request Header

Parameters
Description
X-Quoine-Auth
Signature obtained from signing the Auth Payload
Ruby
1
require 'uri'
2
require 'net/http'
3
require 'time'
4
require 'jwt'
5
6
uri = URI.parse("https://api.liquid.com")
7
http = Net::HTTP.new(uri.host, uri.port)
8
http.use_ssl = true
9
10
token_id = 'YOUR_API_TOKEN_ID'
11
user_secret = 'YOUR_API_SECRET'
12
path = '/orders?product_id=1'
13
14
auth_payload = {
15
path: path,
16
nonce: DateTime.now.strftime('%Q'),
17
token_id: token_id
18
}
19
20
signature = JWT.encode(auth_payload, user_secret, 'HS256')
21
22
request = Net::HTTP::Get.new(path)
23
request.add_field('X-Quoine-API-Version', '2')
24
request.add_field('X-Quoine-Auth', signature)
25
request.add_field('Content-Type', 'application/json')
26
27
response = http.request(request)
Copied!
Last modified 10mo ago