Beruflich Dokumente
Kultur Dokumente
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']);
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
}
}
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)
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".
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 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
Example:
$client->trade("BTC_NXT", "BUY", 5000, 1)
Result:
{
"success":1,
"data": {
"funds":{
"UAH": "4680.84",
"BTC": "254.7",
"NXT": "0"
},
"order_id": 5616820
}
}
Example:
$client->cancel_order(<<order_id>>)
Result:
{
"success":1,
"data": {
"funds":{
"UAH": "9680.84",
"BTC": "254.7",
"NXT": "0"
},
"order_id":5616820
}
}
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
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
}
}
}
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".
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
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".
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
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
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
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
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"
}
}
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"}
}
}
}
}
endpoint: ReplyTicket
method: POST
params:
● ticket id: an integer value which represent ticket_id
● message: string
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
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"}
}
]
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
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
Example:
$client->prices()
Result:
[
{
"buy":"0.00003000",
"sell":"0.00400000",
"market_name":"BTC_ETH",
"updated_time":1470865580,
"Server_time":1470865580}
}
]