Hi everyone,
How can I run the command line by the API?
Cheers
Hi everyone,
How can I run the command line by the API?
Cheers
Hello,
I try to make a mix withe the different posts to make my API.
But I’m wrong in the array to declare.
Somebody can help me ?
The connexion is OK, and I get the error :
{
“message”: “Method Not Allowed”,
“code”: 405
}
I want to make a script for stop or start the miners.
Thanks
<?php
$baseUrl = 'https://api2.hiveos.farm/api/v2';
$data = array();
$data['command'] = "miner";
$data['data']['action']="stop";
//$data2= array('command'=>'miner','data'=>array('action'=>'stop'));
//$data2['miner'][0]['exec'] = "shutdown";
$url = "$baseUrl/farms/######/workers/######/command";
// --> https://api2.hiveos.farm/api/v2/farms/######/workers/######
$headers = array();
$headers[] = "Content-Type: application/json";
$headers[] = "accept: application/json";
$headers[] = "Authorization: Bearer ########################";
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_HTTPHEADER => $headers,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode($data),
]);
$res = curl_exec($ch);
//$farms = $res['data'];
print_r($res);
?>
on my side , this is my array structure =>
{
"worker_ids": [
1234567
],
"search_id": null,
"data": {
"command": "miner",
"data": {
"action":"stop"
}
}
}',
In first, thanks a lot for the quick answer.
I’m not an expert with php and can you tell me more informations ?
Is it possible to have the complete delaration ?
I try
$data2={
"worker_ids": [
123XXXXXX
],
"search_id": null,
"data": {
"command": "miner",
"data": {
"action":"stop"
}
}
}',
but it’s not working…
I think a user a bad declaration of this array.
Thanks !
It’s good now but I have :
{
“message”: “Method Not Allowed”,
“code”: 405
}
I use
$baseUrl = ‘https://api2.hiveos.farm/api/v2’;
$url = “$baseUrl/farms/XXX/workers/YYYYY/command”
I use
“worker_ids”: [
YYYYY
],
Thanks
It’s good !!!
I share my code for help the others newbie dev like me
<?php
$baseUrl = 'https://api2.hiveos.farm/api/v2';
$data = array();
$data = json_decode('
{
"worker_ids": [
"WORKER_ID"
],
"search_id":null,
"data": {
"command": "miner",
"data": {
"action":"restart"
}
}
}');
$url = "$baseUrl/farms/FARM_ID/workers/command";
// --> https://api2.hiveos.farm/api/v2/farms/######/workers/######
$headers = array();
$headers[] = "Content-Type: application/json";
$headers[] = "accept: application/json";
$headers[] = "Authorization: Bearer YOUR_API_KEY_HERE
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_HTTPHEADER => $headers,
CURLOPT_RETURNTRANSFER => true,
// CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode($data),
]);
//print_r(json_encode($data));
$res = curl_exec($ch);
//$farms = $res['data'];
print_r($res);
?>
Thanks for all
Do you have a working version, I can’t seem to get any connection. have basic PHP
My code works for me.
Regards.
I used what you put above and nothing happens, i just need to get unpaid ETH, can you help
Do you change the YOUR_API_KEY_HERE and the number for farmers/workers with yours ? What is the answer of the API ($res) ?
To have a YOUR_API_KEY_HERE you must create an API application in your settings.
Regards,
you have lines commented out, is that correct?, like
// CURLOPT_CUSTOMREQUEST => “PATCH”,
//$farms = $res[‘data’];
//print_r(json_encode($data));
I get { “message”: “Not Found”, “code”: 404 }
I think you may have a bad url or a bad API_KEY.
Could you please tell me where can I find the security code?
First of all, my 2FA is turned off but my webpage response is that a security code is required, when I introduce one in the headers as you did here, it says it is wrong. Where is the correct one?
I have also used my token from account settings with my credentials.
I’ve been attempting to log in with my api authorization key. But it doesn’t appear to be allowing me access? Is there more steps then ensuring Authorization: is in the header of the api call? Very new to api’s I apologize if this is a stupid question, attempting to teach myself.
I am doing this fine in node red - make sure you have the word bearer in the authorization area - it seems lots of people keep missing this
what i did
curl -s -w ‘\n%{http_code}’ -H ‘Content-Type: application/json’ -H ‘Authorization: Bearer YOUR_API_KEY_HERE’ https://api2.hiveos.farm/api/v2/farms/YOUR_FARM_ID_HERE
Craig
Зачем изменили страницу входа в ферму? Теперь она то и дело вываливается в logoff, на страницу авторизации(!), при этом при вводе логин - пароль(!), получаешь сообщение, что вас долго не было и снова показывает туже страницу авторизации(!). Приходится второй раз вводить логин и пароль, ну и код 2FA.
Это очень раздражает!
а API всё? Сломали с концами? Ничего не работает неделю
@hiveon, @keaton_hiveon, the API has not been working for several days, for any request I get a response “Unauthorized”. Even a page https://api2.hiveos.farm/api/v2/ is not working