nicehash-api-cpp  0.0.1
getProviderWorkerStats.cpp
Go to the documentation of this file.
1 #include <string>
2 
3 #include "../../include/nicehash-api.hpp"
4 
5 
6 /**
7  * \brief Get detailed stats for a provider's workers by algorithm id
8  *
9  * Get current stats for provider for all algorithms (data refreshed every 30 seconds).
10  * It (GET) requests https://api.nicehash.com/api?method=stats.provider&addr=...
11  * where the addr param is a wallet address.
12  * The past 56 payments are also returned in the response.
13  *
14  */
15 std::string NiceHashApi::getProviderWorkerStats (std::string address, int algorithm_id){
16 
17  this->throwExceptionIfAlgorithmInvalid(algorithm_id);
18 
19  // Construct the query params (&addr= and algo=)
20  std::string endpoint = "https://api.nicehash.com/api?method=stats.provider.workers&addr=";
21  std::string url = endpoint + address + "&algo=" + std::to_string(algorithm_id);
22 
23  std::string response = this->client->get(url);
24 
25  return response;
26 }
27 /**
28  * \brief Get detailed stats for a provider's workers by algorithm name
29  *
30  * Get current stats for provider for all algorithms (data refreshed every 30 seconds).
31  * It (GET) requests https://api.nicehash.com/api?method=stats.provider&addr=...
32  * where the addr param is a wallet address.
33  * The past 56 payments are also returned in the response.
34  *
35  */
36 std::string NiceHashApi::getProviderWorkerStats (std::string address, std::string algorithm_name){
37 
38  int algorithm_id = this->algorithmNameToId(algorithm_name);
39 
40  return this->getProviderWorkerStats(address, algorithm_id);
41 }
virtual std::string get(std::string const url)
GET request the provided url and return the response body as a string.
Definition: get.cpp:14
std::string getProviderWorkerStats(std::string address, int algorithm_id)
Get detailed stats for a provider&#39;s workers by algorithm id.
int algorithmNameToId(std::string algorithm_name)
Convert an algorithm name to its id.