More
referral
Increase your income with Hive. Invite your friends and earn real cryptocurrency!

Hive API v2

Hi guys,

here you can find a Laravel package for interacting with Hive OS api

Ругается… что ему не нравится ?

1.sh: 21: 1.sh: function: not found
1.sh: 30: 1.sh: [[: not found
1.sh: 30: 1.sh: 200: not found
1.sh: 1: 1.sh: jq: not found
1.sh: 35: 1.sh: Syntax error: “}” unexpected

1 Like

Hello,

I have created a mining monitoring program that performs scoring and statistics as well as profitability calculations. My program is under windows and is currently compatible with current currencies: ETH-ETC-ZEC
I would like to interact with my program so that it can give orders to hiveOS but I did not understand the use of hive very well
I understood that we must use the end point: https://api2.hiveos.farm/api/v2

to log in, use https://api2.hiveos.farm/api/v2/auth/login

When I enter this in a browser, I receive in response:
{
“message”: “”
}

How to authenticate on the API, the process seems complex!
I saw that there were several examples of programs in Javascript, PHP and bash.
I tried these different methods: javascript: impossible to execute the program (many errors)

Would it be possible to do the same thing as the bash but for BATCH WINDOWS ???

ooops if someone could guide me, it will be nice

Thank you for your reply
cordially

Jean Pierre

1 Like

I found the solution and I just implemented my gateway to the pc target hosting HIVEOS
by simply passing through CYGWIN and using the demo script in BASH (LINUX) on the HIVEOS forum
That way, I can run bash commands from WINDOWS

Hi.
Correct me if I’m wrong.
After login, my token is valid for 2 weeks.
To acquire new token I need to provide 2FA code.
If above are true, I’m not able to automate token refresh, so I’m not able to fully automate my monitoring solution.
Is that right?

Hi, you need to create personal API token for your monitoring system. This token never expires until you delete it.

I’m trying to use the API to switch flight sheets, but I am having the following problem:

$ curl -s -w '\n%{http_code}' -H 'Content-Type: application/json' -H 'Authorization: Bearer KEY_DELETED' -X PATCH -d '{"fs_id": X16R}' https://api2.hiveos.farm/api/v2/farms/FARM_ID_DELETED/workers/WORKER_ID_DELETED
{
    "message": "Empty input"
}

I know the API key is OK, because this works:

curl -s -w '\n%{http_code}' -H 'Content-Type: application/json' -H 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9hcGkyLmhpdmVvcy5mYXJtIiwiaWF0IjoxNTU1MzgyMTA3LCJleHAiOjE4NzIyMTA5MDcsIm5iZiI6MTU1NTM4MjEwNywianRpIjo0OTA3MTg5LCJzdWIiOjQ5MDcxODksInJtYiI6dHJ1ZX0.0BqoOA_IaQlOvEmIAjLhgtDmZJcfq16Bg0szV1Ko76E' https://api2.hiveos.farm/api/v2/farms/37906/fs
{"data":[{"id":<REST OF RESPONSE DELETED>

Any help on what I am doing wrong in trying to change the flight sheet?

Thank you!

Hello,
You should send integer ID of the flight sheet in the request, but you send ‘{“fs_id”: X16R}’ which is also an invalid JSON.

Thank you, that fixed the problem!

1 Like

та же проблема , как то решили ?

Добрый день. По таким вопросам обращайтесь в поддержку хайва (телеграм, почта), а это ветка по вопросам касательно API.

yes, fine :slight_smile:

I have a problem that i can’t fix !

The API is working fine for me, i have my token , i can get all the params of the farm. That’s perfect !

But i can’t change a configuration by this API !

I looked at :
https://app.swaggerhub.com/apis/HiveOS/public/2.1-beta

… but i have in return a code 405 error (method not allowed).

Here is my PHP code. In this exemple i would like to change the config of the miner claymore.

  $data = array();
  $data['miners_config'][0]['miner'] = "claymore";
  $data['miners_config'][0]['config']['claymore_user_config'] = "-di 0";

  $url = "$infos_baseUrl/farms/$my-farm-id/workers/$my-rig-id";
  // --> https://api2.hiveos.farm/api/v2/farms/######/workers/######

$headers = array();
$headers[] = "Content-Type: application/json";
$headers[] = "accept: application/json";
$headers[] = "Authorization: Bearer $infos_permanentToken";

$ch = curl_init($url); 
curl_setopt_array($ch, [
  CURLOPT_HTTPHEADER => $headers,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => "PATCH",
  CURLOPT_POSTFIELDS => json_encode($data),
]);

Is anyone can help ?

Thanks !

Hello, I’ve just tried your example and it works, returned status code is 200 which means the API is ok.

Strangly … you are right ! Not a 405 code anymore (i changed nothing ! it’s magic… ) but a 400 ! :sweat_smile:

CODE : 400
Fatal error : Uncaught Exception: Empty input

Do you think it’s my $data sent wich is not correct ?

{
    "miners_config": [
        {
            "miner": "claymore",
            "config": {
                "claymore_user_config": "-di 0"
            }
        }
    ]
}

It seems corrected formatted as in the exemple ?

Thanks for your help !

Your code in first message is absolutely correct - I launched it without any changes and it worked.
Something wrong on your side, maybe request body does not reach the server… Try some another POST and PATCH requests to check if they’re working.

Trying to use the “command” function in the API. I can authenticate and do other things in the API. I want to use the API to turn off the miner. Here is what I’m trying:

curl -s -w ‘\n%{http_code}’ -H ‘Content-Type: application/json’ -H ‘Authorization: Bearer API HASH DELETED’ -X POST -d ‘{“command”: “miner”, “data”: { “action”: “stop” } }’ http://api2.hiveos.farm/api/v2/farms/FARM ID DELETED/workers/WORKER ID DELETED

Here is what I get in response:

{
“message”: “”
}
405

I’m obviously doing something wrong in the JSON request, but I can’t figure it out, even after going through the API docs at https://app.swaggerhub.com/apis/HiveOS/public/2.1-beta#/

Any help is appreciated!

Hello,
You are using wrong endpoint, use this one:
/farms/{farmId}/workers/{workerId}/command

Thanks! I knew I was missing something obvious!