Initial commit
This commit is contained in:
137
docs/api/authenticating_in_management_api_v1.md
Normal file
137
docs/api/authenticating_in_management_api_v1.md
Normal file
@@ -0,0 +1,137 @@
|
||||
# Authenticating in Management API v1
|
||||
|
||||
## Step 1: Generate keypair.
|
||||
|
||||
`ruby -e "require 'openssl'; require 'base64'; OpenSSL::PKey::RSA.generate(2048).tap { |p| puts '', 'PRIVATE RSA KEY (URL-safe Base64 encoded, PEM):', '', Base64.urlsafe_encode64(p.to_pem), '', 'PUBLIC RSA KEY (URL-safe Base64 encoded, PEM):', '', Base64.urlsafe_encode64(p.public_key.to_pem) }"`
|
||||
|
||||
## Step 2: Include public key in the `config/management_api_v1.yml` at Peatio.
|
||||
|
||||
You should give the ID to the key and put it in variable called `keychain`.
|
||||
|
||||
The variable `keychain` in `config/management_api_v1.yml` should look like:
|
||||
|
||||
```yml
|
||||
keychain:
|
||||
backend-1.mycompany.example:
|
||||
algorithm: RS256
|
||||
value: 'BACKEND_1_PUBLIC_KEY_IN_PEM_FORMAT_BASE64_URLSAFE_ENCODED'
|
||||
backend-2.mycompany.example:
|
||||
algorithm: RS256
|
||||
value: 'BACKEND_2_PUBLIC_KEY_IN_PEM_FORMAT_BASE64_URLSAFE_ENCODED'
|
||||
```
|
||||
|
||||
The `value` is public key from URL-safe Base64 encoded PEM from the first step.
|
||||
The `algorithm` is signature algorithm you prefer.
|
||||
|
||||
## Step 3: Configure JWT claims.
|
||||
|
||||
You can customize JWT verification options using variable `jwt` in `config/management_api_v1.yml`:
|
||||
|
||||
```yml
|
||||
jwt:
|
||||
verify_jti: true
|
||||
verify_aud: true
|
||||
exp_leeway: 180
|
||||
```
|
||||
|
||||
The documentation is available at [jwt repository](https://github.com/jwt/ruby-jwt#support-for-reserved-claim-names).
|
||||
|
||||
## Step 4: Configure security scopes.
|
||||
|
||||
The `config/management_api_v1.yml` already includes good docs for this step. You can find it at the bottom near variable `scopes`.
|
||||
|
||||
## Step 5: Configure JWT provider and deliver private key.
|
||||
|
||||
The JWT provider can use Ruby Gem `jwt-multisig` for generating JWT with multiple signatures.
|
||||
|
||||
You should store private keys (ID, value, algorithm) somewhere in your application.
|
||||
|
||||
To generate JWS use the `JWT::Multisig.generate_jwt(payload, private_keychain, algorithms)`.
|
||||
|
||||
In `private_keychain` you need to put private key from URL-safe Base64 encoded PEM from the first step.
|
||||
|
||||
The output from this example with serialized JWT will be save in data.json.
|
||||
|
||||
Example:
|
||||
|
||||
```ruby
|
||||
require 'openssl'
|
||||
require 'jwt-multisig'
|
||||
require 'base64'
|
||||
require 'json'
|
||||
|
||||
payload = {
|
||||
exp: 1922830281, # Put here all the JWT claims.
|
||||
data: { foo: 'bar', baz: 'qux' } # Put here all the data your API action expects.
|
||||
}
|
||||
|
||||
# You can choose what signatures the JWT should include.
|
||||
private_keychain = {
|
||||
:'backend-1.mycompany.example' => OpenSSL::PKey.read(Base64.urlsafe_decode64('BACKEND_1_PRIVATE_KEY_IN_PEM_FORMAT_BASE64_URLSAFE_ENCODED')),
|
||||
:'backend-2.mycompany.example' => OpenSSL::PKey.read(Base64.urlsafe_decode64('BACKEND_2_PRIVATE_KEY_IN_PEM_FORMAT_BASE64_URLSAFE_ENCODED'))
|
||||
}
|
||||
|
||||
algorithms = {
|
||||
:'backend-1.mycompany.example' => 'RS256',
|
||||
:'backend-2.mycompany.example' => 'RS256'
|
||||
}
|
||||
|
||||
jwt = JWT::Multisig.generate_jwt(payload, private_keychain, algorithms)
|
||||
|
||||
Kernel.puts JSON.dump(jwt) # The output will include serialized JWT.
|
||||
|
||||
# Save your JWT in data.json
|
||||
File.open('./data.json','w') do |f|
|
||||
f.write(jwt.to_json)
|
||||
end
|
||||
```
|
||||
|
||||
The documentation for this method is available at [rubydoc.info](http://www.rubydoc.info/gems/jwt-multisig/JWT/Multisig#generate_jwt-class_method).
|
||||
The source code for `jwt-multisig` is available at [GitHub](https://github.com/rubykube/jwt-multisig).
|
||||
The example JWT is available at [jwt-multisig source code](https://github.com/rubykube/jwt-multisig/blob/master/lib/jwt-multisig.rb#L25).
|
||||
|
||||
## Step 6: Make requests to API.
|
||||
|
||||
With next example you can make request with ruby Faraday client library or make request with curl. This request will return empty array if you don't have any deposits on the platform.
|
||||
|
||||
Example:
|
||||
|
||||
```ruby
|
||||
require 'json'
|
||||
require 'faraday'
|
||||
require 'faraday_middleware'
|
||||
|
||||
# Read and save your JWT from data.json
|
||||
data = File.read('./data.json')
|
||||
|
||||
# Create HTTP request with ruby Faraday client library
|
||||
module Faraday
|
||||
class Connection
|
||||
alias original_run_request run_request
|
||||
def run_request(method, url, body, headers, &block)
|
||||
original_run_request(method, url, body, headers, &block).tap do |response|
|
||||
response.env.instance_variable_set :@request_body, body if body
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def http_client
|
||||
Faraday.new(url: @root_api_url) do |conn|
|
||||
conn.request :json
|
||||
conn.response :json
|
||||
conn.adapter Faraday.default_adapter
|
||||
end
|
||||
end
|
||||
|
||||
# The output will include request response
|
||||
Kernel.puts http_client
|
||||
.public_send(:post,'http://localhost:3000/management_api/v1/deposits', data)
|
||||
.body
|
||||
```
|
||||
|
||||
Make request with curl.
|
||||
|
||||
```
|
||||
curl -v -H "Accept: application/json" -H "Content-Type: application/json" -d @jwt.json http://localhost:3000/management_api/v1/deposits
|
||||
```
|
||||
114
docs/api/errors.md
Normal file
114
docs/api/errors.md
Normal file
@@ -0,0 +1,114 @@
|
||||
# Peatio Member API Errors
|
||||
|
||||
## Shared errors
|
||||
|
||||
| Code | Description |
|
||||
| ----------------------- | ----------------------------------- |
|
||||
| `jwt.decode_and_verify` | Impossible to decode and verify JWT |
|
||||
| `record.not_found` | Record Not found |
|
||||
| `server.internal_error` | Internal Server Error |
|
||||
|
||||
## Account module
|
||||
|
||||
| Code | Description |
|
||||
| --------------------------------------- | ---------------------------------------------- |
|
||||
| `account.currency.doesnt_exist` | **Currency** doesn't exist in database |
|
||||
| `account.balance.missing_currency` | Parameter **currency** is missing |
|
||||
| `account.deposit.missing_currency` | Parameter **currency** is missing |
|
||||
| `account.deposit.invalid_state` | Deposit **state** is not valid |
|
||||
| `account.deposit.non_integer_limit` | Parameter **limit** should be integer |
|
||||
| `account.deposit.invalid_limit` | Parameter **limit** is not valid |
|
||||
| `account.deposit.non_positive_page` | Parameter **page** should be positive number |
|
||||
| `account.deposit.empty_txid` | Parameter **txid** is empty |
|
||||
| `account.withdraw.missing_txid` | Parameter **txid** is missing |
|
||||
| `account.deposit.not_permitted` | Pass the corresponding verification steps to **deposit funds** |
|
||||
| `account.withdraw.non_integer_limit` | Parameter **limit** should be integer |
|
||||
| `account.withdraw.invalid_limit` | Parameter **limit** is not valid |
|
||||
| `account.withdraw.non_positive_page` | Parameter **page** should be positive number |
|
||||
| `account.withdraw.non_integer_otp` | Parameter **otp** should be integer |
|
||||
| `account.withdraw.empty_otp` | Parameter **otp** is empty |
|
||||
| `account.withdraw.missing_otp` | Parameter **otp** is missing |
|
||||
| `account.withdraw.missing_rid` | Parameter **rid** is missing |
|
||||
| `account.withdraw.missing_amount` | Parameter **amount** is missing |
|
||||
| `account.withdraw.missing_currency` | Parameter **currency** is missing |
|
||||
| `account.withdraw.empty_rid` | Parameter **rid** is empty |
|
||||
| `account.withdraw.non_decimal_amount` | Parameter **amount** should be decimal |
|
||||
| `account.withdraw.non_positive_amount` | Parameter **amount** should be positive number |
|
||||
| `account.withdraw.insufficient_balance` | Account **balance** is insufficient |
|
||||
| `account.withdraw.invalid_amount` | Parameter **amount** is not valid |
|
||||
| `account.withdraw.create_error` | Failed to create withdraw |
|
||||
| `account.withdraw.invalid_otp` | Parameter **otp** is not valid |
|
||||
| `account.withdraw.disabled_api` | Withdrawal API is disabled |
|
||||
| `account.withdraw.not_permitted` | Pass the corresponding verification steps to **withdraw funds** |
|
||||
| `account.withdraw.too_long_note` | Parameter **note** is too long |
|
||||
| `account.deposit_address.invalid_address_format` | Invalid parameter for deposit address format |
|
||||
| `account.deposit_address.doesnt_support_cash_address_format` | Currency doesn't support cash address format |
|
||||
|
||||
## Market module
|
||||
|
||||
| Code | Description |
|
||||
| -------------------------------------------- | ---------------------------------------------------------------- |
|
||||
| `market.account.insufficient_balance` | Account balance is insufficient |
|
||||
| `market.market.doesnt_exist_or_not_enabled` | **Market** doesn't exist in database or currently disabled/hidden|
|
||||
| `market.order.insufficient_market_liquidity` | Insufficient market liquidity |
|
||||
| `market.order.invalid_volume_or_price` | Order **volume** or **price** is invalid for selected market |
|
||||
| `market.order.create_error` | Failed to create order |
|
||||
| `market.order.cancel_error` | Failed to cancel order |
|
||||
| `market.order.market_order_price` | Market order doesn't have **price** |
|
||||
| `market.order.invalid_state` | Parameter **state** is not valid |
|
||||
| `market.order.invalid_limit` | Parameter **limit** is not valid |
|
||||
| `market.order.non_integer_limit` | Parameter **limit** should be integer |
|
||||
| `market.order.invalid_order_by` | Parameter **order_by** is not valid |
|
||||
| `market.order.invalid_ord_type` | Parameter **ord_type** is not valid |
|
||||
| `market.order.invalid_type` | Parameter **type** is not valid |
|
||||
| `market.order.invalid_side` | Parameter **side** is not valid |
|
||||
| `market.order.missing_market` | Parameter **market** is missing |
|
||||
| `market.order.missing_side` | Parameter **side** is missing |
|
||||
| `market.order.missing_volume` | Parameter **volume** is missing |
|
||||
| `market.order.missing_price` | Parameter **price** is missing |
|
||||
| `market.order.missing_id` | Parameter **id** is missing |
|
||||
| `market.order.non_decimal_volume` | Parameter **volume** should be decimal |
|
||||
| `market.order.non_positive_volume` | Parameter **volume** should be positive number |
|
||||
| `market.order.invalid_type` | Parameter **type** is not valid |
|
||||
| `market.order.non_decimal_price` | Parameter **price** should be decimal |
|
||||
| `market.order.non_positive_price` | Parameter **price** should be positive number |
|
||||
| `market.order.non_integer_id` | Parameter **id** should be integer |
|
||||
| `market.order.empty_id` | Parameter **id** is empty |
|
||||
| `market.trade.non_integer_limit` | Parameter **limit** should be integer |
|
||||
| `market.trade.invalid_limit` | Parameter **limit** is not valid |
|
||||
| `market.trade.empty_page` | Parameter **page** is empty |
|
||||
| `market.trade.non_integer_time_from` | Parameter **time_from** should be integer |
|
||||
| `market.trade.empty_time_from` | Parameter **time_from** is empty |
|
||||
| `market.trade.non_integer_time_to` | Parameter **time_to** should be integer |
|
||||
| `market.trade.empty_time_to_` | Parameter **time_to** is empty |
|
||||
| `market.trade.invalid_order_by` | Parameter **order_by** is not valid |
|
||||
| `market.trade.not_permitted` | Pass the corresponding verification steps to **enable trading** |
|
||||
|
||||
## Public module
|
||||
|
||||
| Code | Description |
|
||||
| ----------------------------------------- | ---------------------------------------------|
|
||||
| `public.currency.doesnt_exist` | **Currency** doesn't exist in database |
|
||||
| `public.currency.invalid_type` | **Currency** type is not valid |
|
||||
| `public.currency.missing_id` | Parameter **id** is missing |
|
||||
| `public.market.missing_market` | Parameter **market** is missing |
|
||||
| `public.market.doesnt_exist` | **Market** doesn't exist in database |
|
||||
| `public.order_book.non_integer_ask_limit` | Parameter **ask_limit** should be integer |
|
||||
| `public.order_book.invalid_ask_limit` | Parameter **ask_limit** is not valid |
|
||||
| `public.order_book.non_integer_bid_limit` | Parameter **bid_limit** should be integer |
|
||||
| `public.order_book.invalid_bid_limit` | Parameter **bid_limit** is not valid |
|
||||
| `public.trade.invalid_limit` | Parameter **limit** is not valid |
|
||||
| `public.trade.non_integer_limit` | Parameter **limit** should be integer |
|
||||
| `public.trade.non_positive_page` | Parameter **page** should be positive number |
|
||||
| `public.trade.non_integer_timestamp` | Parameter **timestamp** should be integer |
|
||||
| `public.trade.invalid_order_by` | Parameter **order_by** is not valid |
|
||||
| `public.market_depth.non_integer_limit` | Parameter **limit** should be integer |
|
||||
| `public.market_depth.invalid_limit` | Parameter **limit** is not valid |
|
||||
| `public.k_line.non_integer_period` | Parameter **period** should be integer |
|
||||
| `public.k_line.invalid_period` | Parameter **period** is not valid |
|
||||
| `public.k_line.non_integer_time_from` | Parameter **time_from** should be integer |
|
||||
| `public.k_line.empty_time_from` | Parameter **time_from** is empty |
|
||||
| `public.k_line.non_integer_time_to` | Parameter **time_to** should be integer |
|
||||
| `public.k_line.empty_time_to` | Parameter **time_to** is empty |
|
||||
| `public.k_line.non_integer_limit` | Parameter **limit** should be integer |
|
||||
| `public.k_line.invalid_limit` | Parameter **limit** is not valid |
|
||||
482
docs/api/event_api.md
Normal file
482
docs/api/event_api.md
Normal file
@@ -0,0 +1,482 @@
|
||||
# RabbitMQ Peatio Event API
|
||||
|
||||
## Overview of RabbitMQ details
|
||||
|
||||
Peatio submits all events into three exchanges depending on event category (read next).
|
||||
|
||||
The exchange name consists of three parts:
|
||||
|
||||
1) application name, like `peatio`, `barong`.
|
||||
|
||||
2) fixed keyword `events`.
|
||||
|
||||
3) category of event, like `system` (generic system event), `model` (the attributes of some record were updated), `market` (trading events).
|
||||
|
||||
The routing key looks like `deposit.updated`, `btcusd.new_order`.
|
||||
The event name matches the routing key but with event category appended at the beginning, like `model.deposit.updated`, `market.btcusd.new_order`.
|
||||
|
||||
## Overview of RabbitMQ message
|
||||
|
||||
Each produced message in `Event API` is JWT (complete format).
|
||||
|
||||
This is very similar to `Management API`.
|
||||
|
||||
The example below demonstrates both generation and verification of JWT:
|
||||
|
||||
```ruby
|
||||
require "jwt-multisig"
|
||||
require "securerandom"
|
||||
|
||||
jwt_payload = {
|
||||
iss: "peatio",
|
||||
jti: SecureRandom.uuid,
|
||||
iat: Time.now.to_i,
|
||||
exp: Time.now.to_i + 60,
|
||||
event: {}
|
||||
}
|
||||
|
||||
require "openssl"
|
||||
private_key = OpenSSL::PKey::RSA.generate(2048)
|
||||
public_key = private_key.public_key
|
||||
|
||||
generated_jwt = JWT::Multisig.generate_jwt(jwt_payload, { peatio: private_key }, { peatio: "RS256" })
|
||||
|
||||
Kernel.puts "GENERATED JWT", generated_jwt.to_json, "\n"
|
||||
|
||||
verification_result = JWT::Multisig.verify_jwt generated_jwt.deep_stringify_keys, \
|
||||
{ peatio: public_key }, { verify_iss: true, iss: "peatio", verify_jti: true }
|
||||
|
||||
decoded_jwt_payload = verification_result[:payload]
|
||||
|
||||
Kernel.puts "MATCH AFTER VERIFICATION: #{jwt_payload == decoded_jwt_payload}."
|
||||
```
|
||||
|
||||
The RabbitMQ message is stored in JWT field called `event`.
|
||||
|
||||
## Overview of Event API message
|
||||
|
||||
The typical event looks like (JSON):
|
||||
|
||||
```ruby
|
||||
event: {
|
||||
name: "model.deposit.updated",
|
||||
foo: "...",
|
||||
bar: "...",
|
||||
qux: "..."
|
||||
}
|
||||
```
|
||||
|
||||
The field `event[:name]` contains event name (same as routing key).
|
||||
The fields `foo`, `bar`, `qux` (just for example) are fields which carry useful information.
|
||||
|
||||
## Format of `model.deposit.created` event
|
||||
|
||||
```ruby
|
||||
event: {
|
||||
name: "model.deposit.created",
|
||||
record: {
|
||||
tid: "TID9493F6CD41",
|
||||
user: {
|
||||
uid: "ID092B2AF8E87",
|
||||
email: "john@doe.com"
|
||||
},
|
||||
uid: "ID092B2AF8E87",
|
||||
currency: "btc",
|
||||
amount: "0.0855",
|
||||
state: "submitted",
|
||||
created_at: "2018-04-12T17:16:06+03:00",
|
||||
updated_at: "2018-04-12T17:16:06+03:00",
|
||||
completed_at: nil,
|
||||
blockchain_address: "n1Ytj6Hy57YpfueA2vtmnwJQs583bpYn7W",
|
||||
blockchain_txid: "c37ae1677c4c989dbde9ac22be1f3ff3ac67ed24732a9fa8c9258fdff0232d72",
|
||||
blockchain_confirmations: 1
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Description |
|
||||
| ---------- | ----------------------------------- |
|
||||
| `record` | The up-to-date deposit attributes. |
|
||||
|
||||
## Format of `model.deposit.updated` event
|
||||
|
||||
```ruby
|
||||
event: {
|
||||
name: "model.deposit.updated",
|
||||
record: {
|
||||
tid: "TID9493F6CD41",
|
||||
user: {
|
||||
uid: "ID092B2AF8E87",
|
||||
email: "john@doe.com"
|
||||
},
|
||||
uid: "ID092B2AF8E87",
|
||||
currency: "btc",
|
||||
amount: "0.0855",
|
||||
state: "accepted",
|
||||
created_at: "2018-04-12T17:16:06+03:00",
|
||||
updated_at: "2018-04-12T18:46:57+03:00",
|
||||
completed_at: "2018-04-12T18:46:57+03:00",
|
||||
blockchain_address: "n1Ytj6Hy57YpfueA2vtmnwJQs583bpYn7W",
|
||||
blockchain_txid: "c37ae1677c4c989dbde9ac22be1f3ff3ac67ed24732a9fa8c9258fdff0232d72",
|
||||
blockchain_confirmations: 7
|
||||
},
|
||||
changes: {
|
||||
state: "submitted",
|
||||
completed_at: nil,
|
||||
blockchain_confirmations: 1,
|
||||
updated_at: "2018-04-12T17:16:06+03:00"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Description |
|
||||
| ---------- | ------------------------------------------------ |
|
||||
| `record` | The up-to-date deposit attributes. |
|
||||
| `changes` | The changed deposit attributes and their values. |
|
||||
|
||||
## Format of `model.withdraw.created` event
|
||||
|
||||
```ruby
|
||||
event: {
|
||||
name: "model.withdraw.created",
|
||||
record: {
|
||||
tid: "TID892F29F094",
|
||||
user: {
|
||||
uid: "ID092B2AF8E87",
|
||||
email: "john@doe.com"
|
||||
},
|
||||
uid: "ID092B2AF8E87",
|
||||
rid: "0xdA35deE8EDDeAA556e4c26268463e26FB91ff74f",
|
||||
currency: "eth",
|
||||
amount: "4.5485",
|
||||
fee: "0.0015",
|
||||
state: "prepared",
|
||||
created_at: "2018-04-12T18:52:16+03:00",
|
||||
updated_at: "2018-04-12T18:52:16+03:00",
|
||||
completed_at: nil,
|
||||
blockchain_txid: nil
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Description |
|
||||
| ---------- | ------------------------------------ |
|
||||
| `record` | The up-to-date withdraw attributes. |
|
||||
|
||||
## Format of `model.withdraw.updated` event
|
||||
|
||||
```ruby
|
||||
event: {
|
||||
name: "model.withdraw.updated",
|
||||
record: {
|
||||
tid: "TID892F29F094",
|
||||
user: {
|
||||
uid: "ID092B2AF8E87",
|
||||
email: "john@doe.com"
|
||||
},
|
||||
uid: "ID092B2AF8E87",
|
||||
rid: "0xdA35deE8EDDeAA556e4c26268463e26FB91ff74f",
|
||||
currency: "eth",
|
||||
amount: "4.5485",
|
||||
fee: "0.0015",
|
||||
state: "succeed",
|
||||
created_at: "2018-04-12T18:52:16+03:00",
|
||||
updated_at: "2018-04-12T18:56:23+03:00",
|
||||
completed_at: "2018-04-12T18:56:23+03:00",
|
||||
blockchain_txid: "0x9c34d1750e225a95938f9884e857ab6f55eedda43b159d13abf773fe6a916164"
|
||||
},
|
||||
changes: {
|
||||
state: "processing",
|
||||
updated_at: "2018-04-12T18:55:39+03:00",
|
||||
completed_at: "2018-04-12T18:55:39+03:00",
|
||||
blockchain_txid: nil
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Description |
|
||||
| ---------- | ------------------------------------------------ |
|
||||
| `record` | The up-to-date withdraw attributes. |
|
||||
| `changes` | The changed withdraw attributes and their values. |
|
||||
|
||||
## Format of `model.account.created` event
|
||||
|
||||
```ruby
|
||||
event: {
|
||||
name: "model.account.created",
|
||||
record: {
|
||||
id: "1",
|
||||
member_id: "2",
|
||||
currency_id: "btc",
|
||||
balance: "0",
|
||||
locked: "0",
|
||||
created_at: "2018-04-12T17:16:06+03:00",
|
||||
updated_at: "2018-04-12T17:16:06+03:00",
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Description |
|
||||
| ---------- | ----------------------------------- |
|
||||
| `record` | The up-to-date account attributes. |
|
||||
|
||||
## Format of `model.account.updated` event
|
||||
|
||||
```ruby
|
||||
event: {
|
||||
name: "model.account.updated",
|
||||
record: {
|
||||
id: "1",
|
||||
member_id: "2",
|
||||
currency_id: "btc",
|
||||
balance: "1",
|
||||
locked: "0",
|
||||
created_at: "2018-04-12T17:16:06+03:00",
|
||||
updated_at: "2018-04-12T17:17:06+03:00",
|
||||
},
|
||||
changes: {
|
||||
balance: "0",
|
||||
updated_at: "2018-04-12T17:16:06+03:00"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Description |
|
||||
| ---------- | ------------------------------------------------ |
|
||||
| `record` | The up-to-date account attributes. |
|
||||
| `changes` | The changed account attributes and their values. |
|
||||
|
||||
## Format of `system.low_hot_wallet_balance` event
|
||||
|
||||
```ruby
|
||||
event: {
|
||||
name: "system.system.low_hot_wallet_balance",
|
||||
currency: "btc",
|
||||
balance: "2.82480099"
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Description |
|
||||
| ---------- | ----------------------- |
|
||||
| `currency` | The currency code. |
|
||||
| `balance` | The up-to-date balance. |
|
||||
|
||||
## Format of `market.btcusd.order_created` event
|
||||
|
||||
Buy 14 BTC for 0.42 USD (0.03 USD per BTC).
|
||||
|
||||
```ruby
|
||||
event: {
|
||||
name: "market.btcusd.order_created",
|
||||
market: "btcusd",
|
||||
type: "buy",
|
||||
trader_uid: "ID022H2NF6E87",
|
||||
income_unit: "btc",
|
||||
income_fee_type: "relative",
|
||||
income_fee_value: "0.0015",
|
||||
outcome_unit: "usd",
|
||||
outcome_fee_type: "relative",
|
||||
outcome_fee_value: "0.0",
|
||||
initial_income_amount: "14.0",
|
||||
current_income_amount: "14.0",
|
||||
initial_outcome_amount: "0.42",
|
||||
current_outcome_amount: "0.42",
|
||||
strategy: "limit",
|
||||
price: "0.03",
|
||||
state: "open",
|
||||
trades_count: 0,
|
||||
created_at: "2018-05-07T02:12:28Z"
|
||||
}
|
||||
```
|
||||
|
||||
## Format of `market.btcusd.order_updated` event
|
||||
|
||||
Sell 100 BTC for 3 USD (0.03 USD per BTC).
|
||||
|
||||
```ruby
|
||||
event: {
|
||||
name: "market.btcusd.order_updated",
|
||||
market: "btcusd",
|
||||
type: "sell",
|
||||
trader_uid: "ID092B2AF8E87",
|
||||
income_unit: "usd",
|
||||
income_fee_type: "relative",
|
||||
income_fee_value: "0.0015",
|
||||
outcome_unit: "btc",
|
||||
outcome_fee_type: "relative",
|
||||
outcome_fee_value: "0.0",
|
||||
initial_income_amount: "3.0",
|
||||
current_income_amount: "2.4",
|
||||
previous_income_amount: "3.0",
|
||||
initial_outcome_amount: "100.0",
|
||||
current_outcome_amount: "80.0",
|
||||
previous_outcome_amount: "100.0",
|
||||
strategy: "limit",
|
||||
price: "0.03",
|
||||
state: "open",
|
||||
trades_count: 1,
|
||||
created_at: "2018-05-07T02:12:28Z",
|
||||
updated_at: "2018-05-08T10:13:13Z"
|
||||
}
|
||||
```
|
||||
|
||||
## Format of `market.btcusd.order_canceled` event
|
||||
|
||||
Sell 100 BTC for 3 USD (0.03 USD per BTC).
|
||||
|
||||
```ruby
|
||||
event: {
|
||||
name: "market.btcusd.order_canceled",
|
||||
market: "btcusd",
|
||||
type: "sell",
|
||||
trader_uid: "ID092B2AF8E87",
|
||||
income_unit: "usd",
|
||||
income_fee_type: "relative",
|
||||
income_fee_value: "0.0015",
|
||||
outcome_unit: "btc",
|
||||
outcome_fee_type: "relative",
|
||||
outcome_fee_value: "0.0",
|
||||
initial_income_amount: "3.0",
|
||||
current_income_amount: "3.0",
|
||||
initial_outcome_amount: "100.0",
|
||||
current_outcome_amount: "100.0",
|
||||
strategy: "limit",
|
||||
price: "0.03",
|
||||
state: "canceled",
|
||||
trades_count: 0,
|
||||
created_at: "2018-05-07T02:12:28Z",
|
||||
canceled_at: "2018-05-08T10:13:13Z"
|
||||
}
|
||||
```
|
||||
|
||||
## Format of `market.btcusd.order_completed` event
|
||||
|
||||
Sell 100 BTC for 3 USD (0.03 USD per BTC).
|
||||
|
||||
```ruby
|
||||
event: {
|
||||
name: "market.btcusd.order_completed",
|
||||
market: "btcusd",
|
||||
type: "sell",
|
||||
trader_uid: "ID092B2AF8E87",
|
||||
income_unit: "usd",
|
||||
income_fee_type: "relative",
|
||||
income_fee_value: "0.0015",
|
||||
outcome_unit: "btc",
|
||||
outcome_fee_type: "relative",
|
||||
outcome_fee_value: "0.0",
|
||||
initial_income_amount: "3.0",
|
||||
current_income_amount: "0.0",
|
||||
previous_income_amount: "3.0",
|
||||
initial_outcome_amount: "100.0",
|
||||
current_outcome_amount: "0.0",
|
||||
previous_outcome_amount: "100.0",
|
||||
strategy: "limit",
|
||||
price: "0.03",
|
||||
state: "completed",
|
||||
trades_count: 1,
|
||||
created_at: "2018-05-07T02:12:28Z",
|
||||
completed_at: "2018-05-07T17:32:09Z"
|
||||
}
|
||||
```
|
||||
|
||||
## Format of `market.btcusd.trade_completed` event
|
||||
|
||||
```ruby
|
||||
event: {
|
||||
name: "market.btcusd.trade_completed",
|
||||
market: "btcusd",
|
||||
price: "0.03",
|
||||
buyer_uid: "ID022H2NF6E87",
|
||||
buyer_income_unit: "btc",
|
||||
buyer_income_amount: "14",
|
||||
buyer_income_fee: "0.021",
|
||||
buyer_outcome_unit: "usd",
|
||||
buyer_outcome_amount: "0.42",
|
||||
buyer_outcome_fee: "0.0",
|
||||
seller_uid: "ID092B2AF8E87",
|
||||
seller_income_unit: "usd",
|
||||
seller_income_amount: "0.42",
|
||||
seller_income_fee: "0.00063",
|
||||
seller_outcome_unit: "btc",
|
||||
seller_outcome_amount: "14.0",
|
||||
seller_outcome_fee: "0.0",
|
||||
completed_at: "2018-05-07T17:32:09Z"
|
||||
}
|
||||
```
|
||||
|
||||
## Producing events using Ruby
|
||||
|
||||
```ruby
|
||||
require "bunny"
|
||||
|
||||
def generate_jwt(jwt_payload)
|
||||
Kernel.abort "Please, see «Overview of RabbitMQ message» for implementation guide."
|
||||
end
|
||||
|
||||
Bunny.run host: "localhost", port: 5672, username: "guest", password: "guest" do |session|
|
||||
channel = session.channel
|
||||
exchange = channel.direct("peatio.events.model")
|
||||
jwt_payload = {
|
||||
iss: "peatio",
|
||||
jti: SecureRandom.uuid,
|
||||
iat: Time.now.to_i,
|
||||
exp: Time.now.to_i + 60,
|
||||
event: {
|
||||
name: "model.deposit.created",
|
||||
record: {
|
||||
tid: "TID9493F6CD41",
|
||||
user: {
|
||||
uid: "ID092B2AF8E87",
|
||||
email: "john@doe.com"
|
||||
},
|
||||
uid: "ID092B2AF8E87",
|
||||
currency: "btc",
|
||||
amount: "0.0855",
|
||||
state: "submitted",
|
||||
created_at: "2018-04-12T17:16:06+03:00",
|
||||
updated_at: "2018-04-12T17:16:06+03:00",
|
||||
completed_at: nil,
|
||||
blockchain_address: "n1Ytj6Hy57YpfueA2vtmnwJQs583bpYn7W",
|
||||
blockchain_txid: "c37ae1677c4c989dbde9ac22be1f3ff3ac67ed24732a9fa8c9258fdff0232d72",
|
||||
blockchain_confirmations: 1
|
||||
}
|
||||
}
|
||||
}
|
||||
exchange.publish(generate_jwt(jwt_payload), routing_key: "deposit.created")
|
||||
end
|
||||
```
|
||||
|
||||
IMPORTANT: Don't forget to implement the logic for JWT exception handling!
|
||||
|
||||
## Producing events using `rabbitmqadmin`
|
||||
|
||||
`rabbitmqadmin publish routing_key=deposit.created payload=JWT exchange=peatio.events.model`
|
||||
|
||||
Don't forget to pass environment variable `JWT`.
|
||||
|
||||
## Consuming events using Ruby
|
||||
|
||||
```ruby
|
||||
require "bunny"
|
||||
|
||||
def verify_jwt(jwt_payload)
|
||||
Kernel.abort "Please, see «Overview of RabbitMQ message» for implementation guide."
|
||||
end
|
||||
|
||||
Bunny.run host: "localhost", port: 5672, username: "guest", password: "guest" do |session|
|
||||
channel = session.channel
|
||||
exchange = channel.direct("peatio.events.model")
|
||||
queue = channel.queue("", auto_delete: true, durable: true, exclusive: true)
|
||||
.bind(exchange, routing_key: "deposit.updated")
|
||||
queue.subscribe manual_ack: true, block: true do |delivery_info, metadata, payload|
|
||||
Kernel.puts verify_jwt(JSON.parse(payload)).fetch(:event)
|
||||
channel.ack(delivery_info.delivery_tag)
|
||||
rescue => e
|
||||
channel.nack(delivery_info.delivery_tag, false, true)
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
IMPORTANT: Don't forget to implement the logic for JWT exception handling!
|
||||
|
||||
BIN
docs/api/images/peatio/scheme_ranger_private_channels.png
Normal file
BIN
docs/api/images/peatio/scheme_ranger_private_channels.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 18 KiB |
BIN
docs/api/images/peatio/scheme_ranger_public_channels.png
Normal file
BIN
docs/api/images/peatio/scheme_ranger_public_channels.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
10
docs/api/mask.md
Normal file
10
docs/api/mask.md
Normal file
@@ -0,0 +1,10 @@
|
||||
# Data masking
|
||||
|
||||
Data masking is the process of hiding original data with modified content (characters or other data.)
|
||||
The main reason for applying masking to a data field is to protect data that is classified as personally identifiable information, sensitive personal data, or commercially sensitive data.
|
||||
|
||||
On Peatio beneficiary account number is masked on API level.
|
||||
|
||||
| Field | Mask | Comment |
|
||||
|---|---|---|
|
||||
| Account number | 42 **** **** 2345 | First 2 number and last 4 digits |
|
||||
1832
docs/api/peatio_admin_api_v2.md
Normal file
1832
docs/api/peatio_admin_api_v2.md
Normal file
File diff suppressed because it is too large
Load Diff
943
docs/api/peatio_management_api_v2.md
Normal file
943
docs/api/peatio_management_api_v2.md
Normal file
@@ -0,0 +1,943 @@
|
||||
# Peatio Management API v2
|
||||
Management API is server-to-server API with high privileges.
|
||||
|
||||
## Version: 2.6.0
|
||||
|
||||
**Contact information:**
|
||||
openware.com
|
||||
<https://www.openware.com>
|
||||
hello@openware.com
|
||||
|
||||
**License:** <https://github.com/openware/peatio/blob/master/LICENSE.md>
|
||||
|
||||
### /api/v2/management/peatio/beneficiaries
|
||||
|
||||
#### POST
|
||||
##### Description
|
||||
|
||||
Create new beneficiary
|
||||
|
||||
##### Parameters
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ---- |
|
||||
| currency | formData | Beneficiary currency code. | Yes | string |
|
||||
| name | formData | Human rememberable name which refer beneficiary. | Yes | string |
|
||||
| description | formData | Human rememberable description which refer beneficiary. | No | string |
|
||||
| data | formData | Beneficiary data in JSON format | Yes | json |
|
||||
| uid | formData | The shared user ID. | Yes | string |
|
||||
| state | formData | Defines either beneficiary active - user can use it to withdraw moneyor pending - requires beneficiary activation with pin. | No | string |
|
||||
|
||||
##### Responses
|
||||
|
||||
| Code | Description | Schema |
|
||||
| ---- | ----------- | ------ |
|
||||
| 201 | Create new beneficiary | [Beneficiary](#beneficiary) |
|
||||
|
||||
### /api/v2/management/peatio/beneficiaries/list
|
||||
|
||||
#### POST
|
||||
##### Description
|
||||
|
||||
Get list of user beneficiaries
|
||||
|
||||
##### Parameters
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ---- |
|
||||
| uid | formData | The shared user ID. | Yes | string |
|
||||
| currency | formData | Beneficiary currency code. | No | string |
|
||||
| state | formData | Defines either beneficiary active - user can use it to withdraw moneyor pending - requires beneficiary activation with pin. | No | string |
|
||||
|
||||
##### Responses
|
||||
|
||||
| Code | Description | Schema |
|
||||
| ---- | ----------- | ------ |
|
||||
| 201 | Get list of user beneficiaries | [Beneficiary](#beneficiary) |
|
||||
|
||||
### /api/v2/management/peatio/accounts/balances
|
||||
|
||||
#### POST
|
||||
##### Description
|
||||
|
||||
Queries the non-zero balance accounts for the given currency.
|
||||
|
||||
##### Parameters
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ---- |
|
||||
| currency | formData | The currency code. | Yes | string |
|
||||
| page | formData | The page number (defaults to 1). | No | integer |
|
||||
| limit | formData | The number of accounts per page (defaults to 100, maximum is 1000). | No | integer |
|
||||
|
||||
##### Responses
|
||||
|
||||
| Code | Description | Schema |
|
||||
| ---- | ----------- | ------ |
|
||||
| 201 | Queries the non-zero balance accounts for the given currency. | [Balance](#balance) |
|
||||
|
||||
### /api/v2/management/peatio/accounts/balance
|
||||
|
||||
#### POST
|
||||
##### Description
|
||||
|
||||
Queries the account balance for the given UID and currency.
|
||||
|
||||
##### Parameters
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ---- |
|
||||
| uid | formData | The shared user ID. | Yes | string |
|
||||
| currency | formData | The currency code. | Yes | string |
|
||||
|
||||
##### Responses
|
||||
|
||||
| Code | Description | Schema |
|
||||
| ---- | ----------- | ------ |
|
||||
| 201 | Queries the account balance for the given UID and currency. | [Balance](#balance) |
|
||||
|
||||
### /api/v2/management/peatio/deposits/state
|
||||
|
||||
#### PUT
|
||||
##### Description
|
||||
|
||||
Allows to load money or cancel deposit.
|
||||
|
||||
##### Parameters
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ---- |
|
||||
| tid | formData | The shared transaction ID. | Yes | string |
|
||||
| state | formData | The new state to apply. | Yes | string |
|
||||
|
||||
##### Responses
|
||||
|
||||
| Code | Description | Schema |
|
||||
| ---- | ----------- | ------ |
|
||||
| 200 | Allows to load money or cancel deposit. | [Deposit](#deposit) |
|
||||
|
||||
### /api/v2/management/peatio/deposits/new
|
||||
|
||||
#### POST
|
||||
##### Description
|
||||
|
||||
Creates new fiat deposit with state set to «submitted». Optionally pass field «state» set to «accepted» if want to load money instantly. You can also use PUT /fiat_deposits/:id later to load money or cancel deposit.
|
||||
|
||||
##### Parameters
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ---- |
|
||||
| uid | formData | The shared user ID. | Yes | string |
|
||||
| tid | formData | The shared transaction ID. Must not exceed 64 characters. Peatio will generate one automatically unless supplied. | No | string |
|
||||
| currency | formData | The currency code. | Yes | string |
|
||||
| amount | formData | The deposit amount. | Yes | double |
|
||||
| state | formData | The state of deposit. | No | string |
|
||||
| transfer_type | formData | Deposit transfer type | No | string |
|
||||
|
||||
##### Responses
|
||||
|
||||
| Code | Description | Schema |
|
||||
| ---- | ----------- | ------ |
|
||||
| 201 | Creates new fiat deposit with state set to «submitted». Optionally pass field «state» set to «accepted» if want to load money instantly. You can also use PUT /fiat_deposits/:id later to load money or cancel deposit. | [Deposit](#deposit) |
|
||||
|
||||
### /api/v2/management/peatio/deposits/get
|
||||
|
||||
#### POST
|
||||
##### Description
|
||||
|
||||
Returns deposit by TID.
|
||||
|
||||
##### Parameters
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ---- |
|
||||
| tid | formData | The transaction ID. | Yes | string |
|
||||
|
||||
##### Responses
|
||||
|
||||
| Code | Description | Schema |
|
||||
| ---- | ----------- | ------ |
|
||||
| 201 | Returns deposit by TID. | [Deposit](#deposit) |
|
||||
|
||||
### /api/v2/management/peatio/deposits
|
||||
|
||||
#### POST
|
||||
##### Description
|
||||
|
||||
Returns deposits as paginated collection.
|
||||
|
||||
##### Parameters
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ---- |
|
||||
| uid | formData | The shared user ID. | No | string |
|
||||
| currency | formData | The currency code. | No | string |
|
||||
| page | formData | The page number (defaults to 1). | No | integer |
|
||||
| limit | formData | The number of deposits per page (defaults to 100, maximum is 1000). | No | integer |
|
||||
| state | formData | The state to filter by. | No | string |
|
||||
|
||||
##### Responses
|
||||
|
||||
| Code | Description | Schema |
|
||||
| ---- | ----------- | ------ |
|
||||
| 201 | Returns deposits as paginated collection. | [Deposit](#deposit) |
|
||||
|
||||
### /api/v2/management/peatio/withdraws/action
|
||||
|
||||
#### PUT
|
||||
##### Summary
|
||||
|
||||
Performs action on withdraw.
|
||||
|
||||
##### Description
|
||||
|
||||
«process» – system will lock the money, check for suspected activity, validate recipient address, and initiate the processing of the withdraw. «cancel» – system will mark withdraw as «canceled», and unlock the money.
|
||||
|
||||
##### Parameters
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ---- |
|
||||
| tid | formData | The shared transaction ID. | Yes | string |
|
||||
| action | formData | The action to perform. | Yes | string |
|
||||
|
||||
##### Responses
|
||||
|
||||
| Code | Description | Schema |
|
||||
| ---- | ----------- | ------ |
|
||||
| 200 | Performs action on withdraw. | [Withdraw](#withdraw) |
|
||||
|
||||
### /api/v2/management/peatio/withdraws/new
|
||||
|
||||
#### POST
|
||||
##### Summary
|
||||
|
||||
Creates new withdraw.
|
||||
|
||||
##### Description
|
||||
|
||||
Creates new withdraw. The behaviours for fiat and crypto withdraws are different. Fiat: money are immediately locked, withdraw state is set to «submitted», system workers will validate withdraw later against suspected activity, and assign state to «rejected» or «accepted». The processing will not begin automatically. The processing may be initiated manually from admin panel or by PUT /management_api/v1/withdraws/action. Coin: money are immediately locked, withdraw state is set to «submitted», system workers will validate withdraw later against suspected activity, validate withdraw address and set state to «rejected» or «accepted». Then in case state is «accepted» withdraw workers will perform interactions with blockchain. The withdraw receives new state «processing». Then withdraw receives state either «confirming» or «failed».Then in case state is «confirming» withdraw confirmations workers will perform interactions with blockchain.Withdraw receives state «succeed» when it receives minimum necessary amount of confirmations.
|
||||
|
||||
##### Parameters
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ---- |
|
||||
| uid | formData | The shared user ID. | Yes | string |
|
||||
| tid | formData | The shared transaction ID. Must not exceed 64 characters. Peatio will generate one automatically unless supplied. | No | string |
|
||||
| rid | formData | The beneficiary ID or wallet address on the Blockchain. | No | string |
|
||||
| beneficiary_id | formData | ID of Active Beneficiary belonging to user. | No | string |
|
||||
| currency | formData | The currency code. | Yes | string |
|
||||
| amount | formData | The amount to withdraw. | Yes | double |
|
||||
| note | formData | The note for withdraw. | No | string |
|
||||
| action | formData | The action to perform. | No | string |
|
||||
| transfer_type | formData | Withdraw transfer type | No | string |
|
||||
|
||||
##### Responses
|
||||
|
||||
| Code | Description | Schema |
|
||||
| ---- | ----------- | ------ |
|
||||
| 201 | Creates new withdraw. | [Withdraw](#withdraw) |
|
||||
|
||||
### /api/v2/management/peatio/withdraws/get
|
||||
|
||||
#### POST
|
||||
##### Description
|
||||
|
||||
Returns withdraw by ID.
|
||||
|
||||
##### Parameters
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ---- |
|
||||
| tid | formData | The shared transaction ID. | Yes | string |
|
||||
|
||||
##### Responses
|
||||
|
||||
| Code | Description | Schema |
|
||||
| ---- | ----------- | ------ |
|
||||
| 201 | Returns withdraw by ID. | [Withdraw](#withdraw) |
|
||||
|
||||
### /api/v2/management/peatio/withdraws
|
||||
|
||||
#### POST
|
||||
##### Description
|
||||
|
||||
Returns withdraws as paginated collection.
|
||||
|
||||
##### Parameters
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ---- |
|
||||
| uid | formData | The shared user ID. | No | string |
|
||||
| currency | formData | The currency code. | No | string |
|
||||
| page | formData | The page number (defaults to 1). | No | integer |
|
||||
| limit | formData | The number of objects per page (defaults to 100, maximum is 1000). | No | integer |
|
||||
| state | formData | The state to filter by. | No | string |
|
||||
|
||||
##### Responses
|
||||
|
||||
| Code | Description | Schema |
|
||||
| ---- | ----------- | ------ |
|
||||
| 201 | Returns withdraws as paginated collection. | [Withdraw](#withdraw) |
|
||||
|
||||
### /api/v2/management/peatio/timestamp
|
||||
|
||||
#### POST
|
||||
##### Description
|
||||
|
||||
Returns server time in seconds since Unix epoch.
|
||||
|
||||
##### Responses
|
||||
|
||||
| Code | Description |
|
||||
| ---- | ----------- |
|
||||
| 201 | Returns server time in seconds since Unix epoch. |
|
||||
|
||||
### /api/v2/management/peatio/assets/new
|
||||
|
||||
#### POST
|
||||
##### Description
|
||||
|
||||
Creates new asset operation.
|
||||
|
||||
##### Parameters
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ---- |
|
||||
| currency | formData | The currency code. | Yes | string |
|
||||
| code | formData | Operation account code | Yes | integer |
|
||||
| debit | formData | Operation debit amount. | No | double |
|
||||
| credit | formData | Operation credit amount. | No | double |
|
||||
|
||||
##### Responses
|
||||
|
||||
| Code | Description | Schema |
|
||||
| ---- | ----------- | ------ |
|
||||
| 201 | Creates new asset operation. | [Operation](#operation) |
|
||||
|
||||
### /api/v2/management/peatio/assets
|
||||
|
||||
#### POST
|
||||
##### Description
|
||||
|
||||
Returns assets as paginated collection.
|
||||
|
||||
##### Parameters
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ---- |
|
||||
| currency | formData | The currency for operations filtering. | No | string |
|
||||
| page | formData | The page number (defaults to 1). | No | integer |
|
||||
| limit | formData | The number of objects per page (defaults to 100, maximum is 1000). | No | integer |
|
||||
| time_from | formData | An integer represents the seconds elapsed since Unix epoch.If set, only operations after the time will be returned. | No | integer |
|
||||
| time_to | formData | An integer represents the seconds elapsed since Unix epoch.If set, only operations before the time will be returned. | No | integer |
|
||||
| reference_type | formData | The reference type for operations filtering | No | string |
|
||||
|
||||
##### Responses
|
||||
|
||||
| Code | Description | Schema |
|
||||
| ---- | ----------- | ------ |
|
||||
| 201 | Returns assets as paginated collection. | [Operation](#operation) |
|
||||
|
||||
### /api/v2/management/peatio/expenses/new
|
||||
|
||||
#### POST
|
||||
##### Description
|
||||
|
||||
Creates new expense operation.
|
||||
|
||||
##### Parameters
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ---- |
|
||||
| currency | formData | The currency code. | Yes | string |
|
||||
| code | formData | Operation account code | Yes | integer |
|
||||
| debit | formData | Operation debit amount. | No | double |
|
||||
| credit | formData | Operation credit amount. | No | double |
|
||||
|
||||
##### Responses
|
||||
|
||||
| Code | Description | Schema |
|
||||
| ---- | ----------- | ------ |
|
||||
| 201 | Creates new expense operation. | [Operation](#operation) |
|
||||
|
||||
### /api/v2/management/peatio/expenses
|
||||
|
||||
#### POST
|
||||
##### Description
|
||||
|
||||
Returns expenses as paginated collection.
|
||||
|
||||
##### Parameters
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ---- |
|
||||
| currency | formData | The currency for operations filtering. | No | string |
|
||||
| page | formData | The page number (defaults to 1). | No | integer |
|
||||
| limit | formData | The number of objects per page (defaults to 100, maximum is 1000). | No | integer |
|
||||
| time_from | formData | An integer represents the seconds elapsed since Unix epoch.If set, only operations after the time will be returned. | No | integer |
|
||||
| time_to | formData | An integer represents the seconds elapsed since Unix epoch.If set, only operations before the time will be returned. | No | integer |
|
||||
| reference_type | formData | The reference type for operations filtering | No | string |
|
||||
|
||||
##### Responses
|
||||
|
||||
| Code | Description | Schema |
|
||||
| ---- | ----------- | ------ |
|
||||
| 201 | Returns expenses as paginated collection. | [Operation](#operation) |
|
||||
|
||||
### /api/v2/management/peatio/revenues/new
|
||||
|
||||
#### POST
|
||||
##### Description
|
||||
|
||||
Creates new revenue operation.
|
||||
|
||||
##### Parameters
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ---- |
|
||||
| currency | formData | The currency code. | Yes | string |
|
||||
| code | formData | Operation account code | Yes | integer |
|
||||
| debit | formData | Operation debit amount. | No | double |
|
||||
| credit | formData | Operation credit amount. | No | double |
|
||||
|
||||
##### Responses
|
||||
|
||||
| Code | Description | Schema |
|
||||
| ---- | ----------- | ------ |
|
||||
| 201 | Creates new revenue operation. | [Operation](#operation) |
|
||||
|
||||
### /api/v2/management/peatio/revenues
|
||||
|
||||
#### POST
|
||||
##### Description
|
||||
|
||||
Returns revenues as paginated collection.
|
||||
|
||||
##### Parameters
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ---- |
|
||||
| currency | formData | The currency for operations filtering. | No | string |
|
||||
| page | formData | The page number (defaults to 1). | No | integer |
|
||||
| limit | formData | The number of objects per page (defaults to 100, maximum is 1000). | No | integer |
|
||||
| time_from | formData | An integer represents the seconds elapsed since Unix epoch.If set, only operations after the time will be returned. | No | integer |
|
||||
| time_to | formData | An integer represents the seconds elapsed since Unix epoch.If set, only operations before the time will be returned. | No | integer |
|
||||
| reference_type | formData | The reference type for operations filtering | No | string |
|
||||
|
||||
##### Responses
|
||||
|
||||
| Code | Description | Schema |
|
||||
| ---- | ----------- | ------ |
|
||||
| 201 | Returns revenues as paginated collection. | [Operation](#operation) |
|
||||
|
||||
### /api/v2/management/peatio/liabilities/new
|
||||
|
||||
#### POST
|
||||
##### Description
|
||||
|
||||
Creates new liability operation.
|
||||
|
||||
##### Parameters
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ---- |
|
||||
| currency | formData | The currency code. | Yes | string |
|
||||
| code | formData | Operation account code | Yes | integer |
|
||||
| uid | formData | The user ID for operation owner. | Yes | string |
|
||||
| debit | formData | Operation debit amount. | No | double |
|
||||
| credit | formData | Operation credit amount. | No | double |
|
||||
|
||||
##### Responses
|
||||
|
||||
| Code | Description | Schema |
|
||||
| ---- | ----------- | ------ |
|
||||
| 201 | Creates new liability operation. | [Operation](#operation) |
|
||||
|
||||
### /api/v2/management/peatio/liabilities
|
||||
|
||||
#### POST
|
||||
##### Description
|
||||
|
||||
Returns liabilities as paginated collection.
|
||||
|
||||
##### Parameters
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ---- |
|
||||
| currency | formData | The currency for operations filtering. | No | string |
|
||||
| uid | formData | The user ID for operations filtering. | No | string |
|
||||
| reference_type | formData | The reference type for operations filtering | No | string |
|
||||
| time_from | formData | An integer represents the seconds elapsed since Unix epoch.If set, only operations after the time will be returned. | No | integer |
|
||||
| time_to | formData | An integer represents the seconds elapsed since Unix epoch.If set, only operations before the time will be returned. | No | integer |
|
||||
| page | formData | The page number (defaults to 1). | No | integer |
|
||||
| limit | formData | The number of objects per page (defaults to 100, maximum is 10000). | No | integer |
|
||||
|
||||
##### Responses
|
||||
|
||||
| Code | Description | Schema |
|
||||
| ---- | ----------- | ------ |
|
||||
| 201 | Returns liabilities as paginated collection. | [Operation](#operation) |
|
||||
|
||||
### /api/v2/management/peatio/orders/cancel
|
||||
|
||||
#### POST
|
||||
##### Description
|
||||
|
||||
Cancel all open orders
|
||||
|
||||
##### Parameters
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ---- |
|
||||
| uid | formData | Filter order by owner uid | No | string |
|
||||
| market | formData | Unique market id. It's always in the form of xxxyyy,where xxx is the base currency code, yyy is the quotecurrency code, e.g. 'btcusd'. All available markets canbe found at /api/v2/markets. | Yes | string |
|
||||
|
||||
##### Responses
|
||||
|
||||
| Code | Description | Schema |
|
||||
| ---- | ----------- | ------ |
|
||||
| 201 | Cancel all open orders | [Order](#order) |
|
||||
|
||||
### /api/v2/management/peatio/orders/{id}/cancel
|
||||
|
||||
#### POST
|
||||
##### Description
|
||||
|
||||
Cancel specific order
|
||||
|
||||
##### Parameters
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ---- |
|
||||
| id | path | Unique order id. | Yes | string |
|
||||
|
||||
##### Responses
|
||||
|
||||
| Code | Description | Schema |
|
||||
| ---- | ----------- | ------ |
|
||||
| 201 | Cancel specific order | [Order](#order) |
|
||||
|
||||
### /api/v2/management/peatio/orders
|
||||
|
||||
#### POST
|
||||
##### Description
|
||||
|
||||
Returns orders
|
||||
|
||||
##### Parameters
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ---- |
|
||||
| uid | formData | Filter order by owner uid | No | string |
|
||||
| market | formData | Unique market id. It's always in the form of xxxyyy,where xxx is the base currency code, yyy is the quotecurrency code, e.g. 'btcusd'. All available markets canbe found at /api/v2/markets. | No | string |
|
||||
| state | formData | Filter order by state. | No | string |
|
||||
| ord_type | formData | Filter order by ord_type. | No | string |
|
||||
|
||||
##### Responses
|
||||
|
||||
| Code | Description | Schema |
|
||||
| ---- | ----------- | ------ |
|
||||
| 201 | Returns orders | [Order](#order) |
|
||||
|
||||
### /api/v2/management/peatio/transfers/new
|
||||
|
||||
#### POST
|
||||
##### Description
|
||||
|
||||
Creates new transfer.
|
||||
|
||||
##### Parameters
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ---- |
|
||||
| key | formData | Unique Transfer Key. | Yes | string |
|
||||
| category | formData | Transfer Category. | Yes | string |
|
||||
| description | formData | Transfer Description. | No | string |
|
||||
| operations[currency] | formData | Operation currency. | Yes | [ string ] |
|
||||
| operations[amount] | formData | Operation amount. | Yes | [ double ] |
|
||||
| operations[account_src][code] | formData | Source Account code. | Yes | [ integer ] |
|
||||
| operations[account_src][uid] | formData | Source Account User ID (for accounts with member scope). | Yes | [ string ] |
|
||||
| operations[account_dst][code] | formData | Destination Account code. | Yes | [ integer ] |
|
||||
| operations[account_dst][uid] | formData | Destination Account User ID (for accounts with member scope). | Yes | [ string ] |
|
||||
|
||||
##### Responses
|
||||
|
||||
| Code | Description |
|
||||
| ---- | ----------- |
|
||||
| 201 | Creates new transfer. |
|
||||
|
||||
### /api/v2/management/peatio/trades
|
||||
|
||||
#### POST
|
||||
##### Description
|
||||
|
||||
Returns trades as paginated collection.
|
||||
|
||||
##### Parameters
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ---- |
|
||||
| uid | formData | The shared user ID. | No | string |
|
||||
| market | formData | | No | string |
|
||||
| page | formData | The page number (defaults to 1). | No | integer |
|
||||
| limit | formData | The number of objects per page (defaults to 100, maximum is 1000). | No | integer |
|
||||
|
||||
##### Responses
|
||||
|
||||
| Code | Description | Schema |
|
||||
| ---- | ----------- | ------ |
|
||||
| 201 | Returns trades as paginated collection. | [Trade](#trade) |
|
||||
|
||||
### /api/v2/management/peatio/members/group
|
||||
|
||||
#### POST
|
||||
##### Description
|
||||
|
||||
Set user group.
|
||||
|
||||
##### Parameters
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ---- |
|
||||
| uid | formData | The shared user ID. | Yes | string |
|
||||
| group | formData | User gruop | Yes | string |
|
||||
|
||||
##### Responses
|
||||
|
||||
| Code | Description |
|
||||
| ---- | ----------- |
|
||||
| 201 | Set user group. |
|
||||
|
||||
### /api/v2/management/peatio/members
|
||||
|
||||
#### POST
|
||||
##### Description
|
||||
|
||||
Create a member.
|
||||
|
||||
##### Parameters
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ---- |
|
||||
| email | formData | User email. | Yes | string |
|
||||
| uid | formData | The shared user ID. | Yes | string |
|
||||
| level | formData | User level. | Yes | integer |
|
||||
| role | formData | User role. | Yes | string |
|
||||
| state | formData | User state. | Yes | string |
|
||||
| group | formData | User group | Yes | string |
|
||||
|
||||
##### Responses
|
||||
|
||||
| Code | Description |
|
||||
| ---- | ----------- |
|
||||
| 201 | Create a member. |
|
||||
|
||||
### /api/v2/management/peatio/fee_schedule/trading_fees
|
||||
|
||||
#### POST
|
||||
##### Description
|
||||
|
||||
Returns trading_fees table as paginated collection
|
||||
|
||||
##### Parameters
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ---- |
|
||||
| group | formData | Member group | No | string |
|
||||
| market_id | formData | Market id | No | string |
|
||||
| page | formData | The page number (defaults to 1). | No | integer |
|
||||
| limit | formData | The number of objects per page (defaults to 100, maximum is 1000). | No | integer |
|
||||
|
||||
##### Responses
|
||||
|
||||
| Code | Description |
|
||||
| ---- | ----------- |
|
||||
| 201 | Returns trading_fees table as paginated collection |
|
||||
|
||||
### /api/v2/management/peatio/currencies/update
|
||||
|
||||
#### PUT
|
||||
##### Description
|
||||
|
||||
Update currency.
|
||||
|
||||
##### Parameters
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ---- |
|
||||
| id | formData | Currency code. | Yes | string |
|
||||
| name | formData | Currency name | No | string |
|
||||
| deposit_fee | formData | Currency deposit fee | No | double |
|
||||
| min_deposit_amount | formData | Minimal deposit amount | No | double |
|
||||
| min_collection_amount | formData | Minimal deposit amount that will be collected | No | double |
|
||||
| withdraw_fee | formData | Currency withdraw fee | No | double |
|
||||
| min_withdraw_amount | formData | Minimal withdraw amount | No | double |
|
||||
| withdraw_limit_24h | formData | Currency 24h withdraw limit | No | double |
|
||||
| withdraw_limit_72h | formData | Currency 72h withdraw limit | No | double |
|
||||
| position | formData | Currency position. | No | integer |
|
||||
| options | formData | Currency options. | No | json |
|
||||
| visible | formData | Currency display possibility status (true/false). | No | Boolean |
|
||||
| deposit_enabled | formData | Currency deposit possibility status (true/false). | No | Boolean |
|
||||
| withdrawal_enabled | formData | Currency withdrawal possibility status (true/false). | No | Boolean |
|
||||
| precision | formData | Currency precision | No | integer |
|
||||
| icon_url | formData | Currency icon | No | string |
|
||||
|
||||
##### Responses
|
||||
|
||||
| Code | Description | Schema |
|
||||
| ---- | ----------- | ------ |
|
||||
| 200 | Update currency. | [Currency](#currency) |
|
||||
|
||||
### /api/v2/management/peatio/currencies/{code}
|
||||
|
||||
#### POST
|
||||
##### Description
|
||||
|
||||
Returns currency by code.
|
||||
|
||||
##### Parameters
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ---- |
|
||||
| code | path | The currency code. | Yes | string |
|
||||
|
||||
##### Responses
|
||||
|
||||
| Code | Description | Schema |
|
||||
| ---- | ----------- | ------ |
|
||||
| 201 | Returns currency by code. | [Currency](#currency) |
|
||||
|
||||
### /api/v2/management/peatio/currencies/list
|
||||
|
||||
#### POST
|
||||
##### Description
|
||||
|
||||
Return currencies list.
|
||||
|
||||
##### Parameters
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ---- |
|
||||
| type | formData | Currency type | No | string |
|
||||
|
||||
##### Responses
|
||||
|
||||
| Code | Description | Schema |
|
||||
| ---- | ----------- | ------ |
|
||||
| 201 | Return currencies list. | [Currency](#currency) |
|
||||
|
||||
### /api/v2/management/peatio/markets/list
|
||||
|
||||
#### POST
|
||||
##### Description
|
||||
|
||||
Return markets list.
|
||||
|
||||
##### Responses
|
||||
|
||||
| Code | Description | Schema |
|
||||
| ---- | ----------- | ------ |
|
||||
| 201 | Return markets list. | [Market](#market) |
|
||||
|
||||
### /api/v2/management/peatio/markets/update
|
||||
|
||||
#### PUT
|
||||
##### Description
|
||||
|
||||
Update market.
|
||||
|
||||
##### Parameters
|
||||
|
||||
| Name | Located in | Description | Required | Schema |
|
||||
| ---- | ---------- | ----------- | -------- | ---- |
|
||||
| id | formData | Unique market id. It's always in the form of xxxyyy,where xxx is the base currency code, yyy is the quotecurrency code, e.g. 'btcusd'. All available markets canbe found at /api/v2/markets. | Yes | string |
|
||||
| state | formData | Market state defines if user can see/trade on current market. | No | string |
|
||||
| min_price | formData | Minimum order price. | No | double |
|
||||
| min_amount | formData | Minimum order amount. | No | double |
|
||||
| amount_precision | formData | Precision for order amount. | No | integer |
|
||||
| price_precision | formData | Precision for order price. | No | integer |
|
||||
| max_price | formData | Maximum order price. | No | double |
|
||||
| position | formData | Market position. | No | integer |
|
||||
|
||||
##### Responses
|
||||
|
||||
| Code | Description | Schema |
|
||||
| ---- | ----------- | ------ |
|
||||
| 200 | Update market. | [Market](#market) |
|
||||
|
||||
### Models
|
||||
|
||||
#### Beneficiary
|
||||
|
||||
Get list of user beneficiaries
|
||||
|
||||
| Name | Type | Description | Required |
|
||||
| ---- | ---- | ----------- | -------- |
|
||||
| id | integer | Beneficiary Identifier in Database | No |
|
||||
| currency | string | Beneficiary currency code. | No |
|
||||
| uid | string | Beneficiary owner | No |
|
||||
| name | string | Human rememberable name which refer beneficiary. | No |
|
||||
| description | string | Human rememberable description of beneficiary. | No |
|
||||
| data | json | Bank Account details for fiat Beneficiary in JSON format.For crypto it's blockchain address. | No |
|
||||
| state | string | Defines either beneficiary active - user can use it to withdraw moneyor pending - requires beneficiary activation with pin. | No |
|
||||
| sent_at | string | Time when last pin was sent | No |
|
||||
|
||||
#### Balance
|
||||
|
||||
Queries the account balance for the given UID and currency.
|
||||
|
||||
| Name | Type | Description | Required |
|
||||
| ---- | ---- | ----------- | -------- |
|
||||
| uid | string | The shared user ID. | No |
|
||||
| balance | string | The account balance. | No |
|
||||
| locked | string | The locked account balance. | No |
|
||||
|
||||
#### Deposit
|
||||
|
||||
Returns deposits as paginated collection.
|
||||
|
||||
| Name | Type | Description | Required |
|
||||
| ---- | ---- | ----------- | -------- |
|
||||
| tid | integer | The shared transaction ID. | No |
|
||||
| currency | string | The currency code. | No |
|
||||
| uid | string | The shared user ID. | No |
|
||||
| type | string | The deposit type (fiat or coin). | No |
|
||||
| amount | string | The deposit amount. | No |
|
||||
| state | string | The deposit state. «submitted» – initial state. «canceled» – deposit has been canceled by outer service. «rejected» – deposit has been rejected by outer service.. «accepted» – deposit has been accepted by outer service, money are loaded. | No |
|
||||
| created_at | string | The datetime when deposit was created. | No |
|
||||
| completed_at | string | The datetime when deposit was completed. | No |
|
||||
| blockchain_txid | string | The transaction ID on the Blockchain (coin only). | No |
|
||||
| blockchain_confirmations | string | The number of transaction confirmations on the Blockchain (coin only). | No |
|
||||
| transfer_type | string | deposit transfer_type. | No |
|
||||
|
||||
#### Withdraw
|
||||
|
||||
Returns withdraws as paginated collection.
|
||||
|
||||
| Name | Type | Description | Required |
|
||||
| ---- | ---- | ----------- | -------- |
|
||||
| tid | integer | The shared transaction ID. | No |
|
||||
| uid | string | The shared user ID. | No |
|
||||
| currency | string | The currency code. | No |
|
||||
| note | string | The note for withdraw. | No |
|
||||
| type | string | The withdraw type (fiat or coin). | No |
|
||||
| amount | string | The withdraw amount excluding fee. | No |
|
||||
| fee | string | The exchange fee. | No |
|
||||
| rid | string | The beneficiary ID or wallet address on the Blockchain. | No |
|
||||
| state | string | The withdraw state. «prepared» – initial state, money are not locked. «submitted» – withdraw has been allowed by outer service for further validation, money are locked. «canceled» – withdraw has been canceled by outer service, money are unlocked. «accepted» – system has validated withdraw and queued it for processing by worker, money are locked. «rejected» – system has validated withdraw and found errors, money are unlocked. «processing» – worker is processing withdraw as the current moment, money are locked. «skipped» – worker skipped withdrawal in case of insufficient balance of hot wallet or it absence. «succeed» – worker has successfully processed withdraw, money are subtracted from the account. «failed» – worker has encountered an unhandled error while processing withdraw, money are unlocked. | No |
|
||||
| created_at | string | The datetime when withdraw was created. | No |
|
||||
| blockchain_txid | string | The transaction ID on the Blockchain (coin only). | No |
|
||||
| transfer_type | string | withdraw transfer_type. | No |
|
||||
|
||||
#### Operation
|
||||
|
||||
Returns liabilities as paginated collection.
|
||||
|
||||
| Name | Type | Description | Required |
|
||||
| ---- | ---- | ----------- | -------- |
|
||||
| code | string | The Account code which this operation related to. | No |
|
||||
| currency | string | Operation currency ID. | No |
|
||||
| credit | string | Operation credit amount. | No |
|
||||
| debit | string | Operation debit amount. | No |
|
||||
| uid | string | The shared user ID. | No |
|
||||
| reference_type | string | The type of operations. | No |
|
||||
| created_at | string | The datetime when operation was created. | No |
|
||||
|
||||
#### Order
|
||||
|
||||
Returns orders
|
||||
|
||||
| Name | Type | Description | Required |
|
||||
| ---- | ---- | ----------- | -------- |
|
||||
| id | integer | Unique order id. | No |
|
||||
| member_id | integer | Member id. | No |
|
||||
| uuid | string | Unique order UUID. | No |
|
||||
| side | string | Either 'sell' or 'buy'. | No |
|
||||
| ord_type | string | Type of order, either 'limit' or 'market'. | No |
|
||||
| price | double | Price for each unit. e.g.If you want to sell/buy 1 btc at 3000 usd, the price is '3000.0' | No |
|
||||
| avg_price | double | Average execution price, average of price in trades. | No |
|
||||
| state | string | One of 'wait', 'done', or 'cancel'.An order in 'wait' is an active order, waiting fulfillment;a 'done' order is an order fulfilled;'cancel' means the order has been canceled. | No |
|
||||
| market | string | The market in which the order is placed, e.g. 'btcusd'.All available markets can be found at /api/v2/markets. | No |
|
||||
| created_at | string | Order create time in iso8601 format. | No |
|
||||
| updated_at | string | Order updated time in iso8601 format. | No |
|
||||
| origin_volume | double | The amount user want to sell/buy.An order could be partially executed,e.g. an order sell 5 btc can be matched with a buy 3 btc order,left 2 btc to be sold; in this case the order's volume would be '5.0',its remaining_volume would be '2.0', its executed volume is '3.0'. | No |
|
||||
| remaining_volume | double | The remaining volume, see 'volume'. | No |
|
||||
| executed_volume | double | The executed volume, see 'volume'. | No |
|
||||
| maker_fee | double | Fee for maker. | No |
|
||||
| taker_fee | double | Fee for taker. | No |
|
||||
| trades_count | integer | Count of trades. | No |
|
||||
| trades | [ [Trade](#trade) ] | Trades wiht this order. | No |
|
||||
|
||||
#### Trade
|
||||
|
||||
Returns trades as paginated collection.
|
||||
|
||||
| Name | Type | Description | Required |
|
||||
| ---- | ---- | ----------- | -------- |
|
||||
| id | string | Trade ID. | No |
|
||||
| price | double | Trade price. | No |
|
||||
| amount | double | Trade amount. | No |
|
||||
| total | double | Trade total (Amount * Price). | No |
|
||||
| fee_currency | double | Currency user's fees were charged in. | No |
|
||||
| fee | double | Percentage of fee user was charged for performed trade. | No |
|
||||
| fee_amount | double | Amount of fee user was charged for performed trade. | No |
|
||||
| market | string | Trade market id. | No |
|
||||
| created_at | string | Trade create time in iso8601 format. | No |
|
||||
| taker_type | string | Trade taker order type (sell or buy). | No |
|
||||
| side | string | Trade side. | No |
|
||||
| order_id | integer | Order id. | No |
|
||||
|
||||
#### Currency
|
||||
|
||||
Return currencies list.
|
||||
|
||||
| Name | Type | Description | Required |
|
||||
| ---- | ---- | ----------- | -------- |
|
||||
| id | string | Currency code.<br>_Example:_ `"btc"` | No |
|
||||
| name | string | Currency name<br>_Example:_ `"Bitcoin"` | No |
|
||||
| description | string | Currency description<br>_Example:_ `"btc"` | No |
|
||||
| homepage | string | Currency homepage<br>_Example:_ `"btc"` | No |
|
||||
| price | string | Currency current price | No |
|
||||
| explorer_transaction | string | Currency transaction exprorer url template<br>_Example:_ `"https://testnet.blockchain.info/tx/"` | No |
|
||||
| explorer_address | string | Currency address exprorer url template<br>_Example:_ `"https://testnet.blockchain.info/address/"` | No |
|
||||
| type | string | Currency type<br>_Example:_ `"coin"` | No |
|
||||
| deposit_enabled | string | Currency deposit possibility status (true/false). | No |
|
||||
| withdrawal_enabled | string | Currency withdrawal possibility status (true/false). | No |
|
||||
| deposit_fee | string | Currency deposit fee<br>_Example:_ `"0.0"` | No |
|
||||
| min_deposit_amount | string | Minimal deposit amount<br>_Example:_ `"0.0000356"` | No |
|
||||
| withdraw_fee | string | Currency withdraw fee<br>_Example:_ `"0.0"` | No |
|
||||
| min_withdraw_amount | string | Minimal withdraw amount<br>_Example:_ `"0.0"` | No |
|
||||
| withdraw_limit_24h | string | Currency 24h withdraw limit<br>_Example:_ `"0.1"` | No |
|
||||
| withdraw_limit_72h | string | Currency 72h withdraw limit<br>_Example:_ `"0.2"` | No |
|
||||
| base_factor | string | Currency base factor<br>_Example:_ `100000000` | No |
|
||||
| precision | string | Currency precision<br>_Example:_ `8` | No |
|
||||
| position | integer | Currency position. | No |
|
||||
| icon_url | string | Currency icon<br>_Example:_ `"https://upload.wikimedia.org/wikipedia/commons/0/05/Ethereum_logo_2014.svg"` | No |
|
||||
| min_confirmations | string | Number of confirmations required for confirming deposit or withdrawal | No |
|
||||
| code | string | Unique currency code. | No |
|
||||
| min_collection_amount | string | Minimal deposit amount that will be collected<br>_Example:_ `"0.0000356"` | No |
|
||||
| visible | string | Currency display possibility status (true/false). | No |
|
||||
| subunits | integer | Fraction of the basic monetary unit. | No |
|
||||
| options | json | Currency options. | No |
|
||||
| created_at | string | Currency created time in iso8601 format. | No |
|
||||
| updated_at | string | Currency updated time in iso8601 format. | No |
|
||||
|
||||
#### Market
|
||||
|
||||
Update market.
|
||||
|
||||
| Name | Type | Description | Required |
|
||||
| ---- | ---- | ----------- | -------- |
|
||||
| id | string | Unique market id. It's always in the form of xxxyyy,where xxx is the base currency code, yyy is the quotecurrency code, e.g. 'btcusd'. All available markets canbe found at /api/v2/markets. | No |
|
||||
| name | string | Market name. | No |
|
||||
| base_unit | string | Market Base unit. | No |
|
||||
| quote_unit | string | Market Quote unit. | No |
|
||||
| min_price | double | Minimum order price. | No |
|
||||
| max_price | double | Maximum order price. | No |
|
||||
| min_amount | double | Minimum order amount. | No |
|
||||
| amount_precision | double | Precision for order amount. | No |
|
||||
| price_precision | double | Precision for order price. | No |
|
||||
| state | string | Market state defines if user can see/trade on current market. | No |
|
||||
| position | integer | Market position. | No |
|
||||
| created_at | string | Market created time in iso8601 format. | No |
|
||||
| updated_at | string | Market updated time in iso8601 format. | No |
|
||||
1187
docs/api/peatio_user_api_v2.md
Normal file
1187
docs/api/peatio_user_api_v2.md
Normal file
File diff suppressed because it is too large
Load Diff
1701
docs/api/swagger.json
Normal file
1701
docs/api/swagger.json
Normal file
File diff suppressed because it is too large
Load Diff
6048
docs/api/swagger/admin_api.json
Normal file
6048
docs/api/swagger/admin_api.json
Normal file
File diff suppressed because it is too large
Load Diff
2851
docs/api/swagger/management_api.json
Normal file
2851
docs/api/swagger/management_api.json
Normal file
File diff suppressed because it is too large
Load Diff
3103
docs/api/swagger/user_api.json
Normal file
3103
docs/api/swagger/user_api.json
Normal file
File diff suppressed because it is too large
Load Diff
390
docs/api/trading_api.md
Normal file
390
docs/api/trading_api.md
Normal file
@@ -0,0 +1,390 @@
|
||||
# Peatio REST API
|
||||
|
||||
Peatio REST API allows to access market data and manage trades using the custom-written software. The end goal is to allow users to create trading platforms on their own to create highly customised and advanced trading strategies.
|
||||
|
||||
## General API Information
|
||||
|
||||
### HTTP Return Codes
|
||||
|
||||
- HTTP 4XX return codes are used for malformed requests; the issue is on the sender's side.
|
||||
- HTTP 403 return code is used when the WAF Limit (Web Application Firewall) has been violated.
|
||||
- HTTP 429 return code is used when breaking a request rate limit.
|
||||
- HTTP 5XX return codes are used for internal errors; the issue is on deployment side. It is important to NOT treat this as a failure operation; the execution status is UNKNOWN and could have been a success.
|
||||
|
||||
### General Information on Endpoints
|
||||
|
||||
- All endpoints return either a JSON object or array.
|
||||
- All time and timestamp related fields are in seconds.
|
||||
|
||||
### Endpoint security types
|
||||
|
||||
REST endpoints fall into two types the difference between the two being if the request is public, or requires authentication. In order to access the parts of the API which require authentication, you can use cookies or generate an API key and an API secret.
|
||||
|
||||
#### List of all user API endpoints you can find here ([user_api_docs](https://github.com/openware/peatio/blob/master/docs/api/peatio_user_api_v2.md))
|
||||
|
||||
#### Prerequisites
|
||||
|
||||
- install [httpie](https://httpie.org/doc#installation)
|
||||
- install [curl](https://www.tecmint.com/install-curl-in-linux/)
|
||||
|
||||
## Public Endpoints Examples
|
||||
|
||||
Get list of avaliable currencies:
|
||||
|
||||
Example with httpie:
|
||||
|
||||
```bash
|
||||
http GET https://your.domain/api/v2/peatio/public/markets
|
||||
```
|
||||
|
||||
Expected response:
|
||||
|
||||
```json
|
||||
[
|
||||
{
|
||||
"amount_precision": 5,
|
||||
"base_unit": "eth",
|
||||
"id": "ethusdt",
|
||||
"max_price": "1000.0",
|
||||
"min_amount": "0.00001",
|
||||
"min_price": "0.01",
|
||||
"name": "ETH/USDT",
|
||||
"price_precision": 2,
|
||||
"quote_unit": "usdt",
|
||||
"state": "enabled"
|
||||
},
|
||||
{
|
||||
"amount_precision": 6,
|
||||
"base_unit": "btc",
|
||||
"id": "btcusdt",
|
||||
"max_price": "12000.0",
|
||||
"min_amount": "0.0001",
|
||||
"min_price": "5000.0",
|
||||
"name": "BTC/USDT",
|
||||
"price_precision": 4,
|
||||
"quote_unit": "usdt",
|
||||
"state": "enabled"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
Example with curl:
|
||||
|
||||
```bash
|
||||
curl -X GET https://your.domain/api/v2/peatio/public/markets
|
||||
```
|
||||
|
||||
Expected response:
|
||||
|
||||
```bash
|
||||
[
|
||||
{
|
||||
"amount_precision": 5,
|
||||
"base_unit": "eth",
|
||||
"id": "ethusdt",
|
||||
"max_price": "1000.0",
|
||||
"min_amount": "0.00001",
|
||||
"min_price": "0.01",
|
||||
"name": "ETH/USDT",
|
||||
"price_precision": 2,
|
||||
"quote_unit": "usdt",
|
||||
"state": "enabled"
|
||||
},
|
||||
{
|
||||
"amount_precision": 6,
|
||||
"base_unit": "btc",
|
||||
"id": "btcusdt",
|
||||
"max_price": "12000.0",
|
||||
"min_amount": "0.0001",
|
||||
"min_price": "5000.0",
|
||||
"name": "BTC/USDT",
|
||||
"price_precision": 4,
|
||||
"quote_unit": "usdt",
|
||||
"state": "enabled"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
## Authentication
|
||||
|
||||
For get access to private endpoints you can use cookies or generate API keys via UI (highly recommended) or API.
|
||||
|
||||
### Authentication with cookies (more for test purposes)
|
||||
|
||||
1. Create and save session cookies using httpie
|
||||
|
||||
```bash
|
||||
http --session barong_session https://your.domain/api/v2/barong/identity/sessions \
|
||||
email=your@email.com password=changeme
|
||||
```
|
||||
|
||||
2. Call private endpoint with created session
|
||||
|
||||
```bash
|
||||
http --session barong_session https://your.domain.com/api/v2/peatio/account/balances
|
||||
```
|
||||
|
||||
Expected response:
|
||||
|
||||
```bash
|
||||
[
|
||||
{
|
||||
"balance": "1.4995",
|
||||
"currency": "eth",
|
||||
"locked": "0.0"
|
||||
},
|
||||
{
|
||||
"balance": "99.0",
|
||||
"currency": "usd",
|
||||
"locked": "0.0"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
### Authentication with API keys
|
||||
|
||||
#### How to create API key?
|
||||
|
||||
1. Using UI
|
||||
|
||||
1. Enable 2FA
|
||||
2. Find API keys section (often located on profile page).
|
||||
3. Create your API key and securely save API Key and Secret
|
||||
|
||||
2. Using API (use this option in case your frontend doesn't support API keys feature)
|
||||
|
||||
1. Login into your account using httpie
|
||||
|
||||
```bash
|
||||
http --session barong_session https://your.domain/api/v2/barong/identity/sessions \
|
||||
email=your@email.com password=changeme otp_code=000000
|
||||
```
|
||||
|
||||
2. Create your API key
|
||||
|
||||
```bash
|
||||
http --session barong_session https://your.domain.com/api/v2/barong/resource/api_keys \
|
||||
algorithm=HS256 totp_code=681757
|
||||
```
|
||||
|
||||
Expected response:
|
||||
|
||||
```ruby
|
||||
{
|
||||
"algorithm": "HS256",
|
||||
"created_at": "2019-12-23T12:22:15Z",
|
||||
"kid": "61d025b8573501c2", # API Key
|
||||
"scope": [],
|
||||
"secret": {
|
||||
"auth": null,
|
||||
"data": {
|
||||
"value": "2d0b4979c7fe6986daa8e21d1dc0644f" # Secret
|
||||
},
|
||||
"lease_duration": 2764800,
|
||||
"lease_id": "",
|
||||
"metadata": null,
|
||||
"renewable": false,
|
||||
"warnings": null,
|
||||
"wrap_info": null
|
||||
},
|
||||
"state": "active",
|
||||
"updated_at": "2019-12-23T12:22:15Z"
|
||||
}
|
||||
```
|
||||
|
||||
3. Securely save API Key and Secret
|
||||
|
||||
#### How to use API key?
|
||||
|
||||
Before calling private endpoint you will need to generate three headers:
|
||||
|
||||
`X-Auth-Apikey` - API key (from previous step)
|
||||
|
||||
`X-Auth-Nonce` - A nonce is an arbitrary number that can be used just once. In our environment you *MUST* use a millisecond timestamp in UTC time. Read more about it [here](https://en.wikipedia.org/wiki/Cryptographic_nonce).
|
||||
|
||||
```bash
|
||||
date +%s%3N
|
||||
1584087661035
|
||||
```
|
||||
|
||||
`X-Auth-Signature` - HMAC-SHA256 signature calculated using concatenation of X-Auth-Nonce and X-Auth-Apikey
|
||||
|
||||
```ruby
|
||||
require 'openssl'
|
||||
|
||||
nonce = '1584087661035'
|
||||
api_key = 'changeme' # API Key from 'How to create API key section ?'
|
||||
secret = 'changeme' # Secret from 'How to create API key section ?'
|
||||
OpenSSL::HMAC.hexdigest("SHA256", secret, nonce + api_key)
|
||||
# => "6cc108cb3427b655ccf0870fc7fa807ef3756506d4db3f3c93f8d4cd8ef0e611"
|
||||
```
|
||||
|
||||
```bash
|
||||
curl -X GET https://your.domain.com/api/v2/peatio/account/balances \
|
||||
-H "X-Auth-Apikey: changeme" \
|
||||
-H "X-Auth-Nonce: changeme" \
|
||||
-H "X-Auth-Signature: changeme"
|
||||
```
|
||||
|
||||
Expected response:
|
||||
|
||||
```bash
|
||||
[
|
||||
{
|
||||
"balance": "1.4995",
|
||||
"currency": "eth",
|
||||
"locked": "0.0"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
Expected response:
|
||||
|
||||
```bash
|
||||
curl -X GET https://your.domain.com/api/v2/peatio/market/orders \
|
||||
-H "X-Auth-Apikey: changeme" \
|
||||
-H "X-Auth-Nonce: changeme" \
|
||||
-H "X-Auth-Signature: changeme"
|
||||
```
|
||||
|
||||
```bash
|
||||
[
|
||||
{
|
||||
"avg_price": "168.0",
|
||||
"created_at": "2020-01-28T15:14:02+01:00",
|
||||
"executed_volume": "0.1",
|
||||
"id": 6291918,
|
||||
"market": "ethusd",
|
||||
"ord_type": "limit",
|
||||
"origin_volume": "0.1",
|
||||
"price": "168.0",
|
||||
"remaining_volume": "0.0",
|
||||
"side": "buy",
|
||||
"state": "done",
|
||||
"trades_count": 1,
|
||||
"updated_at": "2020-03-12T09:17:32+01:00"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
## Step By step guide from authentication to create | cancel order with API keys
|
||||
|
||||
1. Generate API keys (see Authentication with API keys section)
|
||||
|
||||
2. Create order
|
||||
|
||||
```bash
|
||||
http POST https://your.domain.com/api/v2/peatio/market/orders \
|
||||
"X-Auth-Apikey: changeme" \
|
||||
"X-Auth-Nonce: changeme" \
|
||||
"X-Auth-Signature: changeme" \
|
||||
market=ethusd side=buy volume=31 ord_type=limit price=160.82
|
||||
```
|
||||
|
||||
Expected response:
|
||||
|
||||
```bash
|
||||
{
|
||||
"avg_price": "0.0",
|
||||
"created_at": "2020-03-12T17:01:56+01:00",
|
||||
"executed_volume": "0.0",
|
||||
"id": 10440269,
|
||||
"market": "ethusd",
|
||||
"ord_type": "limit",
|
||||
"origin_volume": "31.0",
|
||||
"price": "160.82",
|
||||
"remaining_volume": "31.0",
|
||||
"side": "buy",
|
||||
"state": "pending",
|
||||
"trades_count": 0,
|
||||
"updated_at": "2020-03-12T17:01:56+01:00"
|
||||
}
|
||||
```
|
||||
|
||||
3. Check trade history
|
||||
|
||||
```bash
|
||||
http POST https://your.domain.com/api/v2/peatio/market/trades \
|
||||
"X-Auth-Apikey: changeme" \
|
||||
"X-Auth-Nonce: changeme" \
|
||||
"X-Auth-Signature: changeme" \
|
||||
```
|
||||
|
||||
Expected response:
|
||||
|
||||
```bash
|
||||
{
|
||||
"amount": "5.0",
|
||||
"created_at": "2020-03-12T17:01:56+01:00",
|
||||
"fee": "0.002",
|
||||
"fee_amount": "0.01",
|
||||
"fee_currency": "eth",
|
||||
"id": 1834499,
|
||||
"market": "ethusd",
|
||||
"order_id": 10440269,
|
||||
"price": "160.82",
|
||||
"side": "buy",
|
||||
"taker_type": "buy",
|
||||
"total": "804.1"
|
||||
}
|
||||
```
|
||||
|
||||
4. Check active orders
|
||||
|
||||
```bash
|
||||
curl -X GET https://your.domain.com/api/v2/peatio/market/orders\?state\=wait \
|
||||
-H "X-Auth-Apikey: changeme" \
|
||||
-H "X-Auth-Nonce: changeme" \
|
||||
-H "X-Auth-Signature: changeme"
|
||||
```
|
||||
|
||||
Expected response:
|
||||
|
||||
```bash
|
||||
[
|
||||
{
|
||||
"avg_price": "160.82",
|
||||
"created_at": "2020-03-12T17:01:56+01:00",
|
||||
"executed_volume": "26.35649",
|
||||
"id": 10440269,
|
||||
"market": "ethusd",
|
||||
"ord_type": "limit",
|
||||
"origin_volume": "31.0",
|
||||
"price": "160.82",
|
||||
"remaining_volume": "4.64351",
|
||||
"side": "buy",
|
||||
"state": "wait",
|
||||
"trades_count": 6,
|
||||
"updated_at": "2020-03-12T17:01:56+01:00"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
5. Cancel active order
|
||||
|
||||
```bash
|
||||
curl -X GET https://your.domain.com/api/v2/peatio/market/orders/10440269/cancel \
|
||||
-H "X-Auth-Apikey: changeme" \
|
||||
-H "X-Auth-Nonce: changeme" \
|
||||
-H "X-Auth-Signature: changeme"
|
||||
```
|
||||
|
||||
Expected response
|
||||
|
||||
```bash
|
||||
{
|
||||
"avg_price": "160.82",
|
||||
"created_at": "2020-03-12T17:01:56+01:00",
|
||||
"executed_volume": "26.35649",
|
||||
"id": 10440269,
|
||||
"market": "ethusd",
|
||||
"ord_type": "limit",
|
||||
"origin_volume": "31.0",
|
||||
"price": "160.82",
|
||||
"remaining_volume": "4.64351",
|
||||
"side": "buy",
|
||||
"state": "wait",
|
||||
"trades_count": 6,
|
||||
"updated_at": "2020-03-12T17:01:56+01:00"
|
||||
}
|
||||
```
|
||||
293
docs/api/websocket_api.md
Normal file
293
docs/api/websocket_api.md
Normal file
@@ -0,0 +1,293 @@
|
||||
# Peatio WebSocket API
|
||||
|
||||
Peatio WebSocket API connections are handled by Ranger service provided by
|
||||
[peatio gem](https://github.com/rubykube/peatio-core).
|
||||
|
||||
### API
|
||||
|
||||
There are two types of channels:
|
||||
* Public: accessible by anyone
|
||||
* Private: accessible only by given member
|
||||
|
||||
GET request parameters:
|
||||
|
||||
| Field | Description | Multiple allowed |
|
||||
|----------|-------------------------------------|------------------|
|
||||
| `stream` | List of streams to be subscribed on | Yes |
|
||||
|
||||
List of supported public streams:
|
||||
* [`<market>.ob-inc`](#order-book) market order-book update
|
||||
* [`<market>.trades` ](#trades)
|
||||
* [`<market>.kline-PERIOD` ](#kline-point) (available periods are "1m", "5m", "15m", "30m", "1h", "2h", "4h", "6h", "12h", "1d", "3d", "1w")
|
||||
* [`global.tickers`](#tickers)
|
||||
|
||||
List of supported private streams (requires authentication):
|
||||
* [`order`](#order)
|
||||
* [`trade`](#trade)
|
||||
|
||||
You can find a format of these events below in the doc.
|
||||
|
||||
### Authentication
|
||||
|
||||
Authentication happens on websocket message with following JSON structure.
|
||||
|
||||
```JSON
|
||||
{
|
||||
"jwt": "Bearer <Token>"
|
||||
}
|
||||
```
|
||||
|
||||
If authentication was done, server will respond successfully
|
||||
|
||||
```JSON
|
||||
{
|
||||
"success": {
|
||||
"message": "Authenticated."
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Otherwise server will return an error
|
||||
|
||||
```JSON
|
||||
{
|
||||
"error": {
|
||||
"message": "Authentication failed."
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
If authentication JWT token has invalid type, server return an error
|
||||
|
||||
```JSON
|
||||
{
|
||||
"error": {
|
||||
"message": "Token type is not provided or invalid."
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
If other error occurred during the message handling server throws an error
|
||||
|
||||
```JSON
|
||||
{
|
||||
"error": {
|
||||
"message": "Error while handling message."
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Note:** Peatio websocket API supports authentication only Bearer type of JWT token.
|
||||
|
||||
**Example** of authentication message:
|
||||
|
||||
```JSON
|
||||
{
|
||||
"jwt": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ"
|
||||
}
|
||||
```
|
||||
|
||||
### Streams subscription
|
||||
|
||||
#### Using parameters
|
||||
|
||||
You can specify streams to subscribe to by passing the `stream` GET parameter in the connection URL. The parameter can be specified multiple times for subscribing to multiple streams.
|
||||
|
||||
example:
|
||||
|
||||
```
|
||||
wss://demo.openware.com/api/v2/ranger/public/?stream=global.tickers&stream=ethusd.trades
|
||||
```
|
||||
|
||||
This will subscribe you to *tickers* and *trades* events from *ethusd* market once the connection is established.
|
||||
|
||||
#### Subscribe and unsubscribe events
|
||||
You can manage the connection subscriptions by send the following events after the connection is established:
|
||||
|
||||
Subscribe event will subscribe you to the list of streams provided:
|
||||
|
||||
```json
|
||||
{"event":"subscribe","streams":["ethusd.trades","ethusd.ob-inc"]}
|
||||
```
|
||||
|
||||
The server confirms the subscription with the following message and provides the new list of your current subscrictions:
|
||||
|
||||
```json
|
||||
{"success":{"message":"subscribed","streams":["global.tickers","ethusd.trades","ethusd.ob-inc"]}}
|
||||
```
|
||||
|
||||
Unsubscribe event will unsubscribe you to the list of streams provided:
|
||||
|
||||
```json
|
||||
{"event":"unsubscribe","streams":["ethusd.trades","ethusd.ob-inc"]}
|
||||
```
|
||||
|
||||
The server confirms the unsubscription with the following message and provides the new list of your current subscrictions:
|
||||
|
||||
```json
|
||||
{"success":{"message":"unsubscribed","streams":["global.tickers","ethusd.kline-15m"]}}
|
||||
```
|
||||
|
||||
|
||||
### Public streams
|
||||
|
||||
#### Order-Book
|
||||
|
||||
This stream sends a snapshot of the order-book at the subscription time, then it sends increments. Volumes information in increments replace the previous values. If the volume is zero the price point should be removed from the order-book.
|
||||
|
||||
Register to stream `<market>.ob-inc` to receive snapshot and increments messages.
|
||||
|
||||
Example of order-book snapshot:
|
||||
|
||||
```json
|
||||
{
|
||||
"eurusd.ob-snap":{
|
||||
"asks":[
|
||||
["15.0","21.7068"],
|
||||
["20.0","100.2068"],
|
||||
["20.5","30.2068"],
|
||||
["30.0","21.2068"]
|
||||
],
|
||||
"bids":[
|
||||
["10.95","21.7068"],
|
||||
["10.90","65.2068"],
|
||||
["10.85","55.2068"],
|
||||
["10.70","30.2068"]
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
Example of order-book increment message:
|
||||
|
||||
```json
|
||||
{
|
||||
"eurusd.ob-inc":{
|
||||
"asks":[
|
||||
["15.0","22.1257"]
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
#### Trades
|
||||
|
||||
Here is structure of `<market>.trades` event expose as array with trades:
|
||||
|
||||
| Field | Description |
|
||||
| -------------- | -------------------------------------------- |
|
||||
| `tid` | Unique trade tid. |
|
||||
| `taker_type` | Taker type of trade, either `buy` or `sell`. |
|
||||
| `price` | Price for the trade. |
|
||||
| `amount` | The amount of trade. |
|
||||
| `created_at` | Trade create time. |
|
||||
|
||||
#### Kline point
|
||||
|
||||
Kline point as array of numbers:
|
||||
|
||||
1. Timestamp.
|
||||
2. Open price.
|
||||
3. Max price.
|
||||
4. Min price.
|
||||
5. Last price.
|
||||
6. Period volume
|
||||
|
||||
Example:
|
||||
|
||||
```ruby
|
||||
[1537370580, 0.0839, 0.0921, 0.0781, 0.0845, 0.5895]
|
||||
```
|
||||
|
||||
|
||||
#### Tickers
|
||||
|
||||
Here is structure of `global.tickers` event expose as array with all markets pairs:
|
||||
|
||||
| Field | Description |
|
||||
| -----------------------| ------------------------------- |
|
||||
| `at` | Date of current ticker. |
|
||||
| `name` | Market pair name. |
|
||||
| `base_unit` | Base currency. |
|
||||
| `quote_unit` | Quote currency. |
|
||||
| `low` | Lowest price in 24 hours. |
|
||||
| `high` | Highest price in 24 hours. |
|
||||
| `last` | Last trade price. |
|
||||
| `open` | Last trade from last timestamp. |
|
||||
| `close` | Last trade price. |
|
||||
| `volume` | Volume in 24 hours. |
|
||||
| `sell` | Best price per unit. |
|
||||
| `buy` | Best price per unit. |
|
||||
| `avg_price` | Average price for last 24 hours.|
|
||||
| `price_change_percent` | Average price change in percent.|
|
||||
|
||||
### Private streams
|
||||
|
||||
#### Order
|
||||
|
||||
Here is structure of `Order` event:
|
||||
|
||||
| Field | Description |
|
||||
| ------------------ | ------------------------------------------------------------ |
|
||||
| `id` | Unique order id. |
|
||||
| `market` | The market in which the order is placed. (In peatio `market_id`) |
|
||||
| `order_type` | Order type, either `limit` or `market`. |
|
||||
| `price` | Order price. |
|
||||
| `avg_price` | Order average price. |
|
||||
| `state` | One of `wait`, `done`, `reject` or `cancel`. |
|
||||
| `origin_volume` | The amount user want to sell/buy. |
|
||||
| `remaining_volume` | Remaining amount user want to sell/buy. |
|
||||
| `executed_volume` | Executed amount for current order. |
|
||||
| `created_at` | Order create time. |
|
||||
| `updated_at` | Order create time. |
|
||||
| `trades_count` | Trades with this order. |
|
||||
| `kind` | Type of order, either `bid` or `ask`. (Deprecated) |
|
||||
| `at` | Order create time. (Deprecated) (In peatio `created_at`) |
|
||||
|
||||
#### Trade
|
||||
|
||||
Here is structure of `Trade` event:
|
||||
|
||||
| Field | Description |
|
||||
| ------------ | ------------------------------------------------------------ |
|
||||
| `id` | Unique trade identifier. |
|
||||
| `price` | Price for each unit. |
|
||||
| `amount` | The amount of trade. |
|
||||
| `total` | The total of trade (volume * price). |
|
||||
| `market` | The market in which the trade is placed. (In peatio market_id) |
|
||||
| `side` | Type of order in trade that related to current user `sell` or `buy`. |
|
||||
| `taker_type` | Order side of the taker for the trade, either `buy` or `sell`. |
|
||||
| `created_at` | Trade create time. |
|
||||
| `order_id` | User order identifier in trade. |
|
||||
|
||||
|
||||
### Development
|
||||
|
||||
Start ranger websocket server using following command in peatio-core gem:
|
||||
|
||||
```bash
|
||||
$ ./bin/peatio service start ranger
|
||||
```
|
||||
|
||||
Now we can test authentication with [wscat](https://github.com/websockets/wscat):
|
||||
|
||||
#### Connect to public channel:
|
||||
|
||||
```bash
|
||||
$ wscat -n -c 'ws://ws.app.local:8080/api/ranger/v2?stream=usdeth'
|
||||
```
|
||||
|
||||
#### Connect to private channel:
|
||||
|
||||
Authorization header will be injected automatically by ambassador so we could subscribe to private channels.
|
||||
```bash
|
||||
$ wscat -n -c 'ws://ws.app.local:8080/api/ranger/v2?stream=trade'
|
||||
```
|
||||
|
||||
### Examples
|
||||
|
||||
There is also [example of working with Ranger service using NodeJS.](https://github.com/rubykube/ranger-example-nodejs)
|
||||
Reference in New Issue
Block a user