Author

Topic: ccminer api usage (Read 1544 times)

newbie
Activity: 51
Merit: 0
September 24, 2018, 07:16:01 AM
#6
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 "  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)
newbie
Activity: 1
Merit: 0
September 24, 2018, 03:27:14 AM
#5
Use Socket or TcpClient
newbie
Activity: 17
Merit: 0
April 13, 2018, 01:14:11 PM
#4
did you get it to work? Im having the same issue
newbie
Activity: 22
Merit: 0
November 07, 2017, 04:17:27 AM
#3
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.
full member
Activity: 350
Merit: 100
September 06, 2017, 03:04:54 AM
#2
use websocket to consume the api, there is an example under api folder in the source code.
full member
Activity: 178
Merit: 102
September 04, 2017, 12:13:32 PM
#1
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
Jump to: