Developer's Guide - Api

Overview

AltMarkets.cc provides a simple and powerful REST API to allow you to programatically perform nearly all actions you can from our web interface. All requests use the application/json content type and go over https. The base url is https://altmarkets.cc/api/{version}/. All requests are GET requests and all responses come in a default response object with the result in the result field. Always check the success flag to ensure that your API call succeeded.

We are currently restricting orders to 500 open orders and 200,000 orders a day. We reserve the right to change these settings as we tune the system.

If you have any questions, feedback or recommendation for API support you can post a question in our support center.


Getting Started

  • General
  • Authentication
  • API Reference
  • Client Libraries

General

We provide a simple RESTful API. All calls are GETs and should be called via https. We will support n-1 versions of the API. Our current stable API is v1. The endpoints have a standard format as follows:

https://altmarkets.cc/api/{version}/{method}?param=value

Authentication

In the spirit of keeping things simple, we offer an easy to manage API Key authentication method. You can have multiple API keys, each with their own level of rights. To manage your API keys please goto Settings->Manage API Keys. API Rights

  • Read Info - You can only view the balances, orders, and other details of the account
  • Trade Limit - This allows the API key to place LIMIT buy and sell orders
  • Withdraw - We allow you to programatically withdraw any currency to an address you provide. This can be used to quick arbitrage exchanges or move money into cold storage after thresholds.
For this version, we use a standard HMAC-SHA512 signing. Append apikey and nonce to your request and calculate the HMAC hash and include it under an apisign header. Note: the nonce is not respected right now but will be enforced later.

<?php

$request = '/account/getbalance';
$currency = 'DOGE';

$apikey='__API_KEY__';
$apisecret='__API_SECRET__';
$nonce=time();

$uri='https://altmarkets.cc/api/v1'.$request .'?apikey='.$apikey.'&nonce='.$nonce.'&market='.$market.'&currency='.$currency;
$sign=hash_hmac('sha512',$uri,$apisecret);
$ch = curl_init($uri);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('apisign:'.$sign));
$execResult = curl_exec($ch);
$obj = json_decode($execResult);   
?>                    
                


'use strict';

const API_PUB_KEY = "__YOUR_API_PUBLIC_KEY__";
const API_PRIV_KEY = "__YOUR_API_PRIVATE_KEY__";

GetOpenOrders('BTC-DOGE', data => { console.log(JSON.stringify(data.result || data)); });

function GetOpenOrders(market, callback)
{
    const nonce = Date.now()+Math.floor(Math.random() * (1000)) + 1;
    const uri = 'https://altmarkets.cc/api/v1/market/getopenorders?apikey='+API_PUB_KEY+'&nonce='+nonce+'&market='+market;
    const parsed = require('url').parse(uri, true);
    const signature = require('crypto').createHmac('sha512', API_PRIV_KEY).update(new Buffer(uri, 'utf-8')).digest('hex');
    
    const options = {
        host: parsed.host,
        path: parsed.path,
        headers: { 'apisign': signature }
    };
    
    require("https").request(options, res => {
        let output = '';
        res.on('data', chunk => { output += chunk; });
        res.on('end', () => { return callback(JSON.parse(output)); }); }).end();
};
                

API Reference

Our APIs are broken into distinct groups
  • Public - Public information available without an API key
  • Market - For programatic trading of crypto currencies
  • Account - For managing your account

Public Api

/public/getmarkets

Used to get the open and available trading markets at AltMarkets.cc along with other meta data.

Parameters

None

Request:
https://altmarkets.cc/api/v1/public/getmarkets
Response:
    {
	"success" : true,
	"message" : "",
	"result" : [{
			"MarketCurrency" : "LTC",
			"BaseCurrency" : "BTC",
			"MarketCurrencyLong" : "Litecoin",
			"BaseCurrencyLong" : "Bitcoin",
			"MinTradeSize" : "0",
			"MarketName" : "BTC-LTC",
			"IsActive" : true,
			"Created" : "2014-02-13T00:00:00"
		}, {
			"MarketCurrency" : "DOGE",
			"BaseCurrency" : "BTC",
			"MarketCurrencyLong" : "Dogecoin",
			"BaseCurrencyLong" : "Bitcoin",
			"MinTradeSize" : "0",
			"MarketName" : "BTC-DOGE",
			"IsActive" : true,
			"Created" : "2014-02-13T00:00:00"
		}
        ]
    }

                    
/public/getorderbook

Used to get retrieve the orderbook for a given market

Parameters
parameter required description
market required a string literal for the market (ex: BTC-LTC)
type optional buy, sell or both to identify the type of orderbook to return. By default type='both'
Request:
https://altmarkets.cc/api/v1/public/getorderbook?market=BTC-LTC&type=both 
Response:
    {
	"success" : true,
	"message" : "",
	"result" : {
		"buy" : [{
				"Quantity" : 12.37000000,
				"Rate" : 0.02525000
			}
		],
		"sell" : [{
				"Quantity" : 32.55412402,
				"Rate" : 0.02540000
			}, {
				"Quantity" : 60.00000000,
				"Rate" : 0.02550000
			}, {
				"Quantity" : 60.00000000,
				"Rate" : 0.02575000
			}, {
				"Quantity" : 84.00000000,
				"Rate" : 0.02600000
			}
		]
	}
    }

                    
/public/getmarketsummary

Used to get the last 24 hour summary of one active exchange

Parameters
parameter required description
market required a string literal for the market (ex: BTC-LTC)
Request:
https://altmarkets.cc/api/v1/public/getmarketsummary?market=BTC-LTC
Response:
    {
	"success" : true,
	"message" : "",
	"result" : {
			"MarketName" : "BTC-LTC",
			"High" : 0.01350000,
			"Low" : 0.01200000,
			"Volume" : 3833.97619253,
			"Last" : 0.01349998,
			"Bid" : 0.01271001,
			"Ask" : 0.01291100,
			"OpenBuyOrders" : 45,
			"OpenSellOrders" : 45
		}
		}
                     
/public/getmarkets24

Used to get the last 24 hour summary of all active exchanges

Parameters Request:
https://altmarkets.cc/api/v1/public/getmarkets24
Response:
     {
     "success":true,
     "message":"",
     "result":{
         "TotalMarkets":22,
         "v24":30545.55264574,
         "data":{
             "CYR":{"MarketName":"BTC-CYR","High":"1.10000000","Low":"1.10000000","Volume":"21.74889000","Last":"1.1000000","Bid":"1.10000000","Ask":"1.99990000","OpenBuyOrders":5,"OpenSellOrders":15,"coin_icon_src":"https%3A//raw.githubusercontent.com/conan-equal-newone/yenten/master/src/qt/res/icons/bitcoin.png","coin_info":{"minconf":6,"hold":0.002,"active":true,"page":"https://bitcointalk.org/index.php?topic=2329470.0"}},
             "DOGE":{"MarketName":"MC-DOGE","High":"1.01000000","Low":"0.49999999","Volume":"890.04802700","Last":"1.0100000","Bid":"0.31000001","Ask":"1.01000000","OpenBuyOrders":8,"OpenSellOrders":104,"coin_icon_src":"https%3A//raw.githubusercontent.com/wavidev-the-man/wavi/master/src/qt/res/icons/bitcoin.png","coin_info":{"minconf":3,"hold":0.002,"active":true,"page":"https://bitcointalk.org/index.php?topic=3146751.0"}},
             ...
             }
         }
    }
                    
/public/getmarkethistory

Used to retrieve the latest trades that have occured for a specific market.

Parameters
parameter required description
market required a string literal for the market (ex: BTC-LTC)
Request:
https://altmarkets.cc/api/v1/public/getmarkethistory?market=BTC-LTC
Response:
    {
	"success" : true,
	"message" : "",
	"result" : [{
			"Id" : 319435,
			"TimeStamp" : "2018-01-01T03:21:20.08",
			"Quantity" : 0.30802438,
			"Price" : 0.01263400,
			"Total" : 0.00389158,
			"FillType" : "FILL",
			"OrderType" : "BUY"
		}, {
			"Id" : 319433,
			"TimeStamp" : "2018-01-01T03:21:20.08",
			"Quantity" : 0.31820814,
			"Price" : 0.01262800,
			"Total" : 0.00401833,
			"FillType" : "FILL",
			"OrderType" : "BUY"
		}, {
			"Id" : 319379,
			"TimeStamp" : "2018-01-01T02:58:48.127",
			"Quantity" : 49.64643541,
			"Price" : 0.01263200,
			"Total" : 0.62713377,
			"FillType" : "FILL",
			"OrderType" : "SELL"
		}, {
			"Id" : 319378,
			"TimeStamp" : "2018-01-01T02:58:46.27",
			"Quantity" : 0.35356459,
			"Price" : 0.01263200,
			"Total" : 0.00446622,
			"FillType" : "FILL",
			"OrderType" : "SELL"
		}
	]
    }
                        
                    

Market Apis

/market/buylimit

Used to place a buy order in a specific market. Use buylimit to place limit orders. Make sure you have the proper permissions set on your API keys for this call to work

Parameters
parameter required description
market required a string literal for the market (ex: BTC-LTC)
quantity required the amount to purchase
rate required the rate at which to place the order.
Request:
https://altmarkets.cc/api/v1/market/buylimit?apikey=API_KEY&nonce=NONCE&market=BTC-LTC&quantity=1.2&rate=1.3
Response - Returns you the order uuid:
    {
	"success" : true,
	"message" : "",
	"result" : {
		"uuid" : "e606d53c-8d70-11e3-94b5-425861b86ab6"
	}
    }                        
                    
 'use strict';
 
 const API_PUB_KEY = "__YOUR_API_PUBLIC_KEY__";
 const API_PRIV_KEY = "__YOUR_API_PRIVATE_KEY__";
 
 BuyLimit('LTC-BTC', 0.00001, 1135000, data => { console.log(JSON.stringify(data.result || data)); });
 
 function BuyLimit(market, quantity, rate, callback)
 {
     const nonce = Date.now()+Math.floor(Math.random() * (1000)) + 1;
     const uri = 'https://altmarkets.cc/api/v1/market/buylimit?apikey='+API_PUB_KEY+'&nonce='+nonce+'&market='+market+'&quantity='+quantity+'&rate='+rate;
     const parsed = require('url').parse(uri, true);
     const signature = require('crypto').createHmac('sha512', API_PRIV_KEY).update(new Buffer(uri, 'utf-8')).digest('hex');
     
     const options = {
         host: parsed.host,
         path: parsed.path,
         headers: { 'apisign': signature }
     };
     
     require("https").request(options, res => {
         let output = '';
         res.on('data', chunk => { output += chunk; });
        res.on('end', () => { return callback(JSON.parse(output)); });
    }).end();
     
 }
                 


/market/selllimit

Used to place an sell order in a specific market. Use selllimit to place limit orders. Make sure you have the proper permissions set on your API keys for this call to work

Parameters
parameter required description
market required a string literal for the market (ex: BTC-LTC)
quantity required the amount to purchase
rate required the rate at which to place the order.
Request:
https://altmarkets.cc/api/v1/market/selllimit?apikey=API_KEY&nonce=NONCE&market=BTC-LTC&quantity=1.2&rate=1.3
Response - Returns you the order uuid:
    {
	"success" : true,
	"message" : "",
	"result" : {
		"uuid" : "614c34e4-8d71-11e3-94b5-425861b86ab6"
	}
    }                        
                    
 'use strict';
 
 const API_PUB_KEY = "__YOUR_API_PUBLIC_KEY__";
 const API_PRIV_KEY = "__YOUR_API_PRIVATE_KEY__";
 
 SellLimit('LTC-BTC', 0.00001, 11350000, data => { console.log(JSON.stringify(data.result || data)); });
 
 function SellLimit(market, quantity, rate, callback)
 {
     const nonce = Date.now()+Math.floor(Math.random() * (1000)) + 1;
     const uri = 'https://altmarkets.cc/api/v1/market/selllimit?apikey='+API_PUB_KEY+'&nonce='+nonce+'&market='+market+'&quantity='+quantity+'&rate='+rate;
     const parsed = require('url').parse(uri, true);
     const signature = require('crypto').createHmac('sha512', API_PRIV_KEY).update(new Buffer(uri, 'utf-8')).digest('hex');
     
     const options = {
         host: parsed.host,
         path: parsed.path,
         headers: { 'apisign': signature }
     };
     
     require("https").request(options, res => {
         let output = '';
         res.on('data', chunk => { output += chunk; });
         res.on('end', () => { return callback(JSON.parse(output)); });
     }).end();
     
 }
                 


+
/market/cancel

Used to cancel a buy or sell order.

Parameters
parameter required description
uuid required uuid of buy or sell order
Request:
https://altmarkets.cc/api/v1/market/cancel?apikey=API_KEY&nonce=NONCE&uuid=ORDER_UUID 
Response - Returns you the order uuid:
    {
        "success" : true,
        "message" : "",
        "result" : null
    }
                    
 'use strict';
 
 const API_PUB_KEY = "__YOUR_API_PUBLIC_KEY__";
 const API_PRIV_KEY = "__YOUR_API_PRIVATE_KEY__";
 
 CancelOrder("1530078445865-2-0.6676880290983116", data => { console.log(JSON.stringify(data.result || data)); });
 
 function CancelOrder(uuid, callback)
 {
     const nonce = Date.now()+Math.floor(Math.random() * (1000)) + 1;
     const uri = 'https://altmarkets.cc/api/v1/market/cancel?apikey='+API_PUB_KEY+'&nonce='+nonce+'&uuid='+uuid;
     const parsed = require('url').parse(uri, true);
     const signature = require('crypto').createHmac('sha512', API_PRIV_KEY).update(new Buffer(uri, 'utf-8')).digest('hex');
     
     const options = {
         host: parsed.host,
         path: parsed.path,
         headers: { 'apisign': signature }
     };
     
     require("https").request(options, res => {
         let output = '';
         res.on('data', chunk => { output += chunk; });
         res.on('end', () => { return callback(JSON.parse(output)); });
     }).end();
     
 }
                 


/market/getopenorders

Get all orders that you currently have opened.

Parameters
parameter required description
market required a string literal for the market (ie. BTC-LTC)
Request:
https://altmarkets.cc/api/v1/market/getopenorders?apikey=API_KEY&nonce=NONCE&market=BTC-LTC  
Response - Returns you the order uuid:
    {
	"success" : true,
	"message" : "",
	"result" : [{
			"OrderUuid" : "09aa5bb6-8232-41aa-9b78-a5a1093e0211",
			"Exchange" : "BTC-LTC",
			"QuantityRemaining" : 5.00000000,
			"Price" : 2.00000000,
			"Opened" : "2018-01-01T03:55:48.77",
		}, {
			"OrderUuid" : "8925d746-bc9f-4684-b1aa-e507467aaa99",
			"Exchange" : "BTC-LTC",
			"QuantityRemaining" : 100000.00000000,
			"Price" : 0.00000001,
			"Opened" : "2018-01-01T03:55:48.583",
		}
	]
    }
                        
                    
 'use strict';
 
 const API_PUB_KEY = "__YOUR_API_PUBLIC_KEY__";
 const API_PRIV_KEY = "__YOUR_API_PRIVATE_KEY__";
 
 GetOpenOrders('LTC-BTC', data => { console.log(JSON.stringify(data.result || data)); });
 
 function GetOpenOrders(market, callback)
 {
     const nonce = Date.now()+Math.floor(Math.random() * (1000)) + 1;
     const uri = 'https://altmarkets.cc/api/v1/market/getopenorders?apikey='+API_PUB_KEY+'&nonce='+nonce+'&market='+market;
     const parsed = require('url').parse(uri, true);
     const signature = require('crypto').createHmac('sha512', API_PRIV_KEY).update(new Buffer(uri, 'utf-8')).digest('hex');
     
     const options = {
         host: parsed.host,
         path: parsed.path,
         headers: { 'apisign': signature }
     };
     
     require("https").request(options, res => {
         let output = '';
         res.on('data', chunk => { output += chunk; });
         res.on('end', () => { return callback(JSON.parse(output)); });
     }).end();
 };
                 



Account Api

/account/getbalance

Used to retrieve the balance from your account for a specific currency.

Parameters
parameter required description
currency required a string literal for the currency (ex: BTC)
Request:
https://altmarkets.cc/api/v1/account/getbalance?apikey=API_KEY&nonce=NONCE&currency=BTC
Response:
    {
	"success" : true,
	"message" : "",
	"result" : {
		"Currency" : "BTC",
		"Balance" : 4.21549076,
		"Available" : 4.21549076,
		"Pending" : 0.00000000
	}
    }                        
                    
 'use strict';
 
 const API_PUB_KEY = "__YOUR_API_PUBLIC_KEY__";
 const API_PRIV_KEY = "__YOUR_API_PRIVATE_KEY__";
 
 GetBalance('LTC', data => { console.log(JSON.stringify(data.result || data)); });
 
 
 function GetBalance(currency, callback)
 {
     const nonce = Date.now()+Math.floor(Math.random() * (1000)) + 1;
     const uri = 'https://altmarkets.cc/api/v1/account/getbalance?apikey='+API_PUB_KEY+'&nonce='+nonce+'&currency='+currency;
     const parsed = require('url').parse(uri, true);
     const signature = require('crypto').createHmac('sha512', API_PRIV_KEY).update(new Buffer(uri, 'utf-8')).digest('hex');
     
     const options = {
         host: parsed.host,
         path: parsed.path,
         headers: { 'apisign': signature }
     };
     
     require("https").request(options, res => {
         let output = '';
         res.on('data', chunk => { output += chunk; });
         res.on('end', () => { return callback(JSON.parse(output)); });
     }).end();
 };
                 


/account/getdepositaddress

Used to retrieve or generate an address for a specific currency.

Parameters
parameter required description
currency required a string literal for the currency (ie. BTC)
Request:
https://altmarkets.cc/api/v1/account/getdepositaddress?apikey=API_KEY&nonce=NONCE&currency=LTC
Response:
    {
    	"success" : true,
    	"message" : "",
    	"result" : {
    		"Currency" : "BTC",
    		"Address" : "1y5SKeKGXUHKS2WVpJ76HYuKAu3URastUo"
    	}
    }
                    
/account/getorder

Used to retrieve a single order by uuid.

Parameters
parameter required description
uuid required the uuid of the buy or sell order
Request:
https://altmarkets.cc/api/v1/account/getorder?apikey=API_KEY&nonce=NONCE&uuid=ORDER_UUID
Response:
    {
    	"success" : true,
    	"message" : "",
    	"result" : {
    		"OrderUuid" : "0cb4c4e4-bdc7-4e13-8c13-430e587d2cc1",
    		"Exchange" : "BTC-BTC",
    		"QuantityRemaining" : 1000.00000000,
    		"Price" : 0.00000001,
    		"Opened" : "2018-01-01T07:45:46.27",
    		"IsOpen" : true
    	}
    }
                    
 'use strict';
 
 const API_PUB_KEY = "__YOUR_API_PUBLIC_KEY__";
 const API_PRIV_KEY = "__YOUR_API_PRIVATE_KEY__";
 
 GetOrder("1530077938662-2-0.04123927384759796", data => { console.log(JSON.stringify(data.result || data)); });
 
 function GetOrder(uuid, callback)
 {
     const nonce = Date.now()+Math.floor(Math.random() * (1000)) + 1;
     const uri = 'https://altmarkets.cc/api/v1/account/getorder?apikey='+API_PUB_KEY+'&nonce='+nonce+'&uuid='+uuid;
     const parsed = require('url').parse(uri, true);
     const signature = require('crypto').createHmac('sha512', API_PRIV_KEY).update(new Buffer(uri, 'utf-8')).digest('hex');
     
     const options = {
         host: parsed.host,
        path: parsed.path,
        headers: { 'apisign': signature }
     };
     
     require("https").request(options, res => {
         let output = '';
         res.on('data', chunk => { output += chunk; });
         res.on('end', () => { return callback(JSON.parse(output)); });
     }).end();
     
 }
                 


/account/getorderhistory

Used to retrieve your order history.

Parameters
parameter required description
market required a string literal for the market (ie. BTC-LTC).
Request:
https://altmarkets.cc/api/v1/account/getorderhistory?apikey=API_KEY&nonce=NONCE&market=BTC-LTC
Response:
    {
    	"success" : true,
    	"message" : "",
    	"result" : [{
    			"OrderUuid" : "fd97d393-e9b9-4dd1-9dbf-f288fc72a185",
    			"TimeStamp" : "2018-01-01T04:01:00.667",
    			"Price" : 0.00000001,
    			"QuantityRemaining" : 100000.00000000,
    		}, {
    			"OrderUuid" : "17fd64d1-f4bd-4fb6-adb9-42ec68b8697d",
    			"TimeStamp" : "2018-01-01T20:38:58.317",
    			"Price" : 0.00002950,
    			"QuantityRemaining" : 0.00000000,
    		}
    	]
    }
                    
/account/withdraw

Used to withdraw funds from your account.

Parameters
parameter required description
currency required a string literal for the market (ie. BTC-LTC).
quantity required the quantity of coins to withdraw
address required the address where to send the funds
Request:
https://altmarkets.cc/api/v1/account/withdraw?apikey=API_KEY&nonce=NONCE&currency=CYR&quantity=20.40&address=CYR_ADDRESS
Response:
 {
 	"success" : true,
 	"message" : "",
 	"result" : {
 			"uuid" : "68b5a16c-92de-11e3-ba3b-425861b86ab6"
 	}
 }
                     
 'use strict';
 
 const API_PUB_KEY = "__YOUR_API_PUBLIC_KEY__";
 const API_PRIV_KEY = "__YOUR_API_PRIVATE_KEY__";
 
 Withdraw('CYR', 5, 'CVe3eoMq7TeGMzPw9EpXGpKQzW2aMvJNAa', data => { console.log(JSON.stringify(data.result || data)); });
 
 function Withdraw(currency, quantity, address, callback)
 {
     const nonce = Date.now()+Math.floor(Math.random() * (1000)) + 1;
     const uri = 'https://altmarkets.cc/api/v1/account/withdraw?apikey='+API_PUB_KEY+'&nonce='+nonce+'¤cy='+currency+'&quantity='+quantity+'&address='+address;
     const parsed = require('url').parse(uri, true);
     const signature = require('crypto').createHmac('sha512', API_PRIV_KEY).update(new Buffer(uri, 'utf-8')).digest('hex');
     
     const options = {
         host: parsed.host,
         path: parsed.path,
         headers: { 'apisign': signature }
     };
     
     require("https").request(options, res => {
         let output = '';
         res.on('data', chunk => { output += chunk; });
         res.on('end', () => { return callback(JSON.parse(output)); }); }).end();
 }