Class: Cryptomarket::Client
- Inherits:
-
Object
- Object
- Cryptomarket::Client
- Defined in:
- lib/cryptomarket/client.rb
Overview
Creates a new rest client
Params
Stringapi_key-
the user api key
Stringapi_secret-
the user api secret
Integerwindow-
Maximum difference between the creation of the request and the moment of request processing in milliseconds. Max is 60_000. Defaul is 10_000
Instance Method Summary collapse
-
#activate_sub_accounts(sub_account_ids:) ⇒ Object
Activates sub-accounts listed.
-
#cancel_all_spot_orders ⇒ Object
Cancel all active spot orders.
-
#cancel_spot_order(client_order_id:) ⇒ Object
Cancel the order with the client order id.
-
#change_acl_settings(sub_account_ids:, deposit_address_generation_enabled: nil, withdraw_enabled: nil, description: nil, created_at: nil, updated_at: nil) ⇒ Object
Returns a list of withdrawal settings for sub-accounts listed.
-
#change_credentials(api_key:, api_secret:) ⇒ Object
Changes the user credentials used for authentication in calls.
-
#change_window(window:) ⇒ Object
Changes the window used in authenticated calls.
-
#convert_between_currencies(from_currency:, to_currency:, amount:) ⇒ Object
Converts between currencies Successful response to the request does not necessarily mean the resulting transaction got executed immediately.
-
#create_deposit_crypto_address(currency:, network_code: nil) ⇒ Object
Creates a new address for a currency.
-
#create_spot_order(symbol:, side:, quantity:, client_order_id: nil, type: nil, time_in_force: nil, price: nil, stop_price: nil, expire_time: nil, strict_validate: nil, post_only: nil, take_rate: nil, make_rate: nil) ⇒ Object
Creates a new spot order For fee, for price accuracy and quantity, and for order status information see the api docs.
-
#create_spot_order_list(contingency_type:, orders:, order_list_id: nil) ⇒ Object
creates a list of spot orders.
-
#crypto_address_belongs_to_current_account?(address:) ⇒ Boolean
Check if an address is from this account.
- #delete(endpoint, params = nil) ⇒ Object
-
#freeze_sub_accounts(sub_account_ids:) ⇒ Object
Freezes sub-accounts listed Sub-accounts frozen wouldn’t be able to: * login * withdraw funds * trade * complete pending orders * use API keys.
- #get(endpoint, params = nil) ⇒ Object
-
#get_acl_settings(sub_account_ids:) ⇒ Object
Returns a list of withdrawal settings for sub-accounts listed.
-
#get_active_spot_order(client_order_id:) ⇒ Object
Get an active spot order by its client order id.
-
#get_all_active_spot_orders(symbol: nil) ⇒ Object
Get the user’s active spot orders.
-
#get_all_trading_commission ⇒ Object
(also: #get_all_trading_commissions, #get_trading_commissions)
Get the personal trading commission rates for all symbols.
-
#get_amount_locks(currency: nil, active: nil, limit: nil, offset: nil, from: nil, till: nil) ⇒ Object
Get the list of amount locks.
-
#get_bulk_estimate_withdrawal_fees(fee_requests:) ⇒ Object
Get an estimates for withdrawal fees of currencies.
-
#get_candles(symbols: nil, period: nil, sort: nil, from: nil, till: nil, limit: nil, offset: nil) ⇒ Object
Get a Hash of candles for all symbols or for specified symbols Candles are used for OHLC representation The result contains candles with non-zero volume only (no trades = no candles).
-
#get_candles_by_symbol(symbol:, period: nil, sort: nil, from: nil, till: nil, limit: nil, offset: nil) ⇒ Object
(also: #get_candles_of_symbol)
Get candles of a symbol Candles are used for OHLC representation The result contains candles with non-zero volume only (no trades = no candles).
-
#get_converted_candles(target_currency:, symbols: nil, period: nil, sort: nil, from: nil, till: nil, limit: nil) ⇒ Object
Gets OHLCV data regarding the last price converted to the target currency for all symbols or for the specified symbols.
-
#get_converted_candles_by_symbol(target_currency:, symbol:, period: nil, sort: nil, from: nil, till: nil, limit: nil, offset: nil) ⇒ Object
(also: #get_converted_candles_of_symbol)
Gets OHLCV data regarding the last price converted to the target currency for the specified symbol.
-
#get_currencies(currencies: nil, preferred_network: nil) ⇒ Object
Get a Hash of all currencies or specified currencies.
-
#get_currency(currency:) ⇒ Object
Get the data of a currency.
-
#get_deposit_crypto_address(currency: nil, network_code: nil) ⇒ Object
(also: #get_deposit_crypto_address_of_cyrrency, #get_deposit_crypto_address_by_cyrrency)
Get the current addresses of a currency of the user.
-
#get_deposit_crypto_addresses ⇒ Object
Get a list with the current addresses of the user.
-
#get_estimate_withdrawal_fee(currency:, amount:, network_code: nil) ⇒ Object
Get an estimate of the withdrawal fee.
-
#get_estimate_withdrawal_fees(fee_requests:) ⇒ Object
Get an estimates for withdrawal fees of currencies.
-
#get_last_10_deposit_crypto_addresses(currency:, network_code: nil) ⇒ Object
Get the last 10 unique addresses used for deposit, by currency Addresses used a long time ago may be omitted, even if they are among the last 10 unique addresses.
-
#get_last_10_withdrawal_crypto_addresses(currency:, network_code: nil) ⇒ Object
Get the last 10 unique addresses used for withdrawals, by currency Addresses used a long time ago may be omitted, even if they are among the last 10 unique addresses.
-
#get_orderbook(symbol:, depth: nil) ⇒ Object
(also: #get_orderbook_by_symbol, #get_orderbook_of_symbol)
Get order book of a symbol An Order Book is an electronic list of buy and sell orders for a specific symbol, structured by price level.
-
#get_orderbook_volume(symbol:, volume: nil) ⇒ Object
(also: #get_orderbook_volume_by_symbol, #get_orderbook_volume_of_symbol)
Get order book of a symbol with the desired volume for market depth search An Order Book is an electronic list of buy and sell orders for a specific symbol, structured by price level.
-
#get_orderbooks(symbols: nil, depth: nil) ⇒ Object
Get a Hash of orderbooks for all symbols or for the specified symbols An Order Book is an electronic list of buy and sell orders for a specific symbol, structured by price level.
-
#get_price_history(to:, from: nil, till: nil, since: nil, limit: nil, period: nil, sort: nil) ⇒ Object
Get quotation prices history.
-
#get_prices(to:, from: nil) ⇒ Object
Get a Hash of quotation prices of currencies.
-
#get_spot_orders_history(client_order_id: nil, symbol: nil, sort: nil, by: nil, from: nil, till: nil, limit: nil, offset: nil) ⇒ Object
Get all the spot orders Orders without executions are deleted after 24 hours ‘from’ param and ‘till’ param must have the same format, both id or both timestamp.
-
#get_spot_trades_history(order_id: nil, symbol: nil, sort: nil, by: nil, from: nil, till: nil, limit: nil, offset: nil) ⇒ Object
Get the user’s spot trading history.
-
#get_spot_trading_balance(currency:) ⇒ Object
(also: #get_spot_trading_balance_of_currency, #get_spot_trading_balance_by_currency)
Get the user spot trading balance of a currency.
-
#get_spot_trading_balances ⇒ Object
Get the user’s spot trading balance for all currencies with balance.
-
#get_sub_account_balance(sub_account_id:) ⇒ Object
Returns non-zero balance values by sub-account Report will include the wallet and Trading balances for each currency It is functional with no regard to the state of a sub-account.
-
#get_sub_account_crypto_address(sub_account_id:, currency:) ⇒ Object
Returns sub-account crypto address for currency.
-
#get_sub_account_list ⇒ Object
Returns list of sub-accounts per a super account.
-
#get_symbol(symbol:) ⇒ Object
Get a symbol by its id A symbol is the combination of the base currency (first one) and quote currency (second one).
-
#get_symbols(symbols: nil) ⇒ Object
Get a Hash of all symbols or for specified symbols.
-
#get_ticker(symbol:) ⇒ Object
(also: #get_ticker_by_symbol, #get_ticker_of_symbol)
Get the ticker of a symbol.
-
#get_ticker_price(symbol:) ⇒ Object
(also: #get_ticker_price_by_symbol, #get_ticker_price_of_symbol)
Get ticker’s last prices of a symbol.
-
#get_ticker_prices(symbols: nil) ⇒ Object
Get a Hash of the ticker’s last prices for all symbols or for the specified symbols.
-
#get_tickers(symbols: nil) ⇒ Object
Get a Hash of tickers for all symbols or for specified symbols.
-
#get_trades(symbols: nil, by: nil, sort: nil, from: nil, till: nil, limit: nil, offset: nil) ⇒ Object
Get a Hash of trades for all symbols or for specified symbols ‘from’ param and ‘till’ param must have the same format, both id or both timestamp.
-
#get_trades_by_symbol(symbol: nil, by: nil, sort: nil, from: nil, till: nil, limit: nil, offset: nil) ⇒ Object
(also: #get_trades_of_symbol)
Get trades of a symbol ‘from’ param and ‘till’ param must have the same format, both id or both timestamp.
-
#get_trading_commission(symbol:) ⇒ Object
(also: #get_trading_commission_of_symbol, #get_trading_commission_by_symbol)
Get the personal trading commission rate of a symbol.
-
#get_transaction(id:) ⇒ Object
Get a transaction by its identifier.
-
#get_transaction_history(currency: nil, from: nil, till: nil, types: nil, subtypes: nil, statuses: nil, currencies: nil, networks: nil, id_from: nil, id_till: nil, tx_ids: nil, order_by: nil, sort: nil, limit: nil, offset: nil, group_transactions: nil) ⇒ Object
Get the transaction history of the account Important: - The list of supported transaction types may be expanded in future versions - Some transaction subtypes are reserved for future use and do not purport to provide any functionality on the platform - The list of supported transaction subtypes may be expanded in future versions.
-
#get_wallet_balance(currency:) ⇒ Object
(also: #get_wallet_balance_of_currency, #get_wallet_balance_by_currency)
Get the user’s wallet balance of a currency.
-
#get_wallet_balances ⇒ Object
Get the user’s wallet balance for all currencies with balance.
-
#get_whitelisted_addresses ⇒ Object
Gets the list of whitelisted addresses.
-
#get_withdrawal_fees_hash ⇒ Object
Gets the hash of withdrawal fees.
-
#initialize(api_key: nil, api_secret: nil, window: nil) ⇒ Client
constructor
rubocop:disable Metrics/ClassLength.
-
#offchain_available?(currency:, address:, payment_id: nil) ⇒ Boolean
get the status of the offchain.
- #patch(endpoint, params = nil) ⇒ Object
- #post(endpoint, params = nil) ⇒ Object
- #public_get(endpoint, params = nil) ⇒ Object
- #put(endpoint, params = nil) ⇒ Object
-
#replace_spot_order(client_order_id:, new_client_order_id:, quantity:, price: nil, stop_price: nil, strict_validate: nil) ⇒ Object
Replaces a spot order For fee, for price accuracy and quantity, and for order status information see the api docs.
-
#transfer_between_wallet_and_exchange(currency:, amount:, source:, destination:) ⇒ Object
Transfer funds between account types ‘source’ param and ‘destination’ param must be different account types.
-
#transfer_funds(sub_account_id:, amount:, currency:, type:) ⇒ Object
Transfers funds from the super-account to a sub-account or from a sub-account to the super-account and returns the transaction id.
-
#transfer_money_to_another_user(currency:, amount:, by:, identifier:) ⇒ Object
Transfer funds to another user.
-
#transfer_to_another_subaccount(sub_account_id:, amount:, currency:) ⇒ Object
Creates and commits a transfer between the user (subaccount) and another subaccount.
-
#transfer_to_super_account(amount:, currency:) ⇒ Object
Creates and commits a transfer from a subaccount to its super account.
-
#withdraw_crypto(currency:, amount:, address:, network_code: nil, payment_id: nil, include_fee: nil, auto_commit: nil, use_offchain: nil, public_comment: nil) ⇒ Object
Please take note that changing security settings affects withdrawals: - It is impossible to withdraw funds without enabling the two-factor authentication (2FA) - Password reset blocks withdrawals for 72 hours - Each time a new address is added to the whitelist, it takes 48 hours before that address becomes active for withdrawal Successful response to the request does not necessarily mean the resulting transaction got executed immediately.
-
#withdraw_crypto_commit(id:) ⇒ Object
Commit a withdrawal.
-
#withdraw_crypto_rollback(id:) ⇒ Object
Rollback a withdrawal.
Constructor Details
#initialize(api_key: nil, api_secret: nil, window: nil) ⇒ Client
rubocop:disable Metrics/ClassLength
14 15 16 |
# File 'lib/cryptomarket/client.rb', line 14 def initialize(api_key: nil, api_secret: nil, window: nil) @http_manager = HttpManager.new api_key:, api_secret:, window: end |
Instance Method Details
#activate_sub_accounts(sub_account_ids:) ⇒ Object
Activates sub-accounts listed. It would make sub-accounts active after being frozen
Requires no API key Access Rights
api.exchange.cryptomkt.com/#activate-sub-account
Params
Array[String]sub_account_ids-
A list of sub-account ids to activate
1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 |
# File 'lib/cryptomarket/client.rb', line 1173 def activate_sub_accounts( sub_account_ids: ) post( 'sub-account/activate', { sub_account_ids: } )['result'] end |
#cancel_all_spot_orders ⇒ Object
Cancel all active spot orders
Requires the “Place/cancel orders” API key Access Right
587 588 589 |
# File 'lib/cryptomarket/client.rb', line 587 def cancel_all_spot_orders delete('spot/order') end |
#cancel_spot_order(client_order_id:) ⇒ Object
Cancel the order with the client order id
Requires the “Place/cancel orders” API key Access Right
api.exchange.cryptomkt.com/#cancel-spot-order
Params
Stringclient_order_id-
client order id of the order to cancel
600 601 602 |
# File 'lib/cryptomarket/client.rb', line 600 def cancel_spot_order(client_order_id:) delete("spot/order/#{client_order_id}") end |
#change_acl_settings(sub_account_ids:, deposit_address_generation_enabled: nil, withdraw_enabled: nil, description: nil, created_at: nil, updated_at: nil) ⇒ Object
Returns a list of withdrawal settings for sub-accounts listed
Requires the “Payment information” API key Access Right
api.exchange.cryptomkt.com/#get-acl-settings
Params
Array[String]sub_account_ids-
A list of sub-account ids to get the acl settings
booldeposit_address_generation_enabled-
Optional. Enables deposits
boolwithdraw_enabled-
Optional. Enables withdrawals
Stringdescription-
Optional. Textual description
Stringcreated_at-
Optional. ACL creation time
Stringupdated_at-
Optional. ACL update time
1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 |
# File 'lib/cryptomarket/client.rb', line 1307 def change_acl_settings( # rubocop:disable Metrics/ParameterLists sub_account_ids:, deposit_address_generation_enabled: nil, withdraw_enabled: nil, description: nil, created_at: nil, updated_at: nil ) post( 'sub-account/acl', { sub_account_ids:, deposit_address_generation_enabled:, withdraw_enabled:, description:, created_at:, updated_at: } )['result'] end |
#change_credentials(api_key:, api_secret:) ⇒ Object
Changes the user credentials used for authentication in calls
Params
Stringapi_key-
The user public key used in new calls
Stringapi_secret-
The user secret key used in new calls
48 49 50 |
# File 'lib/cryptomarket/client.rb', line 48 def change_credentials(api_key:, api_secret:) @http_manager.change_credentials(api_key:, api_secret:) end |
#change_window(window:) ⇒ Object
Changes the window used in authenticated calls
Params
Integerwindow-
Acceptable time between request and server execution in millis
57 58 59 |
# File 'lib/cryptomarket/client.rb', line 57 def change_window(window:) @http_manager.change_window(window:) end |
#convert_between_currencies(from_currency:, to_currency:, amount:) ⇒ Object
Converts between currencies Successful response to the request does not necessarily mean the resulting transaction got executed immediately. It has to be processed first and may eventually be rolled back To see whether a transaction has been finalized, call #get_transaction
Requires the “Payment information” API key Access Right
api.exchange.cryptomkt.com/#convert-between-currencies
Params
Stringfrom currency-
currency code of origin
Stringto currency-
currency code of destiny
floatamount-
the amount to be converted
951 952 953 954 955 956 957 958 959 960 |
# File 'lib/cryptomarket/client.rb', line 951 def convert_between_currencies(from_currency:, to_currency:, amount:) post( 'wallet/convert', { from_currency:, to_currency:, amount: } )['result'] end |
#create_deposit_crypto_address(currency:, network_code: nil) ⇒ Object
Creates a new address for a currency
Requires the “Payment information” API key Access Right
api.exchange.cryptomkt.com/#generate-deposit-crypto-address
Params
Stringcurrency-
currency to create a new address
Stringnetwork_code-
Optional. network code
763 764 765 |
# File 'lib/cryptomarket/client.rb', line 763 def create_deposit_crypto_address(currency:, network_code: nil) post('wallet/crypto/address', { currency:, network_code: }) end |
#create_spot_order(symbol:, side:, quantity:, client_order_id: nil, type: nil, time_in_force: nil, price: nil, stop_price: nil, expire_time: nil, strict_validate: nil, post_only: nil, take_rate: nil, make_rate: nil) ⇒ Object
Creates a new spot order For fee, for price accuracy and quantity, and for order status information see the api docs
Requires the “Place/cancel orders” API key Access Right
api.exchange.cryptomkt.com/#create-new-spot-order
Params
Stringsymbol-
Trading symbol
Stringside-
Either ‘buy’ or ‘sell’
Stringquantity-
Order quantity
Stringclient_order_id-
Optional. If given must be unique within the trading day, including all active orders. If not given, is generated by the server
Stringtype-
Optional. ‘limit’, ‘market’, ‘stopLimit’, ‘stopMarket’, ‘takeProfitLimit’ or ‘takeProfitMarket’. Default is ‘limit’
Stringtime_in_force-
Optional. ‘GTC’, ‘IOC’, ‘FOK’, ‘Day’, ‘GTD’. Default is ‘GTC’ if ‘limit’, ‘stopLimit’ or ‘takeProfitLimit’ order, Default is ‘FOK’ if ‘market’, ‘stopMarket’ or ‘takeProfitMarket’ order
Stringprice-
Optional. Required for ‘limit’ and ‘stopLimit’. limit price of the order
Stringstop_price-
Optional. Required for ‘stopLimit’ and ‘stopMarket’ orders. stop price of the order
Stringexpire_time-
Optional. Required for orders with timeInForce = GDT
boolstrict_validate-
Optional. If False, the server rounds half down for tickerSize and quantityIncrement. Example of ETHBTC: tickSize = ‘0.000001’, then price ‘0.046016’ is valid, ‘0.0460165’ is invalid
boolpost_only-
Optional. If True, your post_only order causes a match with a pre-existing order as a taker, then the order will be cancelled
Stringtake_rate-
Optional. Liquidity taker fee, a fraction of order volume, such as 0.001 (for 0.1% fee). Can only increase the fee. Used for fee markup.
Stringmake_rate-
Optional. Liquidity provider fee, a fraction of order volume, such as 0.001 (for 0.1% fee). Can only increase the fee. Used for fee markup.
480 481 482 483 484 485 486 487 488 489 490 491 |
# File 'lib/cryptomarket/client.rb', line 480 def create_spot_order( # rubocop:disable Metrics/ParameterLists symbol:, side:, quantity:, client_order_id: nil, type: nil, time_in_force: nil, price: nil, stop_price: nil, expire_time: nil, strict_validate: nil, post_only: nil, take_rate: nil, make_rate: nil ) post( 'spot/order', { client_order_id:, symbol:, side:, quantity:, type:, time_in_force:, price:, stop_price:, expire_time:, strict_validate:, post_only:, take_rate:, make_rate: } ) end |
#create_spot_order_list(contingency_type:, orders:, order_list_id: nil) ⇒ Object
creates a list of spot orders
Types or contingency
-
‘allOrNone’ (AON)
-
‘oneCancelAnother’ (OCO)
-
‘oneTriggerOther’ (OTO)
-
‘oneTriggerOneCancelOther’ (OTOCO)
Restriction in the number of orders:
-
An AON list must have 2 or 3 orders
-
An OCO list must have 2 or 3 orders
-
An OTO list must have 2 or 3 orders
-
An OTOCO must have 3 or 4 orders
Symbol restrictions
-
For an AON order list, the symbol code of orders must be unique for each order in the list.
-
For an OCO order list, there are no symbol code restrictions.
-
For an OTO order list, there are no symbol code restrictions.
-
For an OTOCO order list, the symbol code of orders must be the same for all orders in the list (placing orders in different order books is not supported).
OrderType restrictions
-
For an AON order list, orders must be ‘limit’ or ‘market’
-
For an OCO order list, orders must be ‘limit’, ‘stopLimit’, ‘stopMarket’, takeProfitLimit or takeProfitMarket.
-
An OCO order list cannot include more than one limit order (the same
applies to secondary orders in an OTOCO order list).
-
For OTO order list, there are no order type restrictions.
-
For an OTOCO order list, the first order must be ‘limit’, ‘market’, ‘stopLimit’, ‘stopMarket’, takeProfitLimit or takeProfitMarket.
-
For an OTOCO order list, the secondary orders have the same restrictions as an OCO order
-
Default is ‘limit’
api.exchange.cryptomkt.com/#create-new-spot-order-list
Params
Stringorder_list_id-
order list identifier. If ommited, it will be generated by the system. Must be equal to the client order id of the first order in the request
Stringcontingency_type-
order list type. ‘allOrNone’, ‘oneCancelOther’ or ‘oneTriggerOneCancelOther’
Array[]orders-
the list of orders. aech order in the list has the same parameters of a new spot order
530 531 532 533 534 535 536 537 538 539 540 541 542 543 |
# File 'lib/cryptomarket/client.rb', line 530 def create_spot_order_list( contingency_type:, orders:, order_list_id: nil ) post( 'spot/order/list', { order_list_id:, contingency_type:, orders: } ) end |
#crypto_address_belongs_to_current_account?(address:) ⇒ Boolean
Check if an address is from this account
Requires the “Payment information” API key Access Right
api.exchange.cryptomkt.com/#check-if-crypto-address-belongs-to-current-account
Params
Stringaddress-
address to check
971 972 973 |
# File 'lib/cryptomarket/client.rb', line 971 def crypto_address_belongs_to_current_account?(address:) get('wallet/crypto/address/check-mine', { address: })['result'] end |
#delete(endpoint, params = nil) ⇒ Object
38 39 40 |
# File 'lib/cryptomarket/client.rb', line 38 def delete(endpoint, params = nil) @http_manager.make_request(method: 'delete', endpoint:, params:) end |
#freeze_sub_accounts(sub_account_ids:) ⇒ Object
Freezes sub-accounts listed Sub-accounts frozen wouldn’t be able to:
-
login
-
withdraw funds
-
trade
-
complete pending orders
-
use API keys
For any sub-account listed, all orders will be canceled and all funds will be transferred form the Trading balance
Requires no API key Access Rights
api.exchange.cryptomkt.com/#freeze-sub-account
Params
Array[String]sub_account_ids-
A list of sub-account ids to freeze
1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 |
# File 'lib/cryptomarket/client.rb', line 1154 def freeze_sub_accounts( sub_account_ids: ) post( 'sub-account/freeze', { sub_account_ids: } )['result'] end |
#get(endpoint, params = nil) ⇒ Object
22 23 24 |
# File 'lib/cryptomarket/client.rb', line 22 def get(endpoint, params = nil) @http_manager.make_request(method: 'get', endpoint:, params:) end |
#get_acl_settings(sub_account_ids:) ⇒ Object
Returns a list of withdrawal settings for sub-accounts listed
Requires the “Payment information” API key Access Right
api.exchange.cryptomkt.com/#get-acl-settings
Params
Array[String]sub_account_ids-
A list of sub-account ids to get the acl settings
1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 |
# File 'lib/cryptomarket/client.rb', line 1282 def get_acl_settings( sub_account_ids: ) get( 'sub-account/acl', { sub_account_ids: } )['result'] end |
#get_active_spot_order(client_order_id:) ⇒ Object
Get an active spot order by its client order id
Requires the “Place/cancel orders” API key Access Right
api.exchange.cryptomkt.com/#get-active-spot-order
Params
Stringclient_order_id-
The client order id of the order
454 455 456 |
# File 'lib/cryptomarket/client.rb', line 454 def get_active_spot_order(client_order_id:) get("spot/order/#{client_order_id}") end |
#get_all_active_spot_orders(symbol: nil) ⇒ Object
Get the user’s active spot orders
Requires the “Place/cancel orders” API key Access Right
api.exchange.cryptomkt.com/#get-all-active-spot-orders
Params
Stringsymbol-
Optional. A symbol for filtering the active spot orders
441 442 443 |
# File 'lib/cryptomarket/client.rb', line 441 def get_all_active_spot_orders(symbol: nil) get('spot/order', { symbol: }) end |
#get_all_trading_commission ⇒ Object Also known as: get_all_trading_commissions, get_trading_commissions
Get the personal trading commission rates for all symbols
Requires the “Place/cancel orders” API key Access Right
610 611 612 |
# File 'lib/cryptomarket/client.rb', line 610 def get_all_trading_commission # rubocop:disable Naming/AccessorMethodName get('spot/fee') end |
#get_amount_locks(currency: nil, active: nil, limit: nil, offset: nil, from: nil, till: nil) ⇒ Object
Get the list of amount locks
Requires the “Payment information” API key Access Right
api.exchange.cryptomkt.com/#get-amount-locks
Params
Stringcurrency-
Optional. Currency code
boolactive-
Optional. value showing whether the lock is active
Integerlimit-
Optional. Dafault is 100. Min is 0. Max is 1_000
Integeroffset-
Optional. Default is 0. Min is 0
Stringfrom-
Optional. Interval initial value. As Datetime
Stringtill-
Optional. Interval end value. As Datetime
1117 1118 1119 1120 1121 1122 1123 1124 |
# File 'lib/cryptomarket/client.rb', line 1117 def get_amount_locks( # rubocop:disable Metrics/ParameterLists currency: nil, active: nil, limit: nil, offset: nil, from: nil, till: nil ) get( 'wallet/amount-locks', { currency:, active:, limit:, offset:, from:, till: } ) end |
#get_bulk_estimate_withdrawal_fees(fee_requests:) ⇒ Object
Get an estimates for withdrawal fees of currencies
Requires the “Payment information” API key Access Right
api.exchange.cryptomkt.com/#bulk-estimate-withdrawal-fee
Params
Array[]fee_requests-
the list of fee requests, each request is a Hash in the form amount:“string”, network_code:“optional string”
880 881 882 883 |
# File 'lib/cryptomarket/client.rb', line 880 def get_bulk_estimate_withdrawal_fees(fee_requests:) params = fee_requests post('wallet/crypto/fee/estimate/bulk', params) end |
#get_candles(symbols: nil, period: nil, sort: nil, from: nil, till: nil, limit: nil, offset: nil) ⇒ Object
Get a Hash of candles for all symbols or for specified symbols Candles are used for OHLC representation The result contains candles with non-zero volume only (no trades = no candles)
Requires no API key Access Rights
api.exchange.cryptomkt.com/#candles
Params
Stringsymbol-
A symbol id
Stringperiod-
Optional. A valid tick interval. ‘M1’ (one minute), ‘M3’, ‘M5’, ‘M15’, ‘M30’, ‘H1’ (one hour), ‘H4’, ‘D1’ (one day), ‘D7’, ‘1M’ (one month). Default is ‘M30’
Stringsort-
Optional. Sort direction. ‘ASC’ or ‘DESC’. Default is ‘DESC’
Stringfrom-
Optional. Initial value of the queried interval. As DateTime
Stringtill-
Optional. Last value of the queried interval. As DateTime
Integerlimit-
Optional. Prices per currency pair. Defaul is 10. Min is 1. Max is 1_000
317 318 319 320 321 322 |
# File 'lib/cryptomarket/client.rb', line 317 def get_candles(symbols: nil, period: nil, sort: nil, from: nil, till: nil, limit: nil, offset: nil) # rubocop:disable Metrics/ParameterLists public_get( 'public/candles/', { symbols:, period:, sort:, from:, till:, limit:, offset: } ) end |
#get_candles_by_symbol(symbol:, period: nil, sort: nil, from: nil, till: nil, limit: nil, offset: nil) ⇒ Object Also known as: get_candles_of_symbol
Get candles of a symbol Candles are used for OHLC representation The result contains candles with non-zero volume only (no trades = no candles)
Requires no API key Access Rights
api.exchange.cryptomkt.com/#candles
Params
Stringsymbol-
A symbol id
Stringperiod-
Optional. A valid tick interval. ‘M1’ (one minute), ‘M3’, ‘M5’, ‘M15’, ‘M30’, ‘H1’ (one hour), ‘H4’, ‘D1’ (one day), ‘D7’, ‘1M’ (one month). Default is ‘M30’
Stringsort-
Optional. Sort direction. ‘ASC’ or ‘DESC’. Default is ‘DESC’
Stringfrom-
Optional. Initial value of the queried interval. As DateTime
Stringtill-
Optional. Last value of the queried interval. As DateTime
Integerlimit-
Optional. Prices per currency pair. Defaul is 100. Min is 1. Max is 1_000
Integeroffset-
Optional. Default is 0. Min is 0. Max is 100_000
341 342 343 344 345 346 |
# File 'lib/cryptomarket/client.rb', line 341 def get_candles_by_symbol(symbol:, period: nil, sort: nil, from: nil, till: nil, limit: nil, offset: nil) # rubocop:disable Metrics/ParameterLists public_get( "public/candles/#{symbol}", { period:, sort:, from:, till:, limit:, offset: } ) end |
#get_converted_candles(target_currency:, symbols: nil, period: nil, sort: nil, from: nil, till: nil, limit: nil) ⇒ Object
Gets OHLCV data regarding the last price converted to the target currency for all symbols or for the specified symbols
Candles are used for OHLC representation
The result contains candles with non-zero volume only (no trades = no candles)
Conversion from the symbol quote currency to the target currency is the mean of "best" bid price and "best" ask price in the order book. If there is no "best" bid or ask price, the last price is returned.
Requires no API key Access Rights
api.exchange.cryptomkt.com/#candles
Stringtarget_currency-
Target currency for conversion
Array[String]symbols-
Optional. A list of symbols
Stringperiod-
Optional. A valid tick interval. ‘M1’ (one minute), ‘M3’, ‘M5’, ‘M15’, ‘M30’, ‘H1’ (one hour), ‘H4’, ‘D1’ (one day), ‘D7’, ‘1M’ (one month). Default is ‘M30’
Stringsort-
Optional. Sort direction. ‘ASC’ or ‘DESC’. Default is ‘DESC’
Stringfrom-
Optional. Initial value of the queried interval. As DateTime
Stringtill-
Optional. Last value of the queried interval. As DateTime
Integerlimit-
Optional. Prices per currency pair. Defaul is 100. Min is 1. Max is 1_000
368 369 370 371 372 373 |
# File 'lib/cryptomarket/client.rb', line 368 def get_converted_candles(target_currency:, symbols: nil, period: nil, sort: nil, from: nil, till: nil, limit: nil) # rubocop:disable Metrics/ParameterLists public_get( 'public/converted/candles', { target_currency:, symbols:, period:, sort:, from:, till:, limit: } ) end |
#get_converted_candles_by_symbol(target_currency:, symbol:, period: nil, sort: nil, from: nil, till: nil, limit: nil, offset: nil) ⇒ Object Also known as: get_converted_candles_of_symbol
Gets OHLCV data regarding the last price converted to the target currency for the specified symbol
Candles are used for OHLC representation
The result contains candles with non-zero volume only (no trades = no candles)
Conversion from the symbol quote currency to the target currency is the mean of "best" bid price and "best" ask price in the order book. If there is no "best" bid or ask price, the last price is returned.
Requires no API key Access Rights
api.exchange.cryptomkt.com/#candles
Stringtarget_currency-
Target currency for conversion
Stringsymbol-
A symbol id
Stringperiod-
Optional. A valid tick interval. ‘M1’ (one minute), ‘M3’, ‘M5’, ‘M15’, ‘M30’, ‘H1’ (one hour), ‘H4’, ‘D1’ (one day), ‘D7’, ‘1M’ (one month). Default is ‘M30’
Stringsort-
Optional. Sort direction. ‘ASC’ or ‘DESC’. Default is ‘DESC’
Stringfrom-
Optional. Initial value of the queried interval. As DateTime
Stringtill-
Optional. Last value of the queried interval. As DateTime
Integerlimit-
Optional. Prices per currency pair. Defaul is 100. Min is 1. Max is 1_000
Integeroffset-
Optional. Default is 0. Min is 0. Max is 100_000
396 397 398 399 400 401 |
# File 'lib/cryptomarket/client.rb', line 396 def get_converted_candles_by_symbol(target_currency:, symbol:, period: nil, sort: nil, from: nil, till: nil, limit: nil, offset: nil) # rubocop:disable Metrics/ParameterLists public_get( "public/converted/candles/#{symbol}", { target_currency:, period:, sort:, from:, till:, limit:, offset: } ) end |
#get_currencies(currencies: nil, preferred_network: nil) ⇒ Object
Get a Hash of all currencies or specified currencies. indexed by id
Requires no API key Access Rights
api.exchange.cryptomkt.com/#currencies
Params
Array[String]currencies-
Optional. A list of currencies ids
Stringpreferred_network-
Optional. Code of de default network code of currencies
75 76 77 78 79 80 |
# File 'lib/cryptomarket/client.rb', line 75 def get_currencies(currencies: nil, preferred_network: nil) public_get('public/currency/', { currencies:, preferred_network: }) end |
#get_currency(currency:) ⇒ Object
Get the data of a currency
Requires no API key Access Rights
api.exchange.cryptomkt.com/#currencies
Params
Stringcurrency-
A currency id
91 92 93 |
# File 'lib/cryptomarket/client.rb', line 91 def get_currency(currency:) public_get("public/currency/#{currency}") end |
#get_deposit_crypto_address(currency: nil, network_code: nil) ⇒ Object Also known as: get_deposit_crypto_address_of_cyrrency, get_deposit_crypto_address_by_cyrrency
Get the current addresses of a currency of the user
Getting the address of a new currency will create an address
Requires the “Payment information” API key Access Right
api.exchange.cryptomkt.com/#get-deposit-crypto-address
Params
Stringcurrency-
Currency to get the address
Stringnetwork_code-
Optional. network code
746 747 748 749 750 751 |
# File 'lib/cryptomarket/client.rb', line 746 def get_deposit_crypto_address(currency: nil, network_code: nil) result = get('wallet/crypto/address', { currency:, network_code: }) raise CryptomarketSDKException 'Too many currencies recieved, expected 1 currency' if result.length != 1 result[0] end |
#get_deposit_crypto_addresses ⇒ Object
Get a list with the current addresses of the user
Requires the “Payment information” API key Access Right
730 731 732 |
# File 'lib/cryptomarket/client.rb', line 730 def get_deposit_crypto_addresses # rubocop:disable Naming/AccessorMethodName get('wallet/crypto/address') end |
#get_estimate_withdrawal_fee(currency:, amount:, network_code: nil) ⇒ Object
Get an estimate of the withdrawal fee
Requires the “Payment information” API key Access Right
api.exchange.cryptomkt.com/#estimate-withdrawal-fee
Params
Stringcurrency-
the currency code for withdrawal
floatamount-
the expected withdraw amount
905 906 907 908 |
# File 'lib/cryptomarket/client.rb', line 905 def get_estimate_withdrawal_fee(currency:, amount:, network_code: nil) params = { amount:, currency:, network_code: } get('wallet/crypto/fee/estimate', params)['fee'] end |
#get_estimate_withdrawal_fees(fee_requests:) ⇒ Object
Get an estimates for withdrawal fees of currencies
Requires the “Payment information” API key Access Right
api.exchange.cryptomkt.com/#estimate-withdrawal-fees
Params
Array[]fee_requests-
the list of fee requests, each request is a Hash in the form amount:“string”, network_code:“optional string”
866 867 868 869 |
# File 'lib/cryptomarket/client.rb', line 866 def get_estimate_withdrawal_fees(fee_requests:) params = fee_requests post('wallet/crypto/fees/estimate', params) end |
#get_last_10_deposit_crypto_addresses(currency:, network_code: nil) ⇒ Object
Get the last 10 unique addresses used for deposit, by currency Addresses used a long time ago may be omitted, even if they are among the last 10 unique addresses
Requires the “Payment information” API key Access Right
api.exchange.cryptomkt.com/#last-10-deposit-crypto-addresses
Params
Stringcurrency-
currency to get the list of addresses
Stringnetwork_code-
Optional. network code
778 779 780 |
# File 'lib/cryptomarket/client.rb', line 778 def get_last_10_deposit_crypto_addresses(currency:, network_code: nil) get('wallet/crypto/address/recent-deposit', { currency:, network_code: }) end |
#get_last_10_withdrawal_crypto_addresses(currency:, network_code: nil) ⇒ Object
Get the last 10 unique addresses used for withdrawals, by currency Addresses used a long time ago may be omitted, even if they are among the last 10 unique addresses
Requires the “Payment information” API key Access Right
api.exchange.cryptomkt.com/#last-10-withdrawal-crypto-addresses
Params
Stringcurrency-
currency to get the list of addresses
Stringnetwork_code-
Optional. network code
793 794 795 |
# File 'lib/cryptomarket/client.rb', line 793 def get_last_10_withdrawal_crypto_addresses(currency:, network_code: nil) get('wallet/crypto/address/recent-withdraw', { currency:, network_code: }) end |
#get_orderbook(symbol:, depth: nil) ⇒ Object Also known as: get_orderbook_by_symbol, get_orderbook_of_symbol
Get order book of a symbol An Order Book is an electronic list of buy and sell orders for a specific symbol, structured by price level
Requires no API key Access Rights
api.exchange.cryptomkt.com/#order-books
Params
Stringsymbol-
A symbol id
Integerdepth-
Optional. Order Book depth. Default value is 100. Set to 0 to view the full Order Book
282 283 284 |
# File 'lib/cryptomarket/client.rb', line 282 def get_orderbook(symbol:, depth: nil) public_get("public/orderbook/#{symbol}", { depth: }) end |
#get_orderbook_volume(symbol:, volume: nil) ⇒ Object Also known as: get_orderbook_volume_by_symbol, get_orderbook_volume_of_symbol
Get order book of a symbol with the desired volume for market depth search An Order Book is an electronic list of buy and sell orders for a specific symbol, structured by price level
Requires no API key Access Rights
api.exchange.cryptomkt.com/#order-books
Params
Stringsymbol-
A symbol id
floatvolume-
Optional. Desired volume for market depth search
297 298 299 |
# File 'lib/cryptomarket/client.rb', line 297 def get_orderbook_volume(symbol:, volume: nil) public_get("public/orderbook/#{symbol}", { volume: }) end |
#get_orderbooks(symbols: nil, depth: nil) ⇒ Object
Get a Hash of orderbooks for all symbols or for the specified symbols An Order Book is an electronic list of buy and sell orders for a specific symbol, structured by price level
Requires no API key Access Rights
api.exchange.cryptomkt.com/#order-books
Params
Array[String]symbols-
Optional. A list of symbol ids
Integerdepth-
Optional. Order Book depth. Default value is 100. Set to 0 to view the full Order Book
267 268 269 |
# File 'lib/cryptomarket/client.rb', line 267 def get_orderbooks(symbols: nil, depth: nil) public_get('public/orderbook', { symbols:, depth: }) end |
#get_price_history(to:, from: nil, till: nil, since: nil, limit: nil, period: nil, sort: nil) ⇒ Object
Get quotation prices history
Requires no API key Access Rights
api.exchange.cryptomkt.com/#prices
Params
Stringto-
Target currency code
Stringfrom-
Optional. Source currency rate
Stringperiod-
Optional. A valid tick interval. ‘M1’ (one minute), ‘M3’, ‘M5’, ‘M15’, ‘M30’, ‘H1’ (one hour), ‘H4’, ‘D1’ (one day), ‘D7’, ‘1M’ (one month). Default is ‘M30’
Stringsort-
Optional. Sort direction. ‘ASC’ or ‘DESC’. Default is ‘DESC’
Stringsince-
Optional. Initial value of the queried interval
Stringuntil-
Optional. Last value of the queried interval
Integerlimit-
Optional. Prices per currency pair. Defaul is 1. Min is 1. Max is 1_000
178 179 180 181 182 183 |
# File 'lib/cryptomarket/client.rb', line 178 def get_price_history(to:, from: nil, till: nil, since: nil, limit: nil, period: nil, sort: nil) # rubocop:disable Metrics/ParameterLists public_get( 'public/price/history', { to:, from:, till:, since:, limit:, period:, sort: } ) end |
#get_prices(to:, from: nil) ⇒ Object
Get a Hash of quotation prices of currencies
Requires no API key Access Rights
api.exchange.cryptomkt.com/#prices
Params
Stringto-
Target currency code
Stringfrom-
Optional. Source currency rate
159 160 161 |
# File 'lib/cryptomarket/client.rb', line 159 def get_prices(to:, from: nil) public_get('public/price/rate', { to:, from: }) end |
#get_spot_orders_history(client_order_id: nil, symbol: nil, sort: nil, by: nil, from: nil, till: nil, limit: nil, offset: nil) ⇒ Object
Get all the spot orders Orders without executions are deleted after 24 hours ‘from’ param and ‘till’ param must have the same format, both id or both timestamp
Requires the “Orderbook, History, Trading balance” API key Access Right
api.exchange.cryptomkt.com/#spot-orders-history
Params
Stringsymbol-
Optional. Filter orders by symbol
Stringby-
Optional. Sorting parameter. ‘id’ or ‘timestamp’. Default is ‘timestamp’
Stringsort-
Optional. Sort direction. ‘ASC’ or ‘DESC’. Default is ‘DESC’
Stringfrom-
Optional. Initial value of the queried interval
Stringtill-
Optional. Last value of the queried interval
Integerlimit-
Optional. Prices per currency pair. Defaul is 100. Max is 1_000
Integeroffset-
Optional. Default is 0. Max is 100_000
650 651 652 653 654 655 656 657 658 659 |
# File 'lib/cryptomarket/client.rb', line 650 def get_spot_orders_history( # rubocop:disable Metrics/ParameterLists client_order_id: nil, symbol: nil, sort: nil, by: nil, from: nil, till: nil, limit: nil, offset: nil ) get( 'spot/history/order', { client_order_id:, symbol:, sort:, by:, from:, till:, limit:, offset: } ) end |
#get_spot_trades_history(order_id: nil, symbol: nil, sort: nil, by: nil, from: nil, till: nil, limit: nil, offset: nil) ⇒ Object
Get the user’s spot trading history
Requires the “Orderbook, History, Trading balance” API key Access Right
api.exchange.cryptomkt.com/#spot-trades-history
Params
Stringorder id-
Optional. Order unique identifier as assigned by the exchange
Stringsymbol-
Optional. Filter orders by symbol
Stringby-
Optional. Sorting parameter. ‘id’ or ‘timestamp’. Default is ‘timestamp’
Stringsort-
Optional. Sort direction. ‘ASC’ or ‘DESC’. Default is ‘DESC’
Stringfrom-
Optional. Initial value of the queried interval
Stringtill-
Optional. Last value of the queried interval
Integerlimit-
Optional. Prices per currency pair. Defaul is 100. Max is 1_000
Integeroffset-
Optional. Default is 0. Max is 100_000
677 678 679 680 681 682 683 684 685 686 |
# File 'lib/cryptomarket/client.rb', line 677 def get_spot_trades_history( # rubocop:disable Metrics/ParameterLists order_id: nil, symbol: nil, sort: nil, by: nil, from: nil, till: nil, limit: nil, offset: nil ) get( 'spot/history/trade', { order_id:, symbol:, sort:, by:, from:, till:, limit:, offset: } ) end |
#get_spot_trading_balance(currency:) ⇒ Object Also known as: get_spot_trading_balance_of_currency, get_spot_trading_balance_by_currency
Get the user spot trading balance of a currency
Requires the “Orderbook, History, Trading balance” API key Access Right
api.exchange.cryptomkt.com/#get-spot-trading-balance
Params
Stringcurrency-
The currency code to query the balance
426 427 428 429 430 |
# File 'lib/cryptomarket/client.rb', line 426 def get_spot_trading_balance(currency:) balance = get("spot/balance/#{currency}") balance['currency'] = currency balance end |
#get_spot_trading_balances ⇒ Object
Get the user’s spot trading balance for all currencies with balance
Requires the “Orderbook, History, Trading balance” API key Access Right
413 414 415 |
# File 'lib/cryptomarket/client.rb', line 413 def get_spot_trading_balances # rubocop:disable Naming/AccessorMethodName get('spot/balance') end |
#get_sub_account_balance(sub_account_id:) ⇒ Object
Returns non-zero balance values by sub-account Report will include the wallet and Trading balances for each currency It is functional with no regard to the state of a sub-account
Requires the “Payment information” API key Access Right
api.exchange.cryptomkt.com/#get-sub-account-balance
Params
Stringsub_account_id-
The id of the sub-account
1328 1329 1330 1331 1332 1333 1334 |
# File 'lib/cryptomarket/client.rb', line 1328 def get_sub_account_balance( sub_account_id: ) get( "sub-account/balance/#{sub_account_id}" )['result'] end |
#get_sub_account_crypto_address(sub_account_id:, currency:) ⇒ Object
Returns sub-account crypto address for currency
Requires the “Payment information” API key Access Right
api.exchange.cryptomkt.com/#get-sub-account-crypto-address
Params
Stringsub_account_id-
The id of the sub-account
Stringcurrency-
The currency of the address
1345 1346 1347 1348 1349 1350 1351 1352 |
# File 'lib/cryptomarket/client.rb', line 1345 def get_sub_account_crypto_address( sub_account_id:, currency: ) get( "sub-account/crypto/address/#{sub_account_id}/#{currency}" )['result']['address'] end |
#get_sub_account_list ⇒ Object
Returns list of sub-accounts per a super account.
Requires no API key Access Rights.
1132 1133 1134 1135 1136 |
# File 'lib/cryptomarket/client.rb', line 1132 def get_sub_account_list # rubocop:disable Naming/AccessorMethodName get( 'sub-account' )['result'] end |
#get_symbol(symbol:) ⇒ Object
Get a symbol by its id A symbol is the combination of the base currency (first one) and quote currency (second one)
Requires no API key Access Rights
api.exchange.cryptomkt.com/#symbols
Params
Stringsymbol-
A symbol id
119 120 121 |
# File 'lib/cryptomarket/client.rb', line 119 def get_symbol(symbol:) public_get("public/symbol/#{symbol}") end |
#get_symbols(symbols: nil) ⇒ Object
Get a Hash of all symbols or for specified symbols. indexed by id A symbol is the combination of the base currency (first one) and quote currency (second one)
Requires no API key Access Rights
api.exchange.cryptomkt.com/#symbols
Params
Array[String]symbols-
Optional. A list of symbol ids
105 106 107 |
# File 'lib/cryptomarket/client.rb', line 105 def get_symbols(symbols: nil) public_get('public/symbol', { symbols: }) end |
#get_ticker(symbol:) ⇒ Object Also known as: get_ticker_by_symbol, get_ticker_of_symbol
Get the ticker of a symbol
Requires no API key Access Rights
api.exchange.cryptomkt.com/#tickers
Params
Stringsymbol-
A symbol id
145 146 147 |
# File 'lib/cryptomarket/client.rb', line 145 def get_ticker(symbol:) public_get("public/ticker/#{symbol}") end |
#get_ticker_price(symbol:) ⇒ Object Also known as: get_ticker_price_by_symbol, get_ticker_price_of_symbol
Get ticker’s last prices of a symbol
Requires no API key Access Rights
api.exchange.cryptomkt.com/#prices
Params
Stringsymbol-
A symbol id
207 208 209 |
# File 'lib/cryptomarket/client.rb', line 207 def get_ticker_price(symbol:) public_get("public/price/ticker/#{symbol}") end |
#get_ticker_prices(symbols: nil) ⇒ Object
Get a Hash of the ticker’s last prices for all symbols or for the specified symbols
Requires no API key Access Rights
api.exchange.cryptomkt.com/#prices
Params
Array[String]symbols-
Optional. A list of symbol ids
194 195 196 |
# File 'lib/cryptomarket/client.rb', line 194 def get_ticker_prices(symbols: nil) public_get('public/price/ticker', { symbols: }) end |
#get_tickers(symbols: nil) ⇒ Object
Get a Hash of tickers for all symbols or for specified symbols. indexed by symbol
Requires no API key Access Rights
api.exchange.cryptomkt.com/#tickers
Params
Array[String]symbols-
Optional. A list of symbol ids
132 133 134 |
# File 'lib/cryptomarket/client.rb', line 132 def get_tickers(symbols: nil) public_get('public/ticker', { symbols: }) end |
#get_trades(symbols: nil, by: nil, sort: nil, from: nil, till: nil, limit: nil, offset: nil) ⇒ Object
Get a Hash of trades for all symbols or for specified symbols ‘from’ param and ‘till’ param must have the same format, both id or both timestamp
Requires no API key Access Rights
api.exchange.cryptomkt.com/#trades
Params
Array[String]symbols-
Optional. A list of symbol ids
Stringby-
Optional. Sorting parameter. ‘id’ or ‘timestamp’. Default is ‘timestamp’
Stringsort-
Optional. Sort direction. ‘ASC’ or ‘DESC’. Default is ‘DESC’
Stringsince-
Optional. Initial value of the queried interval
Stringuntil-
Optional. Last value of the queried interval
Integerlimit-
Optional. Prices per currency pair. Defaul is 10. Min is 1. Max is 1_000
226 227 228 229 230 231 |
# File 'lib/cryptomarket/client.rb', line 226 def get_trades(symbols: nil, by: nil, sort: nil, from: nil, till: nil, limit: nil, offset: nil) # rubocop:disable Metrics/ParameterLists public_get( 'public/trades/', { symbols:, by:, sort:, from:, till:, limit:, offset: } ) end |
#get_trades_by_symbol(symbol: nil, by: nil, sort: nil, from: nil, till: nil, limit: nil, offset: nil) ⇒ Object Also known as: get_trades_of_symbol
Get trades of a symbol ‘from’ param and ‘till’ param must have the same format, both id or both timestamp
Requires no API key Access Rights
api.exchange.cryptomkt.com/#trades
Params
Stringsymbol-
A symbol id
Stringby-
Optional. Sorting parameter. ‘id’ or ‘timestamp’. Default is ‘timestamp’
Stringsort-
Optional. Sort direction. ‘ASC’ or ‘DESC’. Default is ‘DESC’
Stringsince-
Optional. Initial value of the queried interval
Stringuntil-
Optional. Last value of the queried interval
Integerlimit-
Optional. Prices per currency pair. Defaul is 10. Min is 1. Max is 1_000
Integeroffset-
Optional. Default is 0. Min is 0. Max is 100_000
249 250 251 252 253 254 |
# File 'lib/cryptomarket/client.rb', line 249 def get_trades_by_symbol(symbol: nil, by: nil, sort: nil, from: nil, till: nil, limit: nil, offset: nil) # rubocop:disable Metrics/ParameterLists public_get( "public/trades/#{symbol}", { by:, sort:, from:, till:, limit:, offset: } ) end |
#get_trading_commission(symbol:) ⇒ Object Also known as: get_trading_commission_of_symbol, get_trading_commission_by_symbol
Get the personal trading commission rate of a symbol
Requires the “Place/cancel orders” API key Access Right
api.exchange.cryptomkt.com/#get-trading-commission
Params
Stringsymbol-
The symbol of the commission rate
623 624 625 626 627 |
# File 'lib/cryptomarket/client.rb', line 623 def get_trading_commission(symbol:) commission = get("spot/fee/#{symbol}") commission['symbol'] = symbol commission end |
#get_transaction(id:) ⇒ Object
Get a transaction by its identifier
Requires the “Payment information” API key Access Right
api.exchange.cryptomkt.com/#get-transactions-history
Params
Stringid-
The identifier of the transaction
1073 1074 1075 |
# File 'lib/cryptomarket/client.rb', line 1073 def get_transaction(id:) get("wallet/transactions/#{id}") end |
#get_transaction_history(currency: nil, from: nil, till: nil, types: nil, subtypes: nil, statuses: nil, currencies: nil, networks: nil, id_from: nil, id_till: nil, tx_ids: nil, order_by: nil, sort: nil, limit: nil, offset: nil, group_transactions: nil) ⇒ Object
Get the transaction history of the account Important:
- The list of supported transaction types may be in future versions
- Some transaction subtypes are reserved for future use and do not purport to provide any functionality on the platform
- The list of supported transaction subtypes may be in future versions
Requires the “Payment information” API key Access Right
api.exchange.cryptomkt.com/#get-transactions-history
Params
Array[String]tx_ids-
Optional. List of transaction identifiers to query
Array[String]types-
Optional. List of transaction types to query. valid types are: ‘DEPOSIT’, ‘WITHDRAW’, ‘TRANSFER’ and ‘SWAP’
Array[String]subtyes-
Optional. List of transaction subtypes to query. valid subtypes are: ‘UNCLASSIFIED’, ‘BLOCKCHAIN’, ‘AIRDROP’, ‘AFFILIATE’, ‘STAKING’, ‘BUY_CRYPTO’, ‘OFFCHAIN’, ‘FIAT’, ‘SUB_ACCOUNT’, ‘WALLET_TO_SPOT’, ‘SPOT_TO_WALLET’, ‘WALLET_TO_DERIVATIVES’, ‘DERIVATIVES_TO_WALLET’, ‘CHAIN_SWITCH_FROM’, ‘CHAIN_SWITCH_TO’ and ‘INSTANT_EXCHANGE’
Array[String]statuses-
Optional. List of statuses to query. valid subtypes are: ‘CREATED’, ‘PENDING’, ‘FAILED’, ‘SUCCESS’ and ‘ROLLED_BACK’
Array[String]currencies-
Optional. Currency codes of the transactions to fetch
Array[String]networks-
Optional. Network codes of the transactions to fetch
Stringorder_by-
Optional. sorting parameter.‘created_at’, ‘updated_at’, ‘last_activity_at’ ‘or ’id’.
Stringfrom-
Optional. Optional. Interval initial value (inclusive). The value type depends on order_by
Stringtill-
Optional. Interval end value (inclusive). The value type depends on order_BY
Stringid_from-
Optional. Interval initial value when ordering by id. Min is 0
Stringid_till-
Optional. Interval end value when ordering by id. Min is 0
Stringsort-
Optional. Sort direction. ‘ASC’ or ‘DESC’. Default is ‘DESC’
Integerlimit-
Optional. Transactions per query. Defaul is 100. Max is 1_000
Integeroffset-
Optional. Default is 0. Max is 100_000
boolgroup_transactions-
Optional. Flag indicating whether the returned transactions will be parts of a single operation. Default is false
1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 |
# File 'lib/cryptomarket/client.rb', line 1051 def get_transaction_history( # rubocop:disable Metrics/ParameterLists currency: nil, from: nil, till: nil, types: nil, subtypes: nil, statuses: nil, currencies: nil, networks: nil, id_from: nil, id_till: nil, tx_ids: nil, order_by: nil, sort: nil, limit: nil, offset: nil, group_transactions: nil ) get( 'wallet/transactions', { currency:, from:, till:, types:, subtypes:, statuses:, currencies:, networks:, id_from:, id_till:, tx_ids:, order_by:, sort:, limit:, offset:, group_transactions: } ) end |
#get_wallet_balance(currency:) ⇒ Object Also known as: get_wallet_balance_of_currency, get_wallet_balance_by_currency
Get the user’s wallet balance of a currency
Requires the “Payment information” API key Access Right
api.exchange.cryptomkt.com/#wallet-balance
Params
Stringcurrency-
The currency code to query the balance
711 712 713 |
# File 'lib/cryptomarket/client.rb', line 711 def get_wallet_balance(currency:) get("wallet/balance/#{currency}") end |
#get_wallet_balances ⇒ Object
Get the user’s wallet balance for all currencies with balance
Requires the “Payment information” API key Access Right
698 699 700 |
# File 'lib/cryptomarket/client.rb', line 698 def get_wallet_balances # rubocop:disable Naming/AccessorMethodName get('wallet/balance') end |
#get_whitelisted_addresses ⇒ Object
Gets the list of whitelisted addresses
Requires the “Payment information” API key Access Right
720 721 722 |
# File 'lib/cryptomarket/client.rb', line 720 def get_whitelisted_addresses # rubocop:disable Naming/AccessorMethodName get('wallet/crypto/address/white-list') end |
#get_withdrawal_fees_hash ⇒ Object
Gets the hash of withdrawal fees
Requires the “Payment information” API key Access Right
891 892 893 |
# File 'lib/cryptomarket/client.rb', line 891 def get_withdrawal_fees_hash get('wallet/crypto/fee/withdraw/hash')['hash'] end |
#offchain_available?(currency:, address:, payment_id: nil) ⇒ Boolean
get the status of the offchain
Requires the “Payment information” API key Access Right
api.exchange.cryptomkt.com/#check-if-offchain-is-available
Params
Stringcurrency-
currency code
Stringaddress-
address identifier
Stringpayment id-
Optional.
1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 |
# File 'lib/cryptomarket/client.rb', line 1088 def offchain_available?( currency:, address:, payment_id: nil ) post( 'wallet/crypto/check-offchain-available', { currency:, address:, payment_id: } )['result'] end |
#patch(endpoint, params = nil) ⇒ Object
34 35 36 |
# File 'lib/cryptomarket/client.rb', line 34 def patch(endpoint, params = nil) @http_manager.make_request(method: 'patch', endpoint:, params:) end |
#post(endpoint, params = nil) ⇒ Object
26 27 28 |
# File 'lib/cryptomarket/client.rb', line 26 def post(endpoint, params = nil) @http_manager.make_post_request(method: 'post', endpoint:, params:) end |
#public_get(endpoint, params = nil) ⇒ Object
18 19 20 |
# File 'lib/cryptomarket/client.rb', line 18 def public_get(endpoint, params = nil) @http_manager.make_request(method: 'get', endpoint:, params:, public: true) end |
#put(endpoint, params = nil) ⇒ Object
30 31 32 |
# File 'lib/cryptomarket/client.rb', line 30 def put(endpoint, params = nil) @http_manager.make_request(method: 'put', endpoint:, params:) end |
#replace_spot_order(client_order_id:, new_client_order_id:, quantity:, price: nil, stop_price: nil, strict_validate: nil) ⇒ Object
Replaces a spot order For fee, for price accuracy and quantity, and for order status information see the api docs
Requires the “Place/cancel orders” API key Access Right
api.exchange.cryptomkt.com/#replace-spot-order
Params
Stringclient_order_id-
client order id of the old order
Stringnew client order id-
client order id for the new order
Stringquantity-
Order quantity
boolstrict_validate-
Price and quantity will be checked for incrementation within the symbol’s tick size and quantity step. See the symbol’s tick_size and quantity_increment
Stringprice-
Required if order type is ‘limit’, ‘stopLimit’, or ‘takeProfitLimit’. Order price
Stringstop_price-
Required if order type is ‘stopLimit’, ‘stopMarket’, ‘takeProfitLimit’, or ‘takeProfitMarket’. Order stop price
560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 |
# File 'lib/cryptomarket/client.rb', line 560 def replace_spot_order( client_order_id:, new_client_order_id:, quantity:, price: nil, stop_price: nil, strict_validate: nil ) patch( "spot/order/#{client_order_id}", { new_client_order_id:, price:, stop_price:, quantity:, strict_validate: } ) end |
#transfer_between_wallet_and_exchange(currency:, amount:, source:, destination:) ⇒ Object
Transfer funds between account types ‘source’ param and ‘destination’ param must be different account types
Requires the “Payment information” API key Access Right
api.exchange.cryptomkt.com/#transfer-between-wallet-and-exchange
Params
Stringcurrency-
currency code for transfering
floatamount-
amount to be transfered
Stringsource-
transfer source account type. Either ‘wallet’ or ‘spot’
Stringdestination-
transfer source account type. Either ‘wallet’ or ‘spot’
988 989 990 991 992 993 994 995 996 997 998 |
# File 'lib/cryptomarket/client.rb', line 988 def transfer_between_wallet_and_exchange(currency:, amount:, source:, destination:) post( 'wallet/transfer', { currency:, amount:, source:, destination: } ) end |
#transfer_funds(sub_account_id:, amount:, currency:, type:) ⇒ Object
Transfers funds from the super-account to a sub-account or from a sub-account to the super-account and returns the transaction id
Requires the “Withdraw cryptocurrencies” API key Access Right
api.exchange.cryptomkt.com/#transfer-funds
Params
Stringsub_account_ids-
id of the sub-account to transfer funds from/to
Stringamount-
amount to transfer
Stringcurrency-
currency to transfer
Stringtype-
Direction of transfer, “to_sub_account” or “from_sub_account”
1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 |
# File 'lib/cryptomarket/client.rb', line 1196 def transfer_funds( sub_account_id:, amount:, currency:, type: ) post( 'sub-account/transfer', { sub_account_id:, amount:, currency:, type: } )['result'] end |
#transfer_money_to_another_user(currency:, amount:, by:, identifier:) ⇒ Object
Transfer funds to another user
Requires the “Withdraw cryptocurrencies” API key Access Right
api.exchange.cryptomkt.com/#transfer-money-to-another-user
Params
Stringcurrency-
currency code
floatamount-
amount to be transfered
Stringtransfer by-
type of identifier. Either ‘email’ or ‘username’
Stringidentifier-
the email or username of the recieving user
1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 |
# File 'lib/cryptomarket/client.rb', line 1012 def transfer_money_to_another_user(currency:, amount:, by:, identifier:) post( 'wallet/internal/withdraw', { currency:, amount:, by:, identifier: } ) end |
#transfer_to_another_subaccount(sub_account_id:, amount:, currency:) ⇒ Object
Creates and commits a transfer between the user (subaccount) and another subaccount.
Call is being sent by a subaccount
Created but not committed transfer will reserve pending amount on the sender wallet affecting their ability to withdraw or transfer crypto to another account. Incomplete withdrawals affect subaccount transfers the same way
Requires the “Withdraw cryptocurrencies” API key Access Right
api.exchange.cryptomkt.com/#transfer-across-subaccounts
Params
Stringsub_account_ids-
id of the sub-account to transfer funds from/to
Stringamount-
amount to transfer
Stringcurrency-
currency to transfer
1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 |
# File 'lib/cryptomarket/client.rb', line 1258 def transfer_to_another_subaccount( sub_account_id:, amount:, currency: ) post( 'sub-account/transfer/sub-to-sub', { sub_account_id:, amount:, currency: } )['result'] end |
#transfer_to_super_account(amount:, currency:) ⇒ Object
Creates and commits a transfer from a subaccount to its super account
Call is being sent by a subaccount
Created but not committed transfer will reserve pending amount on the sender wallet affecting their ability to withdraw or transfer crypto to another account. Incomplete withdrawals affect subaccount transfers the same way
Requires the “Withdraw cryptocurrencies” API key Access Right
api.exchange.cryptomkt.com/#transfer-to-super-account
Params
Stringamount-
amount to transfer
Stringcurrency-
currency to transfer
1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 |
# File 'lib/cryptomarket/client.rb', line 1228 def transfer_to_super_account( amount:, currency: ) post( 'sub-account/transfer/sub-to-super', { amount:, currency: } )['result'] end |
#withdraw_crypto(currency:, amount:, address:, network_code: nil, payment_id: nil, include_fee: nil, auto_commit: nil, use_offchain: nil, public_comment: nil) ⇒ Object
Please take note that changing security settings affects withdrawals:
-
It is impossible to withdraw funds without enabling the two-factor authentication (2FA)
-
Password reset blocks withdrawals for 72 hours
-
Each time a new address is added to the whitelist, it takes 48 hours before that address becomes active for withdrawal
Successful response to the request does not necessarily mean the resulting transaction got executed immediately. It has to be processed first and may eventually be rolled back To see whether a transaction has been finalized, call #get_transaction
Requires the “Withdraw cryptocurrencies” API key Access Right
api.exchange.cryptomkt.com/#withdraw-crypto
Params
Stringcurrency-
currency code of the crypto to withdraw
floatamount-
amount to be sent to the specified address
Stringaddress-
address identifier
Stringnetwork_code-
Optional. network code
Stringpayment id-
Optional.
boolinclude fee-
Optional. If true then the amount includes fees. Default is false
boolauto commit-
Optional. If false then you should commit or rollback the transaction in an hour. Used in two phase commit schema. Default is true
Stringuse offchain-
Optional. Whether the withdrawal may be comitted offchain. Accepted values are ‘never’, ‘optionaly’ and ‘required’.
Stringpublic comment-
Optional. Maximum lenght is 255
819 820 821 822 823 824 825 826 827 828 829 |
# File 'lib/cryptomarket/client.rb', line 819 def withdraw_crypto( # rubocop:disable Metrics/ParameterLists currency:, amount:, address:, network_code: nil, payment_id: nil, include_fee: nil, auto_commit: nil, use_offchain: nil, public_comment: nil ) post( 'wallet/crypto/withdraw', { currency:, amount:, address:, network_code:, payment_id:, include_fee:, auto_commit:, use_offchain:, public_comment: } )['id'] end |
#withdraw_crypto_commit(id:) ⇒ Object
Commit a withdrawal
Requires the “Withdraw cryptocurrencies” API key Access Right
api.exchange.cryptomkt.com/#withdraw-crypto-commit-or-rollback
Params
Stringid-
the withdrawal transaction identifier
840 841 842 |
# File 'lib/cryptomarket/client.rb', line 840 def withdraw_crypto_commit(id:) put("wallet/crypto/withdraw/#{id}")['result'] end |
#withdraw_crypto_rollback(id:) ⇒ Object
Rollback a withdrawal
Requires the “Withdraw cryptocurrencies” API key Access Right
api.exchange.cryptomkt.com/#withdraw-crypto-commit-or-rollback
Params
Stringid-
the withdrawal transaction identifier
853 854 855 |
# File 'lib/cryptomarket/client.rb', line 853 def withdraw_crypto_rollback(id:) delete("wallet/crypto/withdraw/#{id}")['result'] end |