Bitcoin Forum

Alternate cryptocurrencies => Mining (Altcoins) => Topic started by: duffann on September 04, 2017, 05:13:32 PM



Title: ccminer api usage
Post by: duffann on September 04, 2017, 05:13:32 PM
Hello,

I use this command at the end of the bat :
-b 127.0.0.1:4068

When I try 127.0.0.1:4068 on my browser i get :
ERR_EMPTY_RESPONSE on chrome.

How can i access the api , i can reach api easily with ebwf but not with ccminer.

thanks


Title: Re: ccminer api usage
Post by: car1999 on September 06, 2017, 08:04:54 AM
use websocket to consume the api, there is an example under api folder in the source code.


Title: Re: ccminer api usage
Post by: zenono on November 07, 2017, 09:17:27 AM
I also can't use this api.

I tried -b 127.0.0.1:4068 and -b 0.0.0.0:4068

Running http://127.0.0.1:4068 or websocket.htm has no effect.


Title: Re: ccminer api usage
Post by: joenova on April 13, 2018, 06:14:11 PM
did you get it to work? Im having the same issue


Title: Re: ccminer api usage
Post by: serg_shu on September 24, 2018, 08:27:14 AM
Use Socket or TcpClient


Title: Re: ccminer api usage
Post by: kineda on September 24, 2018, 12:16:01 PM
here is a quick python api script you can use that will export the api data as json. save it as a .py file "filename.py <ip of miner> <port for the api> <command>"  i listed the api commands you can query in the commented section.  

Code:
import socket
import sys

def get_ccminer_api_stats(miner, api_port, command):
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    server_address = (miner, int(api_port))
    print ("Connecting to API@" + miner + ":" + str(api_port))
    try:
        sock.connect((server_address))
        print ("Connected to API")
        sock.sendall(command)
        data = sock.recv(4096)
        data = data.replace('|\x00','')
        data_split = data.split(';')
        keys = []
        values = []
        for item in data_split:
            item_split = item.split('=')
            keys.append(item_split[0])
            values.append(item_split[1])
        api_json = {}
        i = 0
        while i < len(keys):
            api_json[keys[i]] = values[i]
            i+=1
    except Exception as err:
        api_json = {}
        if command == 'summary':
            api_json['KHS'] = 'crashed'
        
    return api_json
        
#api_commands = ['help', 'summary', 'threads', 'pool', 'histo', 'hwinfo', 'meminfo']

miner = sys.argv[1]
api_port = sys.argv[2]
command = sys.argv[3]

stats = get_ccminer_api_stats(miner, api_port, command)
print (stats)