how do i turn on the api access so that i can add my rig running hiveOS to awesome miner ?
hello i installed hiveos app in my samsung phone and it ask me public key (it s ok) and secret apikey , where can i find it or create it?
tks
О уже и приложуху сварганили !
работает )))
Any plans to include commands such as reboot the server or upgrade or any other commands you can do from the control panel? or a watchdog output to a URL/JSON besides Telegram notifications that could trigger an external rebooter?
I noticed that my HiveOS API script has started to be rate limited (and returning more informative failures). First, sorry if I caused any issue; I assumed refreshing every 10 seconds like the web app does would be ok.
Can someone offer guidance on how often each API call can be made? Are there APIs that can be called more often (e.g. stats)?
I noticed this on the HiveOS todo list: “Dude, where is my GPU” script for detecting card physically with fans and leds.
I have a script that does this for nvidia cards (blink LEDs) and another script that correlates HiveOS GPU number to the PCI manufacturer data for each GPU - useful for id’ing cards in a mixed card rig. As far as script for turning fans on/off - won’t touch that Easy to do and my LED blinky script can easily be modified to do so. Let me know if you are interested and I can pass them along.
Answer: There is a limit of 50 request in 5 minutes to API or monitor url. Counters reset every 5 min after the first request in 5 minutes period. Same rate from the whole api.
For python 3:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Hive OS API usage example
Install curl:
easy_install pycurl
pip install pycurl
'''
import pycurl
import sys
import datetime
import urllib.parse
import hmac
import hashlib
import io
import json
argv = sys.argv
argc = len(sys.argv)
null = 0
class HiveAPIExample:
def __init__(self):
pass
__SECRET_KEY = b'YOURKEYHERE'
"""
Your secret API key, you sign the message with it
@var string 64 hex chars
"""
__PUBLIC_KEY = b'YOURKEYHERE'
"""
This is a public key
@var string 64 hex chars
"""
__URL = "https://api.hiveos.farm/worker/eypiay.php"
"""
Api connection URL
Please use HTTPS, not HTTP for calls for better security.
@var string
"""
def run(self):
self.__log("=== Hive API example ===")
method = argv[1]
if method != "multiRocket":
# run this class methods by name
m = getattr(self, method)
result = m()
else:
if argc >= 4:
# at least rig ids and miner required
# take the arguments from commandline
result = self.multiRocket(argv[2], argv[3], argv[4], argv[5], argv[6])
else:
# To use rocket you have to know what you are doing. Then delete these lines and edit the following.
self.log("Please edit the source to use multiRocket method")
exit()
# this is just an example, use some of your real ids which you get with other methods
# set everything to rigs ids 1, 2 and 3
result = self.multiRocket("1,2,3", "claymore", "xmrig", 107800, 800)
# set bminer to rigs ids 4 and 5, unset second miner
# ??? result = self.multiRocket("4,5", "bminer", "0", null, null)
if result is not None:
# print_r($result);
print ( json.dumps(result, indent=4) )
print
def request(self, params):
"""
Make API request with given params. Signs the request with secret key.
@param: array params
@return array
"""
params["public_key"] = self.__PUBLIC_KEY
post_data = urllib.parse.urlencode(params)
hmac_ = hmac.new(self.__SECRET_KEY, post_data.encode("utf-8"), hashlib.sha256).hexdigest()
curl = pycurl.Curl()
curl.setopt(pycurl.URL, self.__URL)
curl.setopt(pycurl.HTTPHEADER, ['HMAC: ' + str(hmac_)])
curl.setopt(pycurl.POST, True)
curl.setopt(pycurl.POSTFIELDS, post_data)
curl.setopt(pycurl.CONNECTTIMEOUT, 10)
curl.setopt(pycurl.TIMEOUT, 5)
buf = io.BytesIO()
curl.setopt(pycurl.WRITEFUNCTION, buf.write)
curl.perform()
response = buf.getvalue()
# Uncomment to debug raw JSON response
# self.__log("< " + response)
http_code = curl.getinfo(pycurl.HTTP_CODE)
curl.close()
result = json.loads(response.decode('utf-8'))
if http_code != 200:
if result["error"]:
# 404 with some valid JSON
self.__log("ERROR: HTTP " + str(http_code) + ": " + json.dumps(result["error"]))
else:
self.__log("ERROR: HTTP " + str(http_code) + ": " + response)
else:
if result is None:
self.__log("ERROR: Unparsable JSON " + response)
else:
if 'error' in result: # || !$result["result"]
self.__log("ERROR: " + json_encode(result["error"]))
else:
result = result["result"]
return result
@staticmethod
def __log(msg):
str_ = '[' + str(datetime.datetime.today()) + '] ' + msg
print ( str_ )
# with open(loggerFilename) as log_file:
# log_file.write(str_)
def getRigs(self):
"""
Rigs list
"""
params = {
'method': 'getRigs'
}
rigs = self.request(params)
if 'error ' in rigs:
return False
return rigs
def getWallets(self):
"""
Wallets list
"""
params = {
'method': 'getWallets'
}
wallets = self.request(params)
if 'error' in wallets:
return False
return wallets
def getOC(self):
"""
Overclocking profiles
"""
params = {
'method': 'getOC'
}
ocs = self.request(params)
if 'error' in ocs:
return False
return ocs
def getCurrentStats(self):
"""
Monitor stats for all the rigs
"""
params = {
'method': 'getCurrentStats'
}
stats = self.request(params)
if 'error' in stats:
return False
return stats
def multiRocket(self, rig_ids_str, miner, miner2, id_wal, id_oc):
"""
Sets parameters for rigs
@param rig_ids_str coma separated string with rig ids "1,2,3,4"
@param miner Miner to set. Leave it null if you do not want to change. "claymore", "claymore-z", "ewbf", ...
@param miner2 Second miner to set. Leave it null if you do not want to change. "0" - if you want to unset it.
@param id_wal ID of wallet. Leave it null if you do not want to change.
@param id_oc ID of OC profile. Leave it null if you do not want to change.
@return bool|mixed
"""
if rig_ids_str is not None:
self.log("Rigs ids required")
exit()
params = {
'method': 'multiRocket',
'rig_ids_str': rig_ids_str,
'miner': miner,
'miner2': miner2,
'id_wal': id_wal,
'id_oc': id_oc
}
result = self.request(params)
if 'error' in result:
return False
return result
if argc <= 1:
script = sys.argv[0]
print ( "Usage: " + script + " methodName aguments" )
print ( "Examples:" )
print ( " " + script + " getRig" )
print ( " " + script + " getWallets" )
print ( " " + script + " getCurrentStats" )
print ( " " + script + " multiRocket \"rig1,rig2\" [miner] [miner2] [id_wal] [id_oc]" )
else:
api = HiveAPIExample()
api.run()
Nah, python 3 gives me:
AttributeError: 'HiveAPIExample' object has no attribute 'log'
I’m not able to fix this…
Can somebody pass line how to auth this using bash/curl? I’d like to get wallets list
Is there an Answer to the “Method not given” failure?
Do i need payed Account for API use?
Anyone successfully got ApI answer in Postman?
всегда больше любил функции, чем объекты. Python3, маленькая, компактная функция.
Little function for api using.
import requests
import hmac
import hashlib
import urllib.parse
hiveos_secret_key=b'your_secret_key'
hiveos_public_key=b'your_public_key'
def hiveos_api(params):
params["public_key"] = hiveos_public_key
url = 'https://api.hiveos.farm/worker/eypiay.php'
hmac_ = hmac.new(hiveos_secret_key,urllib.parse.urlencode(params).encode('utf-8'),hashlib.sha256).hexdigest()
response = requests.post(url,data=params,headers={'HMAC': hmac_}).json()
return response
print(hiveos_api({'method':'getRigs'}))
Дмитрий, а можно сделать в multiRocket или другом методе управление вентиляторами? Сценарий: периодически смотрим статистику ферм и если температура поднялась или упала - корректируем вентиляторы. Расчет оптимальной частоты вращения уже готов, осталось передавать в ферму. Для чего нужно? В домашних фермах вечером, когда падает температура, можно делть фермы потише
Denis, вы можете переключить ферму на другой кошелек, где более приемлимые настройки майнера.
For python 2.7
import requests
import hmac
import hashlib
import urllib
hiveos_secret_key=b'your_secret_key'
hiveos_public_key=b'your_public_key'
def hiveos_api(params):
params["public_key"] = hiveos_public_key
url = 'https://api.hiveos.farm/worker/eypiay.php'
hmac_ = hmac.new(hiveos_secret_key,urllib.urlencode(params).encode('utf-8'),hashlib.sha256).hexdigest()
response = requests.post(url,data=params,headers={'HMAC': hmac_}).json()
return response
riglist = hiveos_api({'method':'getRigs'})['result']
for id, vlist in riglist.items():
print id, vlist
API with json report, active key is always with value 1… even when rig is off…
Can you fix it?
Thanks
How with API I can receive messages?
I mean messages which is shown under rig name in monitor
Thanks
Is there a way to modify/upload Wallet or OC settings through the API?
Thanks.
А можно ли добавить, чтобы в методе getRigs приходили риги с доверенных аккаутнов?
Можете добавить описание ответов от сервера? Не понятно какие вообще поля могут быть у объектов, так как пустые поля не приходят.