This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (cryptocom) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Cryptocom
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
Usage/Example
Installing:
npm i cryptocom
Initialisation
const cryptocom =require("cryptocom");const cdc =newcryptocom(API_KEY,API_SECRET);//const cdc = new cryptocom(); for only public
Public Endpoints
get_instruments()
Provides information on all supported symbols (e.g. BTC_USDT)
cdc.get_instruments().then().catch();
get_book(symbol, depth)
Fetches the public order book for a particular symbol and depth
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();
get_ticker(symbol)
Fetches the public tickers for an symbol (e.g. BTC_USDT).
symbol can be omitted to show tickers for all symbol
Param
Type
Required
Description
symbol
string
N
e.g. BTC_USDT, ETH_CRO, etc.
cdc.get_ticker("BTC_USDT").then().catch();
get_candlestick(interval, symbol)
Retrieves candlesticks (k-line data history) over a given period for an instrument (e.g. BTC_USDT)
Param
Type
Required
Description
interval
string
Y
See below*
symbol
string
Y
e.g. BTC_USDT, ETH_CRO, etc.
*Period can be:
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
Creates a withdrawal request. Withdrawal setting must be enabled for your API Key
If you do not see the option when viewing your API Key, this feature is not yet available for you.
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.
Options:
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();
get_withdrawal_history(options)
Fetches withdrawal history. Withdrawal setting must be enabled for your API Key
If you do not see the option when viewing your API Key, this feature is not yet available for you.
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.
Options:
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
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();// Buys 5000 CRO at 0.06579 or cheaper price IF CRO price is greater or equal to 0.06579 USDTlet 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();// Sells 5000 CRO at 0.06579 or higher price IF CRO price is smaller or equal to 0.06579 USDT
cancel_order(symbol, order_id)
Cancels an existing order on the Exchange (asynchronous)
*This call is asynchronous, so the response is simply a confirmation of the request.
*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.
get_open_orders(options)
Gets all open orders for a particular instrument
Param
Type
Required
Description
options
object
N
see table below
Options:
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();//get all oopen orderslet options ={instrument_name:"CRO_USDT",}
cdc.get_order_history(options).then().catch();//get open orders for CRO_USDT pair
Gets all executed trades for a particular instrument.
Param
Type
Required
Description
options
object
N
see table below
Options:
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();//with defaultslet options ={instrument_name:"CRO_USDT",page:3}
cdc.get_trades(options).then().catch();//get excuted trades for CRO_USDT pair
*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.