Cloud API is designed to be used by 3rd party applications and has full support for account management functions, from sign up to deposits and withdrawals. For trading robots you should use ordinary API at https://api.50x.com (“Public methods” and “Private methods” sections).
Please note that accounts created via Cloud API can be accessed only from the same 3rd party app in which they were created. Also, the app can be used to access the accounts created from this app only.
This literally means that each app uses separate user DB so it is impossible to login to the account created in another 3-rd party app.
To access api.50x.cloud, any HTTP query should contain X-PARTNER
header with the partner identification. For development purposes you can use the ‘other’ test identification. After the app has been developed, you can send an email to support@50x.com and obtain your permanent partner identification.
Likewise, all authorized queries should contain the X-SESSION
header field, which could be obtained by calling /json.login/
authorization method or /json.confirm_email/
email confirmation method.
For more details, refer to this JS example ("for dummies" code style) of using 50x.cloud API:
<!doctype html><html lang="en"><head><title>50x.cloud - Lightweight JS API Example</title><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<script type="text/javascript">
document.x_session = '';
function _e( elid ) {return document.getElementById(elid);} function _v( elid ) {return document.getElementById(elid).value;} function _l( msg ) {_e('id_log').innerHTML = _e('id_log').innerHTML + '<hr>' + msg;}
function _api(method, params, callback, errorcallback) {
var params_array = new Array();
for (var key in params) {
params_array.push(key + '=' + encodeURIComponent(params[key]));
}
var url = 'https://api.50x.cloud/' + method + '/';
var xmlhttp;
xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState != 4) return;
if (xmlhttp.status == 200) {
if ( callback ) {
callback(xmlhttp.responseText);
} else {
_l(xmlhttp.responseText);
}
} else {
if ( errorcallback ) {
errorcallback(xmlhttp.statusText);
} else {
_l('API CALL ERROR:' + xmlhttp.statusText);
}
}
}
xmlhttp.open("POST", url, true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.setRequestHeader("X-PARTNER", "other");
if ( document.x_session ) {
xmlhttp.setRequestHeader("X-SESSION", document.x_session);
}
xmlhttp.send(params_array.join('&'));
}
function b_login() {
_api( 'json.login', {'email':_v('id_login'),'password':_v('id_pwd'),'key':_v('id_2fa')}, function ( res ) {
_l( res );
if ( ! res.error ) { document.x_session = JSON.parse( res ).x_session_id; }
});
}
function b_userinfo() {
_api( 'json.userinfo', {} );
}
function b_join() {
_api( 'json.join', {'email':_v('id_email_reg'),'password':_v('id_pwd_reg'),'repassword':_v('id_repwd_reg')} );
}
function b_init_resetpwd() {
_api( 'json.init_resetpwd', {'email':_v('id_email_reset')} );
}
function b_confirm_email() {
_api( 'json.confirm_email', {'confirmation_code':_v('id_email_code')}, function ( res ) {
_l( res );
if ( ! res.error ) {
document.x_session = JSON.parse( res ).x_session_id;
}
});
}
function b_logout() {
_api( 'json.logout', {} );
}
function b_enable_2fa_1() {
_api( 'json.enable_2fa', {'step':'1'} );
}
function b_enable_2fa_2() {
_api( 'json.enable_2fa', {'step':'2','key':_v('id_2fa_code')} );
}
function b_disable_2fa_1() {
_api( 'json.disable_2fa', {'key':_v('id_2fa_code')} );
}
function b_disable_2fa_2() {
_api( 'json.disable_2fa', {'email':_v('id_login'),'password':_v('id_pwd'),'key':_v('id_2fa_code')} );
}
</script>
</head>
<body>
<input type="text" placeholder="E-Mail" id="id_email_reg"/>
<input type="text" placeholder="Password" id="id_pwd_reg"/>
<input type="text" placeholder="Repeat password" id="id_repwd_reg"/>
<input type="button" onclick="b_join();" value="Join"/>
<hr>
<input type="text" placeholder="E-Mail confirmation code" id="id_email_code"/>
<input type="button" onclick="b_confirm_email();" value="Confirm Email"/>
<hr>
<input type="text" placeholder="E-Mail for reset" id="id_email_reset"/>
<input type="button" onclick="b_init_resetpwd();" value="Reset password"/>
<hr>
<input type="text" placeholder="Login" id="id_login"/>
<input type="text" placeholder="Password" id="id_pwd"/>
<input type="text" placeholder="2FA" id="id_2fa"/>
<input type="button" onclick="b_login();" value="Login"/>
<input type="button" onclick="b_userinfo();" value="User Info"/>
<input type="button" onclick="b_logout();" value="Logout"/>
<hr>
<input type="button" onclick="b_enable_2fa_1();" value="Enable 2FA (step1)"/>
<input type="text" placeholder="2FA Code" id="id_2fa_code"/>
<input type="button" onclick="b_enable_2fa_2();" value="Enable 2FA (step2)"/>
<input type="button" onclick="b_disable_2fa_1();" value="Disable 2FA (after login)"/>
<input type="button" onclick="b_disable_2fa_2();" value="Disable 2FA (without login)"/>
<hr>
<div id="id_log"></div>
</body>
</html>
All requests, should no additional info be displayed to the user, return JSON with {"ok": true}
element upon success.
Any request to the API may result in JSON encoded response containing "error_code"
or "msg_id"
element. For both cases this response should be decoded using "code"
section of the translations file which contains both message and error codes. These responses may contain "values"
array with necessary values to be included in the translation, replacing corresponding ${n}
tag, where n
represents an index in the "values"
array.
Sample replies:
{"message": "Please check your email for activation link", "msg_id": 31001, "ok": true}
{"error_code": 37017, "error": "Auth fail"}
{"error_code": 33027, "error": "Not enough available balance for withdraw", "values": ["BTC", 1.2345, 0.987654321]}
The last example should be displayed to the user using this translation
element:
"code": {
"33027": {
"en": "Not enough available ${0} balance for withdraw, need ${1}, your available balance is ${2} ${0}",
"ru": "Недостаточно свободного баланса ${0} для вывода, требуется ${1}, в наличии свободно ${2} ${0}"
}
}
resulting in the folowing string to be displayed:
Not enough available BTC balance for withdraw, need 1.2345, your available balance is 0.987654321 BTC
POST https://api.50x.cloud/json.join/
Creating a new account
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
String | Yes | ||
password | String | Yes | password |
repassword | String | Yes | repeat password |
Note:
{"ok": true}
POST https://api.50x.cloud/json.login/
Login using POST request to get session ID
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
String | Yes | ||
password | String | Yes | password |
key | String | No | 2FA Code |
Sample reply upon success:
{"x_session_id": "frdifkahui2dc1fy59vr9fl2o08beb8u", "ok": true}
Sample reply upon an error:
{"error_code": 37017, "error": "Auth fail"}
If 2FA was activated for the current account and a key
parameter is missing, you will get 'error':'Need 2FA'
reply, and should ask the user to fill “2FA Code” input to be transferred as a value in key
parameter.
POST https://api.50x.cloud/json.confirm_email/
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
confirmation_code | String | Yes | Confirmation code from the email |
Sample reply upon success:
{"x_session_id": "frdifkahui2dc1fy59vr9fl2o08beb8u", "ok": true}
POST https://api.50x.cloud/json.init_resetpwd/
A e-mail with the password reset code will be sent to the user’s email.
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
String | Yes |
POST https://api.50x.cloud/json.resetpwd/
Setting new password using password reset code from email
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
String | Yes | ||
emailcode | String | Yes | code from email |
password | String | Yes | new password |
repassword | String | Yes | new password repeat |
key | String | No | 2FA Code, if activated |
POST https://api.50x.cloud/json.enable_2fa/
Enable 2FA on user’s account in two steps.
Step 1: request without parameters
Sample reply upon success:
{'key':'KJHD93UDWYY', "ok": true}
key
should be displayed to the user as a string and a QR-code for the Google Authenticator app
Step 2: request with parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
step | INT | Yes | value must be 2 |
key | String | Yes | 6-digit 2FA Code from Google Authenticator |
POST https://api.50x.cloud/json.disable_2fa/
Disable 2FA for all actions on user’s account.
Sample reply upon success:
{"ok": true}
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
key | String | Yes | 6-digit 2FA Code from Google Authenticator |
POST https://api.50x.cloud/json.deposit/
Returns address details for depositing given sym
.
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
sym | String | Yes | internal trading symbol of an asset to be deposited |
Sample reply upon success:
{"ok": true, "msg_id": 31002, "sym": "TUSD", "wallet": "0x9944hh4433gg22776622", "html": "\n To deposit TUSD, please send to this <strong>ETH address</strong>:<br><br><strong class=\"deposit-addr\">0x9944hh4433gg22776622</strong>\n ", "values": ["TUSD", "ETH", "0x9944hh4433gg22776622", "TrueUSD Stable Coin", null]}
ok
- TRUE on success
sym
- internal trading symbol of an asset to be deposited
wallet
- Address with tag in QR-code compatible format
msg_id
- Message code to be used with the translations file
html
- A default html-formatted message to be displayed in case of the translation failure
values
- An array with all variables for the translation
values[0]
- Same as ‘sym’, internal trading symbol of an asset to be deposited
values[1]
- Parent blockchain or payment system name
values[2]
- Address (without tag)
values[3]
- Tag (optional, only for the assets that require TAG, like XRP)
values[4]
- Asset name
POST https://api.50x.cloud/json.place_withdraw/
Creates a withdrawal order. 2FA must be activated to use this function.
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
sym | String | Yes | Internal trading symbol of an asset to be transferred |
amount | String | Yes | Amount to be transferred |
to_addr | String | Yes | Destination address |
to_tag | String | No | Tag for the assets that require tag as a part of address details (like XRP) |
key | String | Yes | 6-digit 2FA Code from Google Authenticator |
Sample reply upon success:
{"ok": true}
POST https://api.50x.cloud/json.logout/
Terminates current session
All methods are called upon by POST queries to https://api.50x.cloud Please look to HTML example code on top of this page.
All methods return JSON.
In case of success, JSON will NOT contain error field.
In case of an error, method will return JSON with {error:"error description"}
If method is designed to be called upon by an authorized user, but is called without authorization, JSON will contain {error:"Login required"}
POST https://api.50x.cloud/json.userinfo/
After authorization, user information and balances are shown
Parameters: No
Sample reply (subsequently, additional fields may appear):
{
"email_confirmed": true,
"last_auth_ip": "10.1.0.254",
"lang": "en",
"first_name": "Nick",
"ip_restriction_list": "",
"blocked": 0,
"prev_auth_ip": "10.1.0.254",
"email": "nick3@mail.com",
"username": "nick3@mail.com",
"ip_restriction_enabled": false,
"fa2_auth_enabled": true,
"last_name": "",
"actions": "",
"balances": [
["A2A(B)", 0.074999889323, 0.0],
["A2A", 0.0, 0.0],
["BTC", 0.8909556407, 0.28180805],
["ETH", 13.08039, 7.614],
["LTC", 0.11994, 0.0],
["PCT", 0.0, 0.0],
["DASH", 0.0, 0.0],
["USDT", 0.0, 0.0],
["BTG", 0.0, 0.0],
["BCH", 0.0, 0.0],
["TRX", 1839.7, 100.2],
["GSXC", 0.0, 0.0]
]
}
“balances” format: [“COIN-SYMBOL”, TOTAL_BALANCE, RESERVED_BALANCE]
POST https://api.50x.cloud/json.incoming_transactions/
shows list of incoming transactions (deposits)
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
pn | String | No | Page number starting from 1 (one page = 30 items) |
sym | String | No | currency symbol (for example, ETH,BTC,LTC…) |
state | String | No | “wait” or “ok” (to be deposited or already deposited) |
Sample reply:
{
"ok": true,
"orders": [
{"addr": "0x4687d453980f7da22ce8d2960c55045480edcf99",
"rec_time": 1522572619.0,
"txh": "0x9a8bdc9677dd33580738e0d0b2cfce260d68dae93a12d401c05889cd731e2468", "
symbol": "ETH",
"amount": 0.1,
"state": "ok",
"confirmations": 98},
{"addr": "0x4687d453980f7da22ce8d2960c55045480edcf99",
"rec_time": 1522146010.0,
"txh": "0x3fbf75c3e54ab072486c9c708a545fe6123dc76aa0418826e09dac0ce060f6b2",
"symbol": "ETH",
"amount": 0.002,
"state": "ok",
"confirmations": 5697},
{"addr": "0x4687d453980f7da22ce8d2960c55045480edcf99",
"rec_time": 1522146010.0,
"txh": "0x300fb44b9782d1d977472148d306297de8f887662a2677364dabde84044e6230",
"symbol": "ETH",
"amount": 0.0003,
"state": "ok",
"confirmations": 5765}
]
}
"state"
can be “wait” (to be deposited) or “ok” (deposited)POST https://api.50x.cloud/json.withdraw_orders/
List of withdrawal orders
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
pn | String | No | page number starting form 1 (one page = 30 items) |
sym | String | No | Currency symbol (for example, ETH,BTC,LTC…) |
state | String | No | “new”, “confirmed”, “done” (new, confirmed, completed) |
Sample reply:
{
"ok": true,
"orders": [
{"symbol": "DOGE",
"state": "done",
"time_payout": 1522220735.0,
"time_confirm": 1522220553.0,
"to_tag": null,
"time_create": 1522195200.0,
"out_txh": "4c024b9a56da913194850b3339f5c4ae03d7b0cfc3d8d7c86d70f2f97ee4f99b",
"to_addr": "DKJ4uJWKtP5oZtTbfuyzNTPfuVC444eSZr",
"amount": 98.0
"memo": "Any string up to 255 characters long for your own referance"},
{"symbol": "DASH",
"state": "done",
"time_payout": 1522218636.0,
"time_confirm": 1522218603.0,
"to_tag": null,
"time_create": 1522195200.0,
"out_txh": "acb3582a3238ee3722e83a900988de6f994dfa982fd628eb6bdb1b64f147f718",
"to_addr": "XnJ44u6EAyc3ePTZcxkcW1dFrVFvfc4ggh",
"amount": 0.00797,
"memo": "Any string up to 255 characters long for your own referance"}
]
}
"state"
can be “new”, “confirmed” or “done” (means completed)POST https://api.50x.cloud/json.place_order/
Placing a trading order
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
pair | String | Yes | Trading pair (for example, ETH/BTC, ETH/DASH, LTC/ETH) |
v | Float | Yes | Volume |
ot | String | Yes | Order type (l - limit, m - market) |
r | Float | Yes | Order execution rate |
bs | String | Yes | If BUY, then b, if SELL, then s |
lifetime | Float | No | Number of seconds of order’s lifetime from placement (optional) |
expire_time | Float | No | time when order is automatically cancelled (optional, lifetime has the priority) |
memo | String | No | Any string up to 255 characters long for your own referance |
Sample reply:
{"ok": true,
"order": {"bs": "b",
"expire_time": 0,
"filled_vol": 0,
"oid": 151871,
"pair": "ETH/BTC",
"rate": 0.001,
"state": 0,
"sym1": "ETH",
"sym2": "BTC",
"time_cancel": 0,
"time_complete": 0,
"time_create": 1536856649.0,
"time_last_fill": 0,
"type": "l",
"vol": 1.0,
"memo": "Any string up to 255 characters long for your own referance",}
}
POST https://api.50x.cloud/json.cancel_order/
Cancels an open order
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
oid | String | Yes | order’s id |
Sample reply:
{"oid": 151871, "ok": true}
POST https://api.50x.cloud/json.cancel_orders/
Cancels all orders that match search conditions.
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
sym | String | No | Asset Symbol |
pair | String | No | Trading pair |
bs | String | No | Trading direction (buy/sell) |
Parameters usage:
sym
- if specified, all open orders with sym will be cancelled. Should not be used with "pair’.
pair
- if specified, all open orders with provided trading pair AND reverse trading pair will be cancelled. Should not be used with "sym’.
bs
- Trading direction (buy/sell). Use bs=‘s’ to cancel only SELL orders, use bs=‘b’ to cancel only BUY orders.
Sending request without parameters will result in cancelling all open orders for the user.
Sample reply:
{"ok": true}
POST https://api.50x.cloud/json.change_order/
Change an open order
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
oid | String | Yes | id orders |
amount | Float | No | order’s new volume (optional, if not included or = 0, then volume shall remain unchanged) |
rate | Float | No | order’s new rate (optional, if not included or = 0, then rate shall remain unchanged) |
expire_time | Float | No | order’s expiration time, unix timestamp (when it is automatically cancelled, optional, if not inlucded, shall remain unchanged) |
memo | String | No | Any string up to 255 characters long for your own referance |
Sample reply:
{"ok": true}
POST https://api.50x.cloud/json.orderslist/
Returns the list of open orders.
If history=1 parameter is included, returns the list of closed orders.
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
history | String | No | if included, shows history, and not open orders |
pn | Float | No | page number starting from 1 (one page = 50 orders) |
pair | String | No | selection based on the indicated pair (for example, ETH/BTC, ETH/DASH, LTC/ETH) |
sym1 | String | No | selection based on the pair’s first symbol (for example, for ETH/BTC, the first symbol is ETH) |
sym2 | String | No | selection based on the pair’s second symbol (for example, for ETH/BTC, the second symbol is BTC) |
ot | String | No | selection based on the order’s type (l,m,c - see place_order description) |
bs | String | No | selection based on BUY or SELL, b and s values respectively |
state | Float | No | selection based on the trading order’s state |
list of possible states of trading orders:
0 - Waiting
, 1 - Placed
, 2 - Partial filled
, 3 - Full filled
, 50 - Wait for cancel
, 51 - Cancelling
, 52 - Cancelled
Sample reply:
{"ok": true, "orders": [
{"time_last_fill": 0,
"time_cancel": 0,
"filled_vol": 0.0,
"rate": 0.07598567,
"commission": 0.2,
"vol": 1.0,
"time_create": 1525244149.0,
"oid": 101011,
"sym1": "ETH",
"time_complete": 0,
"condition_details": null,
"sym2": "BTC",
"state": 0,
"condition_type": null,
"bs": "b",
"pair": "ETH/BTC",
"memo": "Any string up to 255 characters long for your own referance",
"type": "l"},
...
]}
POST https://api.50x.cloud/json.blotter/
Obtain all operations with the selected currency on the account
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
sym | String | Yes | Currency symbol |
Sample reply:
{"ok": true,
"blotter": [{"addr": "",
"amount": 1.0,
"at": 1536857914.0,
"data_id": 151907,
"o_bs": "b",
"o_pair": "ETH/BTC",
"o_rate": 0.03247101,
"o_t": "m",
"o_vol": 1.0,
"sym": "ETH",
"t": "tc",
"tag": "",
"txh": ""}],
}
Reply common values:
“at” - Timestamp of the transaction
“t” - transaction source: indicates which module initiated the transaction, possible states:
tc - Trading Core
, com - Commission
, wd - Withdrawal
, in - Incomming transaction (deposit)
, fix - Error correction
“data_id”- transaction ID, or order ID for trades (if “t”=“tc”)
“amount”- Balance change for selected asset
“sym”- Asset Symbol
Reply deposit/withdrawal values:
“txh” - TxHash for withdrawals
“tag” - Transaction tag for withdrawals for thecoins requiring tags like XRP, IOTA, XLM
“addr” - External blockchain address for deposits and withdrawals
Reply trade/commission/fix values:
“o_bs” - buy/sell for trades: b - buy
, s - sell
“o_t” - Order Type for trades: l - limit
, m - market
“o_pair” - Order Type for trades
“o_vol” - Order Volume for trades
“o_rate” - Order Rate for trades
GET https://rates.50x.com/market/
Obtain current average quotes with the base in selected currency or 1/median quotes in selected currency
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
base | String | No | Base currency symbol |
coin | String | No | Currency symbol |
Note:
base
or coin
Sample query:
GET https://rates.50x.com/market?base=BTC
Sample reply:
[{
"STE":
{
"vol": 15463,
"rate": 4.183e-05,
"change": 0.0
},
"BCH":
{
"vol": 463,
"rate": 0.079074,
"change": -0.16
},
...
}]
vol - volume in BASE units or in COIN units (depends on query)
rate - rate
change - changes in % over the last 24 hours
GET https://rates.50x.com/orderbook/
obtain orderbook for an indicated pair
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
pair | String | Yes | Pair symbol |
Sample query:
GET https://rates.50x.com/orderbook?pair=STE/ETH
Sample reply:
{
"rate_med": 0.00108505,
"rate_bid": 0.00101011,
"rate_ask": 0.00115999,
"bid": [
[0.00101011, 1085.55],
[0.0010101, 130.9999977],
...
],
"ask": [
[0.00115999, 676.24147622],
[0.00116, 1423.12]
...
]
}
rate_med - average price between best bid and best ask= ( best bid + best ask ) / 2
rate_bid - best bid
rate_ask - best ask
bid - bids (buy orders) array in format [ price, volume ]
ask - asks (sell orders) array in format [ price, volume ]
GET https://rates.50x.com/chart/
obtain median rates chart for a pair
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
pair | String | Yes | Pair symbol |
period | String | Yes | Period symbol |
begin | Timestamp | No | Beginning of the requested period |
end | Timestamp | No | End of the requested period |
Available periods: M1, M5, M15, M30, H1, H2, H4, D, W
Sample query:
GET https://rates.50x.com/chart?pair=ETH/DASH&period=h1
Sample reply:
[{"close": 1.28261031,
"date": 1536256800,
"high": 1.29277708,
"low": 1.27164355,
"open": 1.28232894},
{"close": 1.27752193,
"date": 1536260400,
"high": 1.30094927,
"low": 1.2643695,
"open": 1.28310266},
{"close": 1.27696195,
"date": 1536264000,
"high": 1.28768982,
"low": 1.27360386,
"open": 1.27763158},
...
]
POST https://rates.50x.com/last_trades/
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
pair | String | No | Pair’s name (obtain last trades for a pair) |
sym | String | No | Currency’s name (obtain last trades for a currency) |
Sample reply:
{"ok": true,
"trades": [{"bs": "b",
"pair": "ETH/BTC",
"rate": 0.02993642,
"ts": 1536678972.0,
"vol1": 0.81505393,
"vol2": 0.0243998},
{"bs": "b",
"pair": "ETH/BTC",
"rate": 0.03,
"ts": 1536677973.0,
"vol1": 10.0,
"vol2": 0.3},
...]
}