A wrapper for the Crypto.com REST API. Uses promises. For more information on the API and parameters for requests visit https://exchange-docs.crypto.com
npm i cryptocom
const cryptocom = require("cryptocom");
const cdc = new cryptocom(API_KEY, API_SECRET);
cdc.get_instruments().then().catch();
| Param |
Type |
Required |
Description |
| symbol |
string |
Y |
e.g. BTC_USDT, ETH_CRO, etc. |
| depth |
number |
N |
Number of bids and asks to return (up to 150) |
cdc.get_book("BTC_USDT", 10).then().catch();
| Param |
Type |
Required |
Description |
| symbol |
string |
N |
e.g. BTC_USDT, ETH_CRO, etc. |
cdc.get_ticker("BTC_USDT").then().catch();
| Param |
Type |
Required |
Description |
| interval |
string |
Y |
See below* |
| symbol |
string |
Y |
e.g. BTC_USDT, ETH_CRO, etc. |
1m : one minute
5m : five minutes
15m : 15 minutes
30m: 30 minutes
1h : one hour
4h : 4 hours
6h : 6 hours
12h : 12 hours
1D : one day
7D : one week
14D : two weeks
1M : one month
cdc.get_candlestick("5m", "BTC_USDT").then().catch();
| Param |
Type |
Required |
Description |
| symbol |
string |
N |
e.g. BTC_USDT, ETH_CRO, etc. |
cdc.get_trades("BTC_USDT").then().catch();
| Param |
Type |
Required |
Description |
| currency |
string |
Y |
e.g. BTC, CRO |
| amount |
decimal |
Y |
amount to withdraw |
| address |
string |
Y |
withdrawal address |
| options |
object |
N |
see table below |
*Withdrawal addresses must first be whitelisted in your account’s Withdrawal Whitelist page.
*Withdrawal fees and minimum withdrawal amount can be found on the Fees & Limits page on the Exchange website.
| Param |
Type |
Required |
Description |
| client_wid |
string |
N |
Client withdrawal ID |
| address_tag |
string |
N |
Secondary address identifier for coins like XRP, XLM etc. Also known as memo or tags. |
let options = {
client_wid: "my_withdrawal_002",
address_tag: "1234567"
}
cdc.create_withdrawal("XRP", 10, "0x23...", options).then().catch();
| Param |
Type |
Required |
Description |
| options |
object |
N |
see table below |
*Withdrawal addresses must first be whitelisted in your account’s Withdrawal Whitelist page.
*Withdrawal fees and minimum withdrawal amount can be found on the Fees & Limits page on the Exchange website.
| Param |
Type |
Required |
Description |
| currency |
string |
N |
E.g. BTC, CRO |
| start_ts |
long |
N |
timestamp is in milliseconds. Default is 90 days from current timestamp |
| end_ts |
string |
N |
timestamp is in milliseconds. Default is current timestamp |
| page_size |
int |
N |
Page size (Default: 20, Max: 200) |
| page |
int |
N |
Page number (0-based) |
| status |
string |
N |
e.g. "0" (see below*) |
0 - Pending
1 - Processing
2 - Rejected
3 - Payment In-progress
4 - Payment Failed
5 - Completed
6 - Cancelled
let options = {
currency: "CRO",
page: "3",
status: "5"
}
cdc.get_withdrawal_history(options).then().catch();
| Param |
Type |
Required |
Description |
| currency |
string |
N |
Specific currency, e.g. CRO. Omit for 'all' |
cdc.account("CRO").then().catch();
*This call is asynchronous, so the response is simply a confirmation of the request.
| Param |
Type |
Required |
Description |
| symbol |
string |
Y |
e.g., ETH_CRO, BTC_USDT |
| price |
number |
Y |
Unit price |
| quantity |
number |
Y |
Order Quantity to buy |
| options |
object |
N |
see table below |
| Param |
Type |
Required |
Description |
| client_oid |
string |
N |
Client order ID |
| time_in_force |
string |
N |
GOOD_TILL_CANCEL (Default)/ FILL_OR_KILL / IMMEDIATE_OR_CANCEL |
| exec_inst |
string |
N |
POST_ONLY / leave empty |
let options = {
client_oid: "my_order_01"
}
cdc.limit_buy("CRO_USDT", "0.06466", 5000, options).then().catch();
let options_2 = {
client_oid: "my_order_02",
time_in_force: "FILL_OR_KILL"
}
cdc.limit_sell("CRO_USDT", "0.06766", 5000, options_2).then().catch();
*This call is asynchronous, so the response is simply a confirmation of the request.
| Param |
Type |
Required |
Description |
| symbol |
string |
Y |
e.g., ETH_CRO, BTC_USDT |
| notional |
number |
Y |
Amount to spend |
| client_oid |
string |
N |
Client order ID |
cdc.market_buy("CRO_USDT", 20, "my_order").then().catch();
*This call is asynchronous, so the response is simply a confirmation of the request.
| Param |
Type |
Required |
Description |
| symbol |
string |
Y |
e.g., ETH_CRO, BTC_USDT |
| quantity |
number |
Y |
Quantity to be Sold |
| client_oid |
string |
N |
Client order ID |
cdc.market_sell("CRO_USDT", 5000, "my_order").then().catch();
*This call is asynchronous, so the response is simply a confirmation of the request.
| Param |
Type |
Required |
Description |
| symbol |
string |
Y |
e.g., ETH_CRO, BTC_USDT |
| notional |
number |
Y |
Amount to spend |
| trigger_price |
number |
Y |
Dictates when order will be triggered |
| client_oid |
string |
N |
Client order ID |
cdc.stop_loss_buy("CRO_USDT", 20, "0.00009", "my_order").then().catch();
*This call is asynchronous, so the response is simply a confirmation of the request.
| Param |
Type |
Required |
Description |
| symbol |
string |
Y |
e.g., ETH_CRO, BTC_USDT |
| quantity |
number |
Y |
Quantity to be Sold |
| trigger_price |
number |
Y |
Dictates when order will be triggered |
| client_oid |
string |
N |
Client order ID |
cdc.stop_loss_buy("CRO_USDT", 5000, "0.00009", "my_order").then().catch();
*This call is asynchronous, so the response is simply a confirmation of the request.
| Param |
Type |
Required |
Description |
| symbol |
string |
Y |
e.g., ETH_CRO, BTC_USDT |
| price |
number |
Y |
Unit price |
| quantity |
number |
Y |
Quantity to Buy |
| trigger_price |
number |
Y |
Dictates when order will be triggered |
| options |
object |
N |
see table below |
| Param |
Type |
Required |
Description |
| client_oid |
string |
N |
Client order ID |
| time_in_force |
string |
N |
GOOD_TILL_CANCEL (Default)/ FILL_OR_KILL / IMMEDIATE_OR_CANCEL |
| exec_inst |
string |
N |
POST_ONLY / leave empty |
let options = {
client_oid: "my_order_02",
time_in_force: "FILL_OR_KILL"
}
cdc.stop_limit_buy("CRO_USDT", "0.06579", 5000, "0.06579", options).then().catch();
let options_2 = {
client_oid: "my_order_02",
time_in_force: "FILL_OR_KILL"
}
cdc.stop_limit_sell("CRO_USDT", "0.06579", 5000, "0.06579", options_2).then().catch();
*This call is asynchronous, so the response is simply a confirmation of the request.
| Param |
Type |
Required |
Description |
| symbol |
string |
Y |
e.g., ETH_CRO, BTC_USDT |
| order_id |
string |
Y |
ID of order to be cancelled |
cdc.cancel_order("CRO_USDT", "1164074220874569090").then().catch();
*This call is asynchronous, so the response is simply a confirmation of the request.
| Param |
Type |
Required |
Description |
| symbol |
string |
Y |
e.g., ETH_CRO, BTC_USDT |
cdc.cancel_all_orders("CRO_USDT").then().catch();
| Param |
Type |
Required |
Description |
| options |
object |
N |
see table below |
| Param |
Type |
Required |
Description |
| instrument_name |
string |
N |
e.g. ETH_CRO, BTC_USDT. Omit for 'all' |
| start_ts |
long |
N |
Start timestamp (milliseconds since the Unix epoch) - defaults to 24 hours ago |
| end_ts |
long |
N |
End timestamp (milliseconds since the Unix epoch) - defaults to 'now' |
| page_size |
int |
N |
Page size (Default: 20, max: 200) |
| page |
int |
N |
Page number (0-based) |
cdc.get_order_history().then().catch();
let options = {
instrument_name: "CRO_USDT",
start_ts: "1612529644978",
page: 2
}
cdc.get_order_history(options).then().catch();
*The maximum duration between start_ts and end_ts is 24 hours.
You will receive an INVALID_DATE_RANGE error if the difference exceeds the maximum duration.
For users looking to pull longer historical order data, users can create a loop to make a request for each 24-period from the desired start to end time.
| Param |
Type |
Required |
Description |
| options |
object |
N |
see table below |
| Param |
Type |
Required |
Description |
| instrument_name |
string |
N |
e.g. ETH_CRO, BTC_USDT. Omit for 'all' |
| page_size |
int |
N |
Page size (Default: 20, max: 200) |
| page |
int |
N |
Page number (0-based) |
cdc.get_open_orders().then().catch();
let options = {
instrument_name: "CRO_USDT",
}
cdc.get_order_history(options).then().catch();
| Param |
Type |
Required |
Description |
| order_id |
string |
Y |
Order ID |
cdc.get_order_details("1164074220874569090").then().catch();
| Param |
Type |
Required |
Description |
| options |
object |
N |
see table below |
| Param |
Type |
Required |
Description |
| instrument_name |
string |
N |
e.g. ETH_CRO, BTC_USDT. Omit for 'all' |
| start_ts |
long |
N |
Start timestamp (milliseconds since the Unix epoch) - defaults to 24 hours ago |
| end_ts |
long |
N |
End timestamp (milliseconds since the Unix epoch) - defaults to 'now' |
| page_size |
int |
N |
Page size (Default: 20, max: 200) |
| page |
int |
N |
Page number (0-based) |
cdc.get_trades().then().catch();
let options = {
instrument_name: "CRO_USDT",
page: 3
}
cdc.get_trades(options).then().catch();
*The maximum duration between start_ts and end_ts is 24 hours.
You will receive an INVALID_DATE_RANGE error if the difference exceeds the maximum duration.
For users looking to pull longer historical trade data, users can create a loop to make a request for each 24-period from the desired start to end time.