-
Notifications
You must be signed in to change notification settings - Fork 14
api_authentication
luogang edited this page Nov 30, 2021
·
6 revisions
-
You must set ip whitelist on the mining setting page before calling API. Subaccounts will inherit ip whitelist setting from the primary account when its ip whitelist is empty.
-
Each account or subaccount has a pair of
api key
andsecret key
, which can be found on the mining setting page. Such as(sample api key, not work):
key | value |
---|---|
api_key | 16289e05354c3c3814b8f3045950395f |
secret_key | d186ababcb0eb1f6af5c1519424f462b84c631f86c06309992ae1f15604668b0 |
- API need authentication. Just send request with the header
X-API-KEY: <your_api_key>
:
curl 'https://www.viabtc.net/res/openapi/v1/hashrate?coin=BTC' \
-H 'X-API-KEY: 16289e05354c3c3814b8f3045950395f'
- Some API need a signature. Following the setps to sign a request:
- Add
tonce
field to the request parameter. The value oftonce
is current timestamp accurate to milliseconds.
key | value |
---|---|
coin | BTC |
amount | 1.0 |
tonce | 1513746038205 |
- If it is a
GET
orDELETE
request, generatequery string
(in any order):
coin=BTC&amount=1.0&tonce=1513746038205
Calculate the HMAC SHA256
signature of query string
with secret key
:
echo -n 'coin=BTC&amount=1.0&tonce=1513746038205' \
| openssl dgst -sha256 -hmac "d186ababcb0eb1f6af5c1519424f462b84c631f86c06309992ae1f15604668b0"
# output: 4a1c9e4c73629b62fd999cbbcd2bc8b87a07f1791ae61ba576427f820dd3bc59
If it is a POST
or PUT
request, generate request body
(in any order):
{"coin": "BTC", "amount": "1.0", "tonce": 1513746038205}
Calculate the HMAC SHA256
signature of request body
with secret key
:
echo -n '{"coin": "BTC", "amount": "1.0", tonce: 1513746038205}' \
| openssl dgst -sha256 -hmac "d186ababcb0eb1f6af5c1519424f462b84c631f86c06309992ae1f15604668b0"
# output: 2dd2cc09cb5b11c7f24d457b1c01e46f2f2b17f06a62bf29eda35b5fb45ce354
- Send the request with
X-API-KEY: <your_api_key>
andX-SIGNATURE: <signature>
header. Thequery string
orrequest body
of the request should be from the previous step.
curl 'https://www.viabtc.net/res/openapi/v1/hashrate?coin=BTC&amount=1.0&tonce=1513746038205' \
-H 'X-API-KEY: 16289e05354c3c3814b8f3045950395f' \
-H 'X-SIGNATURE: 4a1c9e4c73629b62fd999cbbcd2bc8b87a07f1791ae61ba576427f820dd3bc59'
or
curl 'https://www.viabtc.net/res/openapi/v1/hashrate' \
-H 'Content-Type: application/json' \
-H 'X-API-KEY: 16289e05354c3c3814b8f3045950395f' \
-H 'X-SIGNATURE: 2dd2cc09cb5b11c7f24d457b1c01e46f2f2b17f06a62bf29eda35b5fb45ce354' \
-d '{"coin": "BTC", "amount": "1.0", tonce: 1513746038205}' \
-X POST
- API signature can refer to sample code.
HTTP API Introduction
Account API
Hahrate API
- Acquire Account Hashrate
- Acquire Account Hashrate History
- Acquire Account Hashrate Chart
- Acquire Miner Hahrate
- Acquire Miner Hahrate Info
- Acquire Miner Hashrate History
- Acquire Miner Group Hashrate
- Acquire Miner Group Hashrate Info
Wallet API