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 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
C Example
PHP Example
Python Example
Ruby Example
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