<p>Most Antminers have a WebSocket API that connects to the built in CGMiner software on port 4028.</p>

<p>You can test this in a command prompt in Windows, Mac, or Linux with (nc is a program called <a href="https://eternallybored.org/misc/netcat/" rel="nofollow noreferrer">netcat</a> which you may need to install):</p>

<p><code>echo -n "stats" | nc IP_OF_MINER_GOES_HERE 4028
</code> </p>

<p>There may also be a way to do this with CURL instead of netcat, but I have not had a chance to test it yet.</p>

<p><strong>Code Examples:</strong></p>

<blockquote>
  <p>api-example.php - a php script to access the API   usAge: php
  api-example.php command  by default it sends a 'summary' request to
  the miner at 127.0.0.1:4028  If you specify a command it will send
  that request instead  You must modify the line "$socket =
  getsock('127.0.0.1', 4028);" at the  beginning of "function
  request($cmd)" to change where it looks for cgminer</p>
  
  <p>api-example.rb - a Ruby script to access the API.  usage: ruby
  api-example.rb command[:parameter] [HOST [PORT]] This script prints
  the parsed cgminer API response</p>
  
  <p>API.java/API.class  a java program to access the API (with source
  code)   usAge is: java API command address port  Any missing or blank
  parameters are replaced as if you entered:   java API summary
  127.0.0.1 4028</p>
  
  <p>api-example.c - a 'C' program to access the API (with source code)<br>
  usAge: api-example [command [ip/host [port]]]  again, as above,
  missing or blank parameters are replaced as if you entered:<br>
  api-example summary 127.0.0.1 4028</p>
</blockquote>

<p><a href="https://github.com/ckolivas/cgminer/blob/master/API.java" rel="nofollow noreferrer">Java Example</a></p>

<p><a href="https://github.com/ckolivas/cgminer/blob/master/api-example.c" rel="nofollow noreferrer">C Example</a></p>

<p><a href="https://github.com/ckolivas/cgminer/blob/master/api-example.php" rel="nofollow noreferrer">PHP Example</a></p>

<p><a href="https://github.com/ckolivas/cgminer/blob/master/api-example.py" rel="nofollow noreferrer">Python Example</a></p>

<p><a href="https://github.com/ckolivas/cgminer/blob/master/api-example.rb" rel="nofollow noreferrer">Ruby Example</a></p>

<p>I've built a small script for my personal miners which will not work for most environments (due to reliance on data from SlushPool), but it may be useful for some code snippets (C#): <a href="https://gist.github.com/kpjVideo/1fddf0042fb520deba80100259f73e7b" rel="nofollow noreferrer">Here</a></p>

CC BY-SA 4.0
2018-10-10T15:53:22.910Z
2018-10-10T16:21:15.613Z
2018-10-10T16:21:15.613Z
Mason Ticehurst
<p>You can use my software at <a href="https://github.com/anselal/antminer-monitor" rel="nofollow noreferrer">https://github.com/anselal/antminer-monitor</a>. More features to come</p>

CC BY-SA 4.0
2019-12-16T15:55:18.340Z
2019-12-16T15:55:18.340Z
anselal
<p>I have an antminer asic, and it has web interface. I could see temperature and hashrate through it.</p>

<p>Now i want to retrieve and store that data (from multiple asics), within another program on another device. Obvious but inefficient way is to send HTTP request and parse HTML responses. </p>

<p>But does asic has some way (for example JSON output via some GET/POST requests, or even custom TCP protocol) to get information in machine-friendly format?</p>

<p>How do such aggregated statistics monitoring and control usually implemented in big farms? Is there any existing software for solving this obvious control/monitoring task?</p>

<asic><statistics>
Does asic API exists?
xakepp35
# Does asic API exists?

(Asked by: username_0 on 2018-10-10)

I have an antminer asic, and it has web interface. I could see temperature and hashrate through it.

Now i want to retrieve and store that data (from multiple asics), within another program on another device. Obvious but inefficient way is to send HTTP request and parse HTML responses.

But does asic has some way (for example JSON output via some GET/POST requests, or even custom TCP protocol) to get information in machine-friendly format?

How do such aggregated statistics monitoring and control usually implemented in big farms? Is there any existing software for solving this obvious control/monitoring task?

**Tags:** asic, statistics


---

## 2 answers

### Answer by username_1 on 2018-10-10. Score: 2 | Accepted answer

Most Antminers have a WebSocket API that connects to the built in CGMiner software on port 4028.

You can test this in a command prompt in Windows, Mac, or Linux with (nc is a program called [netcat](https://eternallybored.org/misc/netcat/) which you may need to install):

`echo -n "stats" | nc IP_OF_MINER_GOES_HERE 4028`

There may also be a way to do this with CURL instead of netcat, but I have not had a chance to test it yet.

**Code Examples:**

> api-example.php - a php script to access the API usAge: php
> api-example.php command by default it sends a 'summary' request to
> the miner at 127.0.0.1:4028 If you specify a command it will send
> that request instead You must modify the line "$socket =
> getsock('127.0.0.1', 4028);" at the beginning of "function
> request($cmd)" to change where it looks for cgminer
>
> api-example.rb - a Ruby script to access the API. usage: ruby
> api-example.rb command[:parameter] [HOST [PORT]] This script prints
> the parsed cgminer API response
>
> API.java/API.class a java program to access the API (with source
> code) usAge is: java API command address port Any missing or blank
> parameters are replaced as if you entered: java API summary
> 127.0.0.1 4028
>
> api-example.c - a 'C' program to access the API (with source code)  
> usAge: api-example [command [ip/host [port]]] again, as above,
> missing or blank parameters are replaced as if you entered:  
> api-example summary 127.0.0.1 4028

[Java Example](https://github.com/ckolivas/cgminer/blob/master/API.java)

[C Example](https://github.com/ckolivas/cgminer/blob/master/api-example.c)

[PHP Example](https://github.com/ckolivas/cgminer/blob/master/api-example.php)

[Python Example](https://github.com/ckolivas/cgminer/blob/master/api-example.py)

[Ruby Example](https://github.com/ckolivas/cgminer/blob/master/api-example.rb)

I've built a small script for my personal miners which will not work for most environments (due to reliance on data from SlushPool), but it may be useful for some code snippets (C#): [Here](https://gist.github.com/kpjVideo/1fddf0042fb520deba80100259f73e7b)


---

### Answer by username_2 on 2019-12-16. Score: 1

You can use my software at <https://github.com/username_2/antminer-monitor>. More features to come


---

