Vous êtes sur la page 1sur 27

HTTP API

0. General
StocksExchange provides all the core exchange functionality, and additional merchant tools
available via the HTTP API where all returned messages are in JSON. It's much easier to
work with the API by using one of the clients provided by StocksExchange (now available
only in PHP), so while this page describes the API in case you want or need to build your
own client, the examples use the PHP client. To view and downloads the clients, please visit:
API PHP Client

In order to use the API functions, you must have an API key and API secret, which is
generated in the user profile.

The base URL for all the​ requests other than ​ticker​ ​is ​https://stocks.exchange/api2​.

Authentication
Most of the calls described next require authentication. All those are POST requests that
must be created according to the following steps:
1.​ ​Include a unique 'nonce' argument (numeric value).
2.​ ​Include an 'method' argument set to the end point for the request.
3.​ ​Represent the (key, value) pairs present in the request as JSON. Let SIGNDATA be
the result of this step.
4.​ ​Calculate the HMAC-SHA512 of SIGNDATA using your API secret.
5.​ ​Create a 'Sign' header and set its value to the hexadecimal digest resulting from the
HMAC-SHA512 calculation.
6.​ ​Create a 'Key' header and set its value to your API key.
7.​ ​Send a POST request with the parameter SIGNDATA.

For all purposes the nonce must be unique within an API key. If this is not the case, or the
signature doesn't match, an error will be returned.

To get started with the PHP client, here's a snippet for creating a client with existing
credentials:
require_once(__DIR__ .'/stockExchange.php');
$API = array('key' => <<API key>>, 'secret' => <<API secret>>);
$client = new StockExange($API['key'], $API['secret']);

The ​$client ​instance is assumed to be available in the following examples.


Note that the clients provided do all the steps required for signing data. The limited testing
can be done through the​ ​testi_api​ page.
Errors
When you handling an API request all answers start by parameter ​"status".
If any errors occur when handling an API request, the response will follow this format:
{
"status": 0,
"error": <<error message describing problem goes here>>
}

Any response that contains the 'error' field should be considered unsuccessful for the reason
given. Note that HTTP errors may also be thrown depending on the issue.

There are two types of API errors when you handling an API request:
1. Common errors (main errors such as “Invalid Sign” etc)
2. Method errors (errors that generate if something going wrong when you processing a
particular ​API request). ​These errors will be described individually in each method

Common Errors
Here is a list with common errors and their descriptions:
1.​ ​Invalid Key - not generated key or the key does not correspond to the a user
2.​ ​Invalid Sign - bad hash-code
3.​ ​Invalid Nonce - wrong or empty parameter Nonce
4.​ ​Duplicate Request - parameter Nonce is not unique
5.​ ​Invalid Method - this method is wrong or missing
1. Private API
1.1 Account Information
Get information about your account. Return an overview of:
1.​ ​user email and username
2.​ ​user sessions (active user sessions)
3.​ ​funds ( available balance in all currencies)
4.​ ​hold_funds ( balance in orders)
5.​ ​wallets addresses ( numbers of wallets with exchange types)
6.​ ​public keys (public key for each wallet if exist)
7.​ ​Assets portfolio (funds, hold_funds, wallet address and public key for each asset)
8.​ ​open orders ( count of open orders)
9.​ ​server_time ( current server time)

endpoint:​ ​GetInfo
method:​ ​POST

Example:
$client->get_info()

Result:
{
"​success​": ​1,
"data": {
"email": "some_email@gmail.com",
"username": "some_username",
"userSessions": [
{
"ip":"46.164.189.25",
"date":"2016-06-29 15:41:21",
"created_at":"2016-06-28 20:30:28",
"active":false
}
],
funds": {
"NXT": "8",
"BTC": "0.018"
},
hold_funds": {
"NXT": "18",
"BTC": "0"
},
"wallets_addresses": {
"NXT": "NXT-XXXX-XXXX-XXXX-XXXXX",
"BTC": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
},
"publick_key": {
"NXT": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"BTC": ""
},
"Assets portfolio": {
"portfolio_price": 0,
"frozen_portfolio_price": 0,
"count": 1,
"assets": [
{
"wallets_adress": "NXT-XXXX-XXXX-XXXX-XXXXX",
"publick_key":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"funds":"100"
}
]
},
"open_orders": 0,
"server_time": 1463346756
}
}

1.2 Active orders


Get information about active orders. Return an overview of:
1.​ ​order id (order id in database)
2.​ ​pair (currency pair contained in order record)
3.​ ​type (order type: buy or sell)
4.​ ​amount (the amount that remains to implement)
5.​ ​rate (order price)
6.​ ​order indicate (indicates that your order or not)
7.​ ​timestamp (order creation time)

endpoint:​ ​ActiveOrders
method:​ ​POST
params:
● pair: string to select an entry order currency pairs (optional, default: "ALL")
● from: an integer value that represent number of records to be skipped before output
(optional)
● count: an integer value that represents the number of records that you want to
display (optional, max: 50, default: 50)
● from_id: an integer value which represent ​order_id​, from which the output begins
(optional)
● end_id: an integer value that represents ​order_id​ after which the output ends
(optional)
● order: string to select the sort type (optional, default: "DESC")
● since: UNIX timestamp that represents the time after which the output begins
(optional)
● ​end: UNIX timestamp that represents the time after which the output ends (optional)

● type: string to select the order type (optional, default: "ALL")


● ​owner: string to select the order owner (optional, default: "OWN")

The parameter pair can be "ALL", "BTC_NXT", "BTC_ETH" or any other pair that available
right now. You can see the list of all available pairs calling public​ method ​markets

The parameter order can be one of "ASC" or "DESC". Please note that all orders are sorted
by ID.
Note, if you use parameters since or end parameter order will be set to "ASC".

The parameter type can be one of "BUY", "SELL", "ALL".

The parameter owner can be one of "ALL" or "OWN".

Method errors and their descriptions:


1.​ ​Invalid Currency Pair​ - one of the currencies is empty or contains invalid characters
or currency pair is not available
2.​ ​Invalid Currency Code​ - currency code is not present in the list of available
3.​ ​Invalid From: not a positive number​ – parameter from is not a positive number
4.​ ​Invalid Count: not a positive number​ – parameter count is not a positive number
5.​ ​Invalid From ID: not a positive number​ – parameter from_id is not a positive
number
6.​ ​Invalid End ID: not a positive number​ – parameter end_id is not a positive number
7.​ ​Invalid Since: not a UNIX timestamp​ – parameter since is not a valid UNIX
timestamp
8.​ ​Invalid End: not a UNIX timestamp​ – parameter end is not a valid UNIX timestamp
9.​ ​Invalid Type​ - parameter type is not equal to one of the available
10.​ ​Invalid Owner​ - parameter owner is not equal to one of the available

Example:
$client->active_orders()

Result:
{
"​success​": ​1,
"data": {
"5303351":{
"pair":"BTC_NXT",
"type":"buy",
"amount":"0.1",
"rate":"5321.1",
"is_your_order":0,
"timestamp":1464352941
},
"5303391":{
"pair":"BTC_ETH",
"type":"buy",
"amount":"0.3",
"rate":"5322.2",
"is_your_order":0,
"timestamp":1464352978
}
}
}

1.3 Trade
Create orders for the purchase and sale. Return an overview of:
1.​ ​funds (your wallet balance after operation)
2.​ ​order_id (created order id)

endpoint:​ ​Trade
method:​ ​POST
params:
● type: string to select the operation type
● pair: string to select the operation currency pair
● ​amount: a positive float value which represent the amount that you want to buy or
sell
● rate: a positive float value which represent the order course

The parameter type can be one of "BUY" or "SELL".

The parameter pair can be "BTC_NXT", "BTC_ETH" or any other pair that available right
now. You can see the list of all available pairs calling public​ method ​markets

Method errors and their descriptions:


1.​ ​Invalid Currency Pair​ – one of the currencies is empty or contains invalid characters
or currency pair is not available
2.​ ​Invalid Type​ – parameter type is not equal to one of the available
3.​ ​Invalid Currency Code​ – currency code is not present in the list of available
4.​ ​Selected Pair is disabled​ – operations for this pair are currently closed
5.​ ​The amount field is required.​ – parameter amount is required
6.​ ​The rate field is required.​ – parameter rate is required
7.​ ​The amount must be a number.​ – parameter amount is not a positive number
8.​ ​The rate must be a number.​ – parameter rate is not a positive number
9.​ ​Not Enough <<currency_code>>​ – there is not enough money in this currency
10.​ ​Minimum Order Amount is <<min_amount>>​ ​<<currency_code>>​ – parameter
amount is less than the ​Minimum Order Amount

Example:
​$client->trade("BTC_NXT", "BUY", 5000, 1)

Result:
{
"success":1,
"data": {
"funds":{
"UAH": "4680.84",
"BTC": "254.7",
"NXT": "0"
},
"order_id":​ ​5616820
}
}

1.4. Cancel Order


Cancel selected order. Return an overview of:
1.​ ​order_id (canceled order id)
2.​ ​funds (your wallet balance after operation)
endpoint:​ ​CancelOrder
method:​ ​POST
params:
● order_id: an integer value which represent canceled ​order_id

Method errors and their descriptions:


1.​ ​Invalid Order ID​ – an error occurs in the following cases: if the parameter is not a
numeric value, the parameter is not included, order is not yours or order is closed
2.​ ​Order Pair is disabled​ – operations for this currency pair are currently closed
3.​ ​Order Processed ​– order is in processing

Example:
$client->cancel_order(<<order_id>>)

Result:
{
"success":1,
"data": {
"funds":{
"UAH": "9680.84",
"BTC": "254.7",
"NXT": "0"
},
"order_id":5616820
}
}

1.5 Trade History


Get information about all closed orders. Return an overview of:
1.​ ​order id (order id in database)
2.​ ​pair (currency pair contained in order record)
3.​ ​type (order type: buy or sell)
4.​ ​amount (the amount that remains to implement)
5.​ ​rate (order price)
6.​ ​order indicate (indicates that your order or not)
7.​ ​timestamp (order creation time)
8. fee (order operation fee)
9. currency_fee (currency fee code)

endpoint:​ ​TradeHistory
method:​ ​POST
params:
● pair: string to select an entry order currency pairs (optional, default: "ALL")
● from: an integer value that represent number of records to be skipped before output
(optional)
● count: an integer value that represents the number of records that you want to
display (optional, max: 50, default: 50)
● ​from_id: an integer value which represent ​order_id​, from which the output begins
(optional)
● end_id: an integer value that represents ​order_id​ after which the output ends
(optional)
● order: string to select the sort type (optional, default: "DESC")
● since: UNIX timestamp that represents the time after which the output begins
(optional)
● end: UNIX timestamp that represents the time after which the output ends (optional)
● status: an integer value which represent ​order_status_id​ (optional, default: 3)
● owner: string to select the order owner (optional, default: "OWN")

The parameter pair can be "ALL", "BTC_NXT", "BTC_ETH" or any other pair that available
right now. You can see the list of all available pairs calling public​ method ​markets

The parameter order can be one of "ASC" or "DESC". Please note that all orders are sorted
by ID.
The parameter owner can be one of "ALL" or "OWN".

Note, if you use parameters since or end parameter order will be set to "ASC".

The parameter status can be one of: 1,2,3,4. Here is the list with order status IDs and their
descriptions:
PENDING – 1
PROCESSING – 2
FINISHED – 3
CANCELED – 4

Method errors and their descriptions:


1.​ ​Invalid Currency Pair​ - one of the currencies is empty or contains invalid characters
or currency pair is not available
2.​ ​Invalid Currency Code​ - currency code is not present in the list of available
3.​ ​Invalid From: not a positive number​ – parameter from is not a positive number
4.​ ​Invalid Count: not a positive number​ – parameter count is not a positive number
5.​ ​Invalid From ID: not a positive number​ – parameter from_id is not a positive
number
6.​ ​Invalid End ID: not a positive number​ – parameter end_id is not a positive number
7.​ ​Invalid Since: not a UNIX timestamp​ – parameter since is not a valid UNIX
timestamp
8.​ ​Invalid End: not a UNIX timestamp​ – parameter end is not a valid UNIX timestamp
9.​ ​Invalid Status: not a positive number ​- parameter status is not a positive number
Invalid Owner​ - parameter owner is not equal to one of the available

Example:
$client->trade_history()

Result:
{
"success":1,
"data":{
"5303353":{
"pair":"BTC_NXT",
"type":"buy",
"amount":"0.3",
"rate":"5352",
"is_your_order":0,
"timestamp":1464352943
},
"5303346":{
"pair":"BTC_ETH",
"type":"sell",
"amount":"0.3",
"rate":"5343",
"is_your_order":1,
"timestamp":1464352943
}
}
}

1.6 Trans History


Get information about your deposits and withdrawals. Return a list of:
1.​ ​Deposit
1.1.​ ​ID (deposit id in database)
1.2.​ ​currency (deposit currency)
1.3.​ ​amount (deposit amount)
1.4.​ ​deposit fee (operational fee ​<<currency_code>>)​
1.5.​ ​TX_ID (deposit transaction id)
1.6.​ ​status (current deposit status)
1.7.​ ​date (operation time)
2.​ ​Withdrawal
2.1.​ ​ID (withdrawal id in database)
2.2.​ ​currency (withdrawal currency)
2.3.​ ​amount (withdrawal amount)
2.4.​ ​withdrawal fee (operational fee ​<<currency_code>>​)
2.5.​ ​address (the address that will receive the payment)
2.6.​ ​TX_ID (withdrawal transaction id)
2.7.​ ​status (current withdrawal status)
2.8.​ ​date (operation time)
endpoint:​ ​TransHistory
method:​ ​POST
params:
● currency: string to select an entry deposit or withdrawal currency (optional, default:
"ALL")
● from: an integer value that represent number of records to be skipped before output
(optional)
● count: an integer value that represents the number of records that you want to
display (optional, max: 50, default: 50)
● from_id: an integer value which represent deposit or withdrawal id, from which the
output begins (optional)
● end_id: an integer value that represents deposit or withdrawal id after which the
output ends (optional)
● order: string to select the sort type (optional, default: "DESC")
● since: UNIX timestamp that represents the time after which the output begins
(optional)
● end: UNIX timestamp that represents the time after which the output ends (optional)
● ​operation: string to select the operation type (optional, default: "ALL")

● status: an integer value which represent deposit or withdrawal status (optional,


default: "FINISHED")

The parameter currency can be "ALL", "BTC ", "NXT " or any other currency that available
right now. You can see the list of all available currencies calling​ ​public​ method ​currencies

The parameter order can be one of "ASC" or "DESC". Please note that all orders are sorted
by ID.
Note, if you use parameters since or end parameter order will be set to "ASC".

The parameter operation can be one of "ALL", "DEPOSIT" or "WITHDRAWAL".

The parameter status can be one of:


For deposit:
1.​ ​FINISHED
2.​ ​AWAITING_CONFIRMATIONS
For withdrawal:
1.​ ​EMAIL_SENT
2.​ ​CANCELED_BY_USER
3.​ ​AWAITING_APPROVAL
4.​ ​APPROVED
5.​ ​PROCESSING
6.​ ​WITHDRAWAL_ERROR
7.​ ​CANCELED_BY_ADMIN
8.​ ​FINISHED
If parameter operation is set to "ALL" parameter status will be set to " FINISHED".

Method errors and their descriptions:


1.​ ​Invalid Currency Code​ - currency code is not present in the list of available
2.​ ​Invalid From: not a positive number​ – parameter from is not a positive number

3.​ ​Invalid Count: not a positive number​ – parameter count is not a positive number

4.​ ​Invalid From ID: not a positive number​ – parameter from_id is not a positive

number
5.​ ​Invalid End ID: not a positive number​ – parameter end_id is not a positive number
6.​ ​Invalid Since: not a UNIX timestamp​ – parameter since is not a valid UNIX
timestamp
7.​ ​Invalid End: not a UNIX timestamp​ – parameter end is not a valid UNIX timestamp

Example:
$client->trans_history()

Result:
{
"success":1,
"data":{
"DEPOSIT":{
"113":{
"Currency":"NXT",
"Amount":"11",
"Deposit_fee":"2NXT",
"TX_id":"17388534115659312996",
"Status":"Finished",
"Date":1461361743
},
"112":{
"Currency":"NXT",
"Amount":"10",
"Deposit_fee":"2NXT",
"TX_id":"4992090663590407388",
"Status":"Finished",
"Date":1461360604
}
},
"WITHDRAWAL":{
"15":{
"Currency":"NXT",
"Amount":"12",
"Withdrawal_Fee":"1NXT",
"Address":"NXT-QLF8-K5L8-VPRE-CYVAX",
"TX_id":"1748174097384839713",
"Status":"FINISHED",
"Date":1461363498
}
}
}
}

1.7 Grafic
Get information about trade statistic. Return an overview of:
1.​ ​orders currency pair
2.​ ​start date (period start date)
3.​ ​end date (period end date)
4.​ ​count of page for static info in this period
5.​ ​current page
6.​ ​count of points per page
7.​ ​an array with static records named graf
·​ ​the price of the first order in the current period

·​ ​the price of the last order in the current period

·​ ​the maximum price of the order in the current period

·​ ​the minimum price of the order in the current period

endpoint:​ ​Grafic
method:​ ​POST
params:
● pair: string to select an entry currency pairs (default: "ALL")
● order: string to select the sort type (optional, default: "DESC")
● since: UNIX timestamp that represents the time from which the output begins
(optional, default: the beginning of the month)
● end: UNIX timestamp that represents the time after which the output ends (optional,
default: current time)
● ​page: an integer value that represent the current page (optional, default: 1)
● count: an integer value that represents the number of records that you want to
display per page (optional, max: 100, default: 50)
● interval: string that represent time interval by which values are grouped (optional,
default: "1D")

The parameter pair can be "BTC_NXT", "BTC_ETH" or any other pair that available right
now. You can see the list of all available pairs calling​ ​public​ method ​markets

The parameter order can be one of "ASC" or "DESC". Please note that all orders are sorted
by ID.
Note, if you use parameters since or end parameter order will be set to "ASC".
The parameter interval can be one of "1D", "1M" , "3M", "1Y".
Here is a description for each interval parameter values:
1D – day
1M – month
3M – 3 month
1Y – year
The parameter c​ ount​ can be one of "10", "25" , "50", "100".

Method errors and their descriptions:


1.​ ​Invalid Currency Pair​ - one of the currencies is empty or contains invalid
characters or currency pair is not available
2.​ ​Invalid Currency Code​ - currency code is not present in the list of available
3.​ ​Selected Pair is disabled​ – operations for this pair are currently closed
4.​ ​Invalid Since: not a UNIX timestamp​ – parameter since is not a valid UNIX
timestamp
5.​ ​Invalid End: not a UNIX timestamp​ – parameter end is not a valid UNIX
timestamp
6.​ ​Invalid Page: not a positive number​ – parameter page is not a positive
number
7.​ ​Invalid Count​ – parameter count is not present in the list of available

Example:
$client->grafic("BTC_ETH")

Result:
{
"success":1,
"data":{
"pair":"BTC_ETH",
"since":"2016-05-01 00:00:00",
"end":"2016-07-01 00:01:15",
"count_pages":3,
"count":"2",
"current_page":1,
"graf":[
{
"open":"5350.50000000",
"close":"5358.70000000",
"low":"5320.90000000",
"high":"5361.00000000",
"date":"2016-05-02 00:00:00"
},
{
"open":"16.00000000",
"close":"16.00000000",
"low":"16.00000000",
"high":"16.00000000",
"date":"2016-05-03 00:00:00"
}
]
}
}

1.8 Deposit
Get information about your wallet to deposit funds. Return an overview of:
1.​ ​currency (deposit currency code)
2.​ ​address (wallet address)
3.​ ​public key (wallet public key if exist)
3.​ ​payment id (wallet payment id if exist)

endpoint:​ ​Deposit
method:​ ​POST
params:
● currency: string to select an entry deposit currency

The parameter currency can be "BTC ", "NXT " or any other currency that available right
now. You can see the list of all available currencies calling​ ​public​ method ​currencies

Method errors and their descriptions:


1.​ ​Invalid Currency Code​ - currency code is not present in the list of available
2.​ ​Selected currency is disabled​ - operations for this currency are currently
closed
3.​ ​No Wallet​ — can’t find any wallet by selected currency
4.​ ​No Wallet​ ​Address​ — create wallet address for selected currency

Example:
$client->make_deposit(​"NXT")​

Result:
{
"success":1,
"data":{
"currency":"NXT",
"address":"NXT-C59X-SZRV-V36P-62SW3",
"publicKey":" XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
}
}

1.9 Withdraw
Withdraw your funds. Return an overview of:
1.​ ​msg (operation comment)
2.​ ​currency code (withdrawal currency code)
3.​ ​amount (withdrawal amount)
4.​ ​withdrawal fee (withdraw operation fee)
4.​ ​withdrawal fee currency (withdrawal fee currency code)
5.​ ​date (object that consist info about operation date)
6.​ ​address (withdrawal address)
7. Payment id (optional)
endpoint:​ ​Withdraw
method:​ ​POST
params:
● currency: string to select an entry deposit currency
● ​address: string to select the withdrawal address
● amount: a positive float value which represent the amount that you want to withdraw

The parameter currency can be "BTC ", "NXT " or any other currency that available right
now. You can see the list of all available currencies calling​ ​public​ method ​currencies

Method errors and their descriptions:


1.​ ​Invalid Currency Code​ - currency code is not present in the list of available
2.​ ​Selected currency is disabled​ - operations for this currency are currently
closed
3.​ ​Withdrawal is disabled​ – user can not witdraw
4.​ ​You can not withdraw money until <<hold_period>>​ – You cann't
withdraw money until min period is not pass
5.​ ​The address field is required.​ – parameter address is required
6.​ ​The amount field is required.​ – parameter amount is required
7.​ ​The amount must be a number.​ – parameter amount is not a positive
number
8.​ ​"Address": The attribute must contain only letters and numbers
9.​ ​You do not have enough <<currency_code>>​ – no enough funds on your
balance
10.​ ​Minimum withdrawal amount is <<min_withdraw_amount>>
<<currency_code>>​ – amount rezer than Minimum withdrawal amount
11.​ ​Wrong address​ – wrong address format for NXT and Asset withdraw
12.​ ​You do not have enough <<currency_code>> on your
<<currency_code>> balance to pay withdrawals fee​ – for asset withdraw
you must have some funds on your balance to pay withdraw fee

Example:
$client->make_withdraw("NXT", "NXT-C59X-SZRV-V36P-62SW3", 5)

Result:
{
"success":1,
"data":{
"code":"NXT",
"id":17,
"amount":"9",
"address":"NXT-C59X-SZRV-V36P-62SW3",
"withdrawal_fee":"1",
"withdrawal_fee_currency":"NXT",
"token":"jTJDhfAok4AbEW0rdLKqMDagKsOOLRe1yTlQsUqLoXIgDyiwEimbWXiJ7",
"date":{
"date":"2016-07-06 14:06:21.000000",
"timezone_type":3,
"timezone":"UTC"
},
"msg":" Message with confirmation sent to your email address"
}
}
1.10 Generate Wallets
Generate currency wallet address. Return an overview of:
1.​ ​msg (operation comment)
2.​ ​code (currency code)
3.​ ​address (created address)
4.​ ​public key (if need)
5. Payment id (if need)
endpoint:​ ​GenerateWallets
method:​ ​POST
params:
·​ ​currency: string to select an entry wallet currency

The parameter currency can be "BTC ", "NXT " or any other currency that available right
now. You can see the list of all available currencies calling​ ​public​ method ​currencies

Method errors and their descriptions:


1.​ ​Invalid Currency Code​ - currency code is not present in the list of available
2.​ ​Selected Currency is disabled​ - operations for this currency are currently
closed
3.​ ​Already have an wallet address​ - you already have an wallet address, so
you need to use it before creating a new one
4.​ ​Creation address for <<currency_code>>​ ​failed​ – an error when create a
wallet address

Example:
$client->generate_wallets()

Result:
{
"success":1,
"data":{
"msg":"Address generated",
"code":"BTC",
"address":"1GgcGVRfxY8C5WXAkzt1qxKTi66HKzgyRL"
}
}

1.11​ Ticket
Create ticket. Return an overview of:
1.​ ​msg (operation comment)
2.​ ​ticket id (ticket id in database)
3.​ ​subject
4.​ ​ticket category id (category id for tickets in database)
5.​ ​ticket status id (status id for tickets in database)
6.​ ​ticket message (text message of ticket)
endpoint:​ ​Ticket
method:​ ​POST
params:
● category: an integer value which represent ticket_category_id
● subject: string
● message: string

The parameter ​category​ can be one of:


1.​ ​Order Problem
2.​ ​Deposit Problem
3.​ ​Withdrawal Problem
4.​ ​Dividend Problem
5.​ ​Other

The value of ​status​ can be one of:


1.​ ​Awaiting Support Response
2.​ ​Awaiting Customer Response
3.​ ​Closed

Method errors and their descriptions:


1.​ ​The ticket category id field is required​ – parameter category is required
2.​ ​The subject field is required​ - parameter subject is required
3.​ ​The message field is required​ - parameter message is required

Example:
$client->create_tickets()

Result:
{
"success":1,
"data":{
"msg":"Ticket created",
"ticket_id":"3",
"subject":"Cann’t get deposit",
"ticket_category_id":"2",
"ticket_status_id":"1",
"message":"Cann’t get deposit to my ETH wallet"
}
}

1.1​2 Get Tickets


Get tickets. Return an overview of:
1.​ ​ticket id (ticket id in database)
2.​ ​ticket category id (category id for tickets in database)
3.​ ​ticket status id (status id for tickets in database)
4.​ ​ticket message
4.1.​ ​text (text message of ticket)
4.2.​ ​date (date of created messages)
endpoint:​ ​GetTickets
method:​ ​POST
params:
● ticket id: an integer value which represent ticket_id
● category: an integer value which represent ticket_category_id
● status: an integer value which represent ticket_status_id

All parameters can be empty.


The parameter ​category​ can be one of:
1.​ ​Order Problem
2.​ ​Deposit Problem
3.​ ​Withdrawal Problem
4.​ ​Dividend Problem
5.​ ​Other
The parameter of ​status​ can be one of:
1.​ ​Awaiting Support Response
2.​ ​Awaiting Customer Response
3.​ ​Closed

Method errors and their descriptions:


1.​ ​Invalid Ticket id​ – parameter ticket is not a positive number

Example:
$client->get_tickets()

Result:

{"success":1,
"data":{
"3":{
"ticket_id":3,
"ticket_category_id":2,
"ticket_status_id":1,
"ticket_messages":{
"4":{"text":"Cann't get deposit to my ETH wallet",
"date":{"date":"2017-03-14
10:04:32.000000","timezone_type":3,"timezone":"UTC"}
}
}
},
"2":{
"ticket_id":2,
"ticket_category_id":5,
"ticket_status_id":1,
"ticket_messages":{
"3":{"text":"pizza",
"date":{"date":"2017-03-14
08:59:35.000000","timezone_type":3,"timezone":"UTC"}
}
}
}
}

1.1​3 Reply Ticket


Reply ticket. Return an overview of:
1.​ ​msg (operation comment)
2.​ ​ticket message id (ticket message id in database)

endpoint: ​ReplyTicket
method:​ ​POST
params:
● ticket id: an integer value which represent ticket_id
● message: string

Method errors and their descriptions:


1.​ ​Invalid Ticket id – parameter ticket is not a positive number
2.​ ​Ticket is closed​ – ticket with id have status closed
3.​ ​Ticket dosn’t exist​ – ticket with id does not exist
4.​ ​The message field is required​ - parameter message is required

Example:
$client->reply_tickets()

Result:
{
"success":1,
"data":{
"msg":"Ticket reply created",
"ticket_massage_id":"6"
}
}
2. Public API
1.1 Currencies
Get all available currencies with additional info. Return an overview of:
1.​ ​currency (currency code)
2.​ ​active (active currency or not active)
3.​ ​precision
4.​ ​api precision
5.​ ​minimum withdrawal amount
6.​ ​minimum deposit amount
9.​ ​deposit fee currency
10.​ ​deposit fee const
11.​ ​deposit fee percent
12.​ ​withdrawal fee currency
13.​ ​withdrawal fee const
14.​ ​withdrawal fee percent
15.​ ​currency long (currency long name)
base url:​ ​https://stocks.exchange/api2/currencies
method:​ ​GET

Example:
$client->currencies()

Result:
[
{
"currency":"BTC",
"active":true,
"precision":8,
"api_precision":8,
"minimum_withdrawal_amount":"0.01000000",
"minimum_deposit_amount":"0.01000000",
"calculated_balance":"0",
"deposit_fee_currency":"BTC",
"deposit_fee_const":0,
"deposit_fee_percent":0,
"withdrawal_fee_currency":"BTC",
"withdrawal_fee_const":0,
"withdrawal_fee_percent":"0.50000000",
"currency_long":"Bitcoin"
},
{
"currency":"NXT",
"active":true,
"precision":3,
"api_precision":8,
"minimum_withdrawal_amount":"5.00000000",
"minimum_deposit_amount":"5.00000000",
"calculated_balance":"10",
"deposit_fee_currency":"NXT",
"deposit_fee_const":"1.00000000",
"deposit_fee_percent":0,
"withdrawal_fee_currency":"NXT",
"withdrawal_fee_const":"1.00000000",
"withdrawal_fee_percent":0,
"currency_long":"Next"
}
]

1.2 Markets
Get all available currency pairs with additional info. Return an overview of:
1.​ ​currency (currency code)
2.​ ​partner (partner currency code)
3.​ ​currency long (currency long name)
4.​ ​partner long (partner currency long name)
5.​ ​min order amount (minimum order amount)
6.​ ​min buy price (minimum buy price)
7.​ ​min sell price (minimum sell price)
9.​ ​buy fee percent (fee by percent for buying)
10.​ ​sell fee percent (fee by percent for selling)
11.​ ​active (active market or not active)
12.​ ​currency precision
13.​ ​partner precision (partner currency precision)
14.​ ​market name

base url:​ ​https://stocks.exchange/api2/markets


method:​ ​GET

Example:
$client->markets()

Result:
[
{
"currency":"BTC",
"partner":"USD",
"currency_long":"Bitcoin",
"partner_long":"USD",
"min_order_amount":1.000000,
"min_buy_price":0,
"min_sell_price":0,
"buy_fee_percent":0.002,
"sell_fee_percent":0.002,
"active":false,
"currency_precision":8,
"partne_precision":3,
"market_name":"BTC_USD"
},
{
"currency":"BTC",
"partner":"NXT",
"currency_long":"Bitcoin",
"partner_long":"Next",
"min_order_amount":1.000000,
"min_buy_price":0,
"min_sell_price":0,
"buy_fee_percent":0.002,
"sell_fee_percent":0.002,
"active":true,
"currency_precision":8,
"partne_precision":8,
"market_name":"BTC_NXT"}
}
]

1.3 Market summary


Get currency pair with additional info. Return an overview of:
1.​ ​currency (currency code)
2.​ ​partner (partner currency code)
3.​ ​currency long (currency long name)
4.​ ​partner long (partner currency long name)
5.​ ​min order amount (minimum order amount)
6.​ ​min buy price (minimum buy price)
7.​ ​min sell price (minimum sell price)
9.​ ​buy fee percent (fee by percent for buying)
10.​ ​sell fee percent (fee by percent for selling)
11.​ ​active (active market or not active)
12.​ ​currency precision
13.​ ​partner precision (partner currency precision)
14.​ m
​ arket name

base url:​ ​https://stocks.exchange/api2/market_summary/{currency1}/{currency2}


method:​ ​GET
● currency1: string to select first currency
● currency2: string to select second currency
The parameters currency1 and currency2 can be "BTC ", "NXT " or any other currency that
available right now. You can see the list of all available currencies calling public​ method
currencies

Method errors and their descriptions:


1.​ ​Invalid Currency Code​ – currency code is not present in the list of available
2.​ ​Invalid Currency Pair ​– currency pair is not present in the list of available

Example:
$client->market_summary(<<currency1>>, <<currency2>>)

Result:
[
{
"currency":"BTC",
"partner":"USD",
"currency_long":"Bitcoin",
"partner_long":"USD",
"min_order_amount":1.000000,
"min_buy_price":0,
"min_sell_price":0,
"buy_fee_percent":0.002,
"sell_fee_percent":0.002,
"active":false,
"currency_precision":8,
"partne_precision":3,
"market_name":"BTC_USD"
}
]
1.4 Ticker
Use it to get the recommended retail exchange rates for all currency pairs. Return an
overview of:
1.​ ​min order amount
2.​ ​ask (highest buy)
3.​ ​bid (lowest sell)
4.​ ​last
5.​ ​last day ago
6.​ ​volume 24 h
7.​ ​spread
8.​ ​buy fee percent (fee by percent for buying)
9.​ ​sell fee percent (fee by percent for selling)
10.​ ​market name
11.​ ​updated time
12.​ ​server time

base url:​ ​https://stocks.exchange/api2/ticker


method:​ ​GET

Example:
$client->ticker()

Result:
[
{
"min_order_amount":"0.00000000",
"ask":0,
"bid":0,
"last":"10.00000000",
"lastDayAgo":1,
"vol":15,
"spread":-0.02,
"buy_fee_percent":"0",
"sell_fee_percent":"0",
"market_name":"BTC_ETH",
"updated_time":1470865580,
"Server_time":1470865580}
}
]
1.5 Prices
Use it to get the new retail exchange rates for all currency pairs. Return an overview of:
1.​ ​buy (highest buy)
2.​ ​sell (lowest sell)
3.​ ​market name
4.​ ​updated time
5.​ ​server time

base url:​ ​https://stocks.exchange/api2/prices


method:​ ​GET

Example:
$client->prices()

Result:
[
{
"buy":"0.00003000",
"sell":"0.00400000",
"market_name":"BTC_ETH",
"updated_time":1470865580,
"Server_time":1470865580}
}
]