UseCryptos API

Return all the active trading pairs.
GET https://usecryptos.com/jsonapi/pairs
APIPairsResponse Response:
[
  "aur-btc",
  "aur-ltc",
  "doge-btc",
  "doge-ltc",
  "drk-btc",
  "drk-ltc",
  "frk-btc",
  "frk-ltc",
  "ltc-btc",
  "mint-btc",
  "mint-ltc",
  ...
]
Returns the statistics for all or a single market.
GET https://usecryptos.com/jsonapi/ticker
Example 1: https://usecryptos.com/jsonapi/ticker
Example 2: https://usecryptos.com/jsonapi/ticker/ltc-btc

Response:
{
  "aur-btc":{
    "marketName":"AUR-BTC",
    "lastprice":0.00000000,
    "last24hhigh":0.00000000,
    "last24hlow":0.00000000,
    "privolume":0.00000000,
    "secvolume":0.00000000
   },
  ...
}
Return the most recent 1000 trade history records of a specific market.
GET https://usecryptos.com/jsonapi/tradehistory/{marketname}
Example: https://usecryptos.com/jsonapi/tradehistory/ltc-btc

Response:
[
  {
    "tid":173,
    "date":"2014-03-12T13:39:03.46",
    "price":0.00280000,
    "amount":2.00000000
  },
  ...
]
Return all open orders of a specific market.
GET https://usecryptos.com/jsonapi/orders/{marketname}
Example: https://usecryptos.com/jsonapi/orders/ltc-btc

Response:
[
  {
    "type":"buy",
    "price":0.00260000,
    "amount":5.00000000,
    "total":0.0130000000000000
  },
  ...
]

Authenticated methods require the use of an api key and can only be accessed via the POST method.

URL - The URL you will be posting to is: https://usecryptos.com/privateapi

Authorization is performed by sending the following variables into the request header:

Key - Public API key. An example API key: B29AA4FD80A04D27B34FF6A97AB86A7E

Sign - ALL POST data (param=val & param1=val1) signed by a secret key according to HMAC-SHA512 method. Your secret key and public keys can be generated from your account settings page.

An additional security element must be passed into the post:

nonce - All requests must also include a special nonce POST parameter with incrementing integer. The integer must always be greater than the previous requests nonce value.

Other Variables:

method - The method from the list below which you are accessing.

General Return Values

error - Either a 1 or a 0. 0 Represents sucessful call, 1 Represents unsuccessful

msg - If unsuccessful, this will be the error message

data - If successful, this will be the data returned


<?php function api_query($method, array $req = array()) {
// API settings
$key = ''; // your API-key
$secret = ''; // your Secret-key

$req['method'] = $method;
$mt = explode(' ', microtime());
$req['nonce'] = $mt[1];

// generate the POST data string
$post_data = http_build_query($req, '', '&');

$sign = hash_hmac("sha512", $post_data, $secret);

// generate the extra headers
$headers = array(
'Sign: '.$sign,
'Key: '.$key,
);

// our curl handle (initialize if required)
static $ch = null;
if (is_null($ch)) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible;'.php_uname('s').'; PHP/'.phpversion().')');
}
curl_setopt($ch, CURLOPT_URL, 'https://usecryptos.com/privateapi');
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);

// run the query
$res = curl_exec($ch);

if ($res === false) throw new Exception('Could not get reply: '.curl_error($ch));
$dec = json_decode($res, true);
if (!$dec) throw new Exception('Invalid data received, please make sure connection is working and requested API exists');
return $dec;
}

$result = api_query("getinfo");
public static string Base(string PublicKey, string PrivateKey, string method, Dictionary<string, string> paramList = null, string url = "https://usecryptos.com/privateapi", int maxRetryCount = 3)
{
if (string.IsNullOrEmpty(PublicKey) || string.IsNullOrEmpty(PrivateKey))
{
throw new Exception("Please set public and private key using the static properties");
}
System.Net.ServicePointManager.Expect100Continue = false;
var request = WebRequest.Create(url);
var postData = String.Format("method={0}&nonce={1}", method, DateTime.UtcNow.Ticks);

if (paramList != null)
{
postData = paramList.Aggregate(postData, (current, pair) => current + String.Format("&{0}={1}", pair.Key, pair.Value));
}

var hmAcSha = new HMACSHA512(Encoding.ASCII.GetBytes(PrivateKey));
var messagebyte = Encoding.ASCII.GetBytes(postData);
var hashmessage = hmAcSha.ComputeHash(messagebyte);
var sign = BitConverter.ToString(hashmessage);
sign = sign.Replace("-", "");

request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = messagebyte.Length;
request.Method = "POST";
request.Headers.Add("Key", PublicKey);
request.Headers.Add("Sign", sign.ToLower());

try
{
var stream = request.GetRequestStream();
stream.Write(messagebyte, 0, messagebyte.Length);
stream.Close();
var response = request.GetResponse();
var postreqreader = new StreamReader(response.GetResponseStream());
var json = postreqreader.ReadToEnd();
return json;
}
catch (Exception exception)
{
if (--maxRetryCount == 0)
throw exception;
}

return null;
}

Inputs: n/a

Response :
  "servertimestamp": Current server timestamp
  "servertimezone": Current timezone for the server
  "balances": Array of currencies and the balances availalbe

Inputs:

  "marketid": Market ID for which you are creating an order for. (Use the field id from the api https://usecryptos.com/jsonapi/ticker)
  "ordertype": Order type you are creating ('buy'/'sell')
  "quantity": Amount of units (IN SATOSHI) you are buying/selling in this order. ex.: 1BTC should be sent as 100000000 (1 * 100000000)
  "price": Price per unit (IN SATOSHI) you are buying/selling at. ex.: 0.05 BTC should be sent as 5000000 (0.05 * 100000000)
Response :
  "orderid": If successful, the Order ID for the order which was created

Inputs:

  "marketid": Market ID for which you are querying (Use the field id from the api https://usecryptos.com/jsonapi/ticker)
Response :

Array of your orders for this market listing your current open sell and buy orders.

"id" - Order ID for this order

"date" - Datetime the order was created

"type" - Type of order (Buy/Sell)

"price" - The price per unit for this order

"amount" - Quantity remaining for this order

"total" - Total value of order (price * quantity)

"netTotal" - Total considering exchange fees

Inputs:

  "marketid": Market ID for which you are querying (Use the field id from the api https://usecryptos.com/jsonapi/ticker)
Response :

Array containing your Trades for this Market, in Date Decending Order

"tid" - An integer identifier for this trade

"type" - Type of trade (Buy/Sell)

"date" - Server datetime trade occurred

"price" - The price the trade occurred at

"amount" - Quantity traded

"total" - Total value of trade (tradeprice * quantity) - Does not include fees

"fee" - Fee Charged for this Trade

"initiateType" - The type of order which initiated this trade

"orderid" - Original order id this trade was executed against

Inputs:

  "orderid": Order ID for which you would like to cancel
Response :
n/a. If successful, it will return a success code.

Inputs:

  "coin": Currency Code for the coin you want to generate a new address for (ie. BTC = BitCoin)
Response :
  "address": The new generated address

Inputs:

  "coin": Currency Code for the coin you want to generate a new address for (ie. BTC = BitCoin)
Response:

Array your Trades for this Market, in Date Decending Order

"id" - An integer identifier for this transaction

"requestdate" - Date that the operation was requested

"processed" - If the transaction was processed or confirmed

"processeddate" - Date that the operation was processed

"type" - Deposit or Withdrawal

"amount" - Amount requested for this operation - Does not include fees

"fee" - Fee Charged for this operation

"txid" - The transaction ID or reference of the operation

Inputs:

"coin": Currency Code for the coin you want to withdraw (ie. BTC = BitCoin)

"address": The address that your want to send to.

"amount": Amount of units (IN SATOSHI) you want to send. ex.: 1BTC should be sent as 100000000 (1 * 100000000)

"fee": Amount of units (IN SATOSHI) you want to pay in fees (optional, if not set will use the minimun fee for each coin). ex.: 0.0001BTC should be sent as 10000 (0.0001 * 100000000)

"label": Description of this transaction. (optional)

Response :
  n/a. If successful, it will return a success code.

Inputs:

  "coin": Currency Code for the coin.
Response :
Array of Addresses.

Inputs:

  "coin": Currency Code for the coin.
  "amount": Currency Code for the coin.
  "clientcode": Currency Code for the coin.
  "description": Currency Code for the coin.
  "redirecturl": Currency Code for the coin.
  "notificationurl": Currency Code for the coin.
  "notificationemail": Currency Code for the coin.
Response :
{ id status date coin url address amount fee redirectURL notificationURL notificationEmail }