Hive API v2

Hive open API version 2.

New Hive 2.0 has REST API.
Previous API v1 is totally deprecated. ([DEPRECATED] Hive API)

API endpoints are here
https://api2.hiveos.farm/api/v2

Full specification is here
https://app.swaggerhub.com/apis/HiveOS/public/2.1-beta

You authorize with the credentials and receive JWT auth token. Then you can do just anything what you can do in Hive. You can build your autoswitching, get stats data, add/switch wallets, apply OC settings, adopt a mobile version, create a custom monitoring screen.

Extended documentation and how-to tutorials will be later, but you can inspect the requests that new frontend sends since it also works with this API.

Client example: PHP
<?php

$baseUrl = 'https://api2.hiveos.farm/api/v2';
$login = 'your_login';
$password = 'your_password';

function doCurl($ch) {
    $res = curl_exec($ch);
    if ($res === false) {
        die('CURL error: '.curl_error($ch));
    }
    $code = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
    curl_close($ch);
    $res = json_decode($res, true);
    if ($code < 200 || $code >= 300) {
        throw new Exception($res['message'] ?? 'Response error');
    }
    return $res;
}

// 1. Login
$ch = curl_init("$baseUrl/auth/login");
curl_setopt_array($ch, [
    CURLOPT_HTTPHEADER => [
        "Content-Type: application/json"
    ],
    CURLOPT_POST           => true,
    CURLOPT_POSTFIELDS     => json_encode([
        'login'    => $login,
        'password' => $password,
    ]),
    CURLOPT_RETURNTRANSFER => true,
]);
$res = doCurl($ch);
$token = $res['access_token'];

// 2. Get farms list
$ch = curl_init("$baseUrl/farms");
curl_setopt_array($ch, [
    CURLOPT_HTTPHEADER     => [
        "Authorization: Bearer $token"
    ],
    CURLOPT_RETURNTRANSFER => true,
]);
$res = doCurl($ch);
$farms = $res['data'];
print_r($farms);
Client example: Javascript

const baseUrl = 'https://api2.hiveos.farm/api/v2';
let accessToken = null;

doLogin('your_login', 'your_password')
    .then(getFarms)
    .then(farms => console.log('farms=', farms));

function doLogin(login, password) {
    return fetch(`${baseUrl}/auth/login`, {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json',
        },
        body: JSON.stringify({login, password})
    }).then(r => {
        if (!r.ok) {
            r.json().then(data => {
                console.error(data.message || 'Response error');
            });
            return Promise.reject(r);
        }
        else {
            return r.json().then(data => {
                accessToken = data.access_token;
                return data;
            });
        }
    })
}

function getFarms() {
    return fetch(`${baseUrl}/farms`, {
        method: 'GET',
        headers: {
            'Authorization': `Bearer ${accessToken}`,
        }
    }).then(r => {
        if (!r.ok) {
            r.json().then(data => {
                console.error(data.message || 'Response error');
            });
            return Promise.reject(r);
        }
        else {
            return r.json();
        }
    });
}
Client example: Bash
#!/bin/bash

baseUrl='https://api2.hiveos.farm/api/v2'
login='your_login'
password='your_password'

# 1. Login
response=`curl -s -w "\n%{http_code}" \
	 -H "Content-Type: application/json" \
	 -X POST \
	 -d "{\"login\":\"$login\",\"password\":\"$password\"}" \
	 "$baseUrl/auth/login"`
[ $? -ne 0 ] && (>&2 echo 'Curl error') && exit 1
statusCode=`echo "$response" | tail -1`
response=`echo "$response" | sed '$d'`
[[ $statusCode -lt 200 || $statusCode -ge 300 ]] && { echo "$response" | jq 1>&2; } && exit 1

# Extract access token
accessToken=`echo "$response" | jq --raw-output '.access_token'`

# 2. Get farms
response=`curl -s -w "\n%{http_code}" \
	 -H "Content-Type: application/json" \
	 -H "Authorization: Bearer $accessToken" \
	 "$baseUrl/farms"`
[ $? -ne 0 ] && (>&2 echo 'Curl error') && exit 1
statusCode=`echo "$response" | tail -1`
response=`echo "$response" | sed '$d'`
[[ $statusCode -lt 200 || $statusCode -ge 300 ]] && { echo "$response" | jq 1>&2; } && exit 1

# Display farms
echo "$response" | jq
8 Likes

reserved

По русски можно.

1 Like

All request returns 404

1 Like

hello… is this working ? all we get is 404…

Endpoints are not public at the moment. We finish internal tests now and release it to public. Hope during the folowing days.

When is the expected release date for hiveOS v2? and will it contain native vega support?

Vegas are supported by Linux driver. There is custom solution with ROCM driver. We wait for Linux kernel 4.19 to include promised support. Also you can use Hive for Windows.

At the moment we are doing private tests of Hive 2.0 and to release it by the end of the month.

Hi guys,

hope tests are going well :slight_smile:

Are you confident about releasing the APi at the end of the month?

Good work! :slight_smile:

Hello, today is last day of the month. What about API or docs for it?

Tomorrow will open public test
Testing API url is here:
https://api2.hiveos.farm

Sorry, the page you are looking for could not be found.

Then it’s working. You need to look the api specs to see where are the endpoints.
E.g, here is an open url https://api2.hiveos.farm/api/v2/pools

Where to look all endpoints ?

https://api2.hiveos.farm/api/v2 - this dont work
https://api2.hiveos.farm - this dont work

https://the2.hiveos.farm

Hello. So, we have https://api2.hiveos.farm/api/v2 as base url, then using paths from https://app.swaggerhub.com/apis/HiveOS/public/2.0-beta.
For example https://api2.hiveos.farm/api/v2/farms, is it?
Where I can get the API Bearer Auth Key?

Use https://api2.hiveos.farm/api/v2/auth/login
You’ll get access_token in response.

1 Like

Ok, thank you.
Did I understand correctly that the token is valid for 6 hours and I need to update it in time?

Hmmm, I getting empty data for all of my workers by that request: /farms/{farmId}/workers/{workerId}/metrics
For farm too:
/farms/{farmId}/metrics

But it’s not true.

The problem is topical. What am I doing wrong?
This is a FarmMetric model.

This is a response: {"data":[]}