Previous version of this doc here
JavaScript SDK for CryptoAPIs.io
You can get API key here.
Docs here.
$ npm install cryptoapis.io
const CryptoApis = require('cryptoapis.io');
const apiKey = 'your API key';
const caClient = new CryptoApis(apiKey);
// You can use several instances of the client which can coexist in the same environment
// By default the calls are made to the mainnet for each chain.
// The selected network for each chain at any moment can be checked with the <chain>.getSelectedNetwork() method.
caClient.BC.DOGE.getSelectedNetwork();
// To switch to a different network you need to call the <chain>.switchNetwork method.
// The network can be specified via the respective <chain>.NETWORKS.<network>
caClient.BC.ETH.switchNetwork(caClient.BC.ETH.NETWORKS.ROPSTEN);
caClient.BC.BTC.switchNetwork(caClient.BC.BTC.NETWORKS.TESTNET);
caClient.BC.BCH.switchNetwork(caClient.BC.BCH.NETWORKS.TESTNET);
caClient.BC.LTC.switchNetwork(caClient.BC.LTC.NETWORKS.TESTNET);
caClient.BC.DOGE.switchNetwork(caClient.BC.DOGE.NETWORKS.TESTNET);
caClient.BC.DASH.switchNetwork(caClient.BC.DASH.NETWORKS.TESTNET);
// Or by passing a valid network name for the chain
caClient.BC.ETH.switchNetwork('rinkeby');
Examples (for more examples, you can check out the tests)
caClient.BC.ETH.address.generateAddress()
.then(function(result) {
console.log(result);
})
.catch(function(err) {
console.error(err);
});
It will print the following:
{
"payload": {
"address": "0xd1b99ca3971c06af48474aa6606ec885e7aff600",
"privateKey": "31f5d2a8d3f4a816fb498200423461ec52aefe579c13b807a8140c7a7ecc8448",
"publicKey": "51767e84342ea3d10faf35676997cf1dbd4d2c0168fe46a4a920c4c1f557bc8851445ff17aaba144546e7aac45b1754352d860c617eff441778c4e053178f97b"
}
}
required
arguments (e.g.getBlockByHeight(blockHeight)
means the correct usage isgetBlockByHeight(567)
one of
arguments (e.g.transferTokens(fromAddress, toAddress, contract, gasPrice, gasLimit, token, password/privateKey)
means the following are correct usages:transferTokens(fromAddress, toAddress, contract, gasPrice, gasLimit, token, password)
transferTokens(fromAddress, toAddress, contract, gasPrice, gasLimit, token, privateKey)
optional
arguments are marked with?
(e.g.getAddressTransactions(address, ?{?index, ?limit} = {index: 0, limit: 50}
means the following are all correct usages:getAddressTransactions(address)
getAddressTransactions(address, {index: 1})
getAddressTransactions(address, {limit: 10})
getAddressTransactions(address, {index: 1, limit: 10})
and if omitted, the default values are given in= {index: 0, limit: 50}
meaninggetAddressTransactions(address)
impliesindex: 0
andlimit: 50
unless specified otherwise via usagesii
,iii
,iv
NOTES:
- XXX - blockchain (BTC / BCH / LTC / DOGE / DASH / ETH / ETC / ZIL, XRP)
- doc links target BTC / ETH in our documentation to avoid repetition. For other blockchains refer to the corresponding parts in our documentation
- caClient.BC.XXX.blockchain.getInfo() (docs)
- caClient.BC.XXX.blockchain.getBlockByHash(blockHash) (docs)
- caClient.BC.XXX.blockchain.getBlockByHeight(blockHeight) (docs)
- caClient.BC.XXX.blockchain.getLatestBlock() (docs)
- caClient.BC.XXX.address.getInfo(address) (docs)
- (
BTC / BCH / LTC only
) caClient.BC.XXX.address.getInfoMultisig(address, ?{?limit} = {limit: 50}) (docs) - caClient.BC.XXX.address.generateAddress() (docs)
- caClient.BC.XXX.address.getAddressTransactions(address, ?{?index, ?limit} = {index: 0, limit: 50}) (docs)
- caClient.BC.XXX.address.multipleAddressesInfo(addresses) (docs)
- caClient.BC.XXX.address.getUnconfirmedByAddress(address, ?{?index, ?limit} = {index: 0, limit: 50}) (docs)
- caClient.BC.XXX.wallet.createWallet(name, addresses) (docs)
- caClient.BC.XXX.wallet.createHDWallet(name, addressCount, password) (docs)
- caClient.BC.XXX.wallet.listWallets() (docs)
- caClient.BC.XXX.wallet.listHDWallets() (docs)
- caClient.BC.XXX.wallet.getWallet(walletName) (docs)
- caClient.BC.XXX.wallet.getHDWallet(walletName) (docs)
- caClient.BC.XXX.wallet.addAddressToWallet(name, addresses) (docs)
- caClient.BC.XXX.wallet.generateAddressInWallet(name) (docs)
- caClient.BC.XXX.wallet.generateAddressInHDWallet(name, addressCount, password) (docs)
- caClient.BC.XXX.wallet.removeAddressFromWallet(name, address) (docs)
- caClient.BC.XXX.wallet.deleteWallet(name) (docs)
- caClient.BC.XXX.wallet.deleteHDWallet(name) (docs)
- caClient.BC.XXX.wallet.createXPub(password) (docs)
- caClient.BC.XXX.wallet.getXPubChangeAddresses(xpub, from, to) (docs)
- caClient.BC.XXX.wallet.getXPubReceiveAddresses(xpub, from, to) (docs)
- caClient.BC.XXX.wallet.importAddressAsWallet(walletName, password, privateKey, address) (docs)
- caClient.BC.XXX.transaction.getTransaction(txID) (docs)
- caClient.BC.XXX.transaction.getBasicTransaction(txID) (docs)
- caClient.BC.XXX.transaction.getTransactionIndexByBlock(block, ?{?index, ?limit} = {index: 0, limit: 1}) (docs)
- caClient.BC.XXX.transaction.getUnconfirmedTransactions(?{?index, ?limit} = {index: 0, limit: 100}) (docs)
- caClient.BC.XXX.transaction.decodeRawTransaction(hex) (docs)
- caClient.BC.XXX.transaction.createTransaction(inputs, outputs, fee) (docs)
- caClient.BC.XXX.transaction.signTransaction(hex, wifs) (docs)
- caClient.BC.XXX.transaction.sendTransaction(hex) (docs)
- caClient.BC.XXX.transaction.newTransaction(inputs, outputs, fee, wifs) (docs)
- caClient.BC.XXX.transaction.createHDWalletTransaction(walletName, password, outputs, fee, ?{?inputs, ?locktime} = {inputs: null, locktime: 0}) (docs)
- caClient.BC.XXX.transaction.getTransactionsFee() (docs)
- caClient.BC.XXX.transaction.getTransactionSize(inputs, outputs, fee) (docs)
- caClient.BC.XXX.transaction.refund(txid, wif) (docs)
- caClient.BC.XXX.transaction.getTransactionSizeForHDWallet(walletName, password, outputs) (docs)
- caClient.BC.XXX.paymentForwarding.createPaymentForwarding(from, to, callbackURL, wallet, password, confirmations, ?{?fee} = {fee: null}) (docs)
- caClient.BC.XXX.paymentForwarding.listPayments() (docs)
- caClient.BC.XXX.paymentForwarding.listPaymentsHistory() (docs)
- caClient.BC.XXX.paymentForwarding.deletePayment(paymentID) (docs)
- caClient.BC.XXX.webhook.createNewBlockWebHook(callbackURL, ?{allowDuplicate} = {allowDuplicate: false}) (docs)
- caClient.BC.XXX.webhook.createConfirmedTransactionWebHook(callbackURL, transaction, confirmations, ?{allowDuplicate} = {allowDuplicate: false}) (docs)
- caClient.BC.XXX.webhook.createAddressTransactionWebHook(callbackURL, address, confirmations, ?{allowDuplicate} = {allowDuplicate: false}) (docs)
- caClient.BC.XXX.webhook.createTransactionConfirmationsWebHook(callbackURL, address, confirmations, ?{allowDuplicate} = {allowDuplicate: false}) (docs)
- (
BTC only
) caClient.BC.XXX.webhook.createOmniConfirmedTransactionWebHook(callbackURL, transaction, confirmations, ?{allowDuplicate} = {allowDuplicate: false}) (docs) - (
BTC only
) caClient.BC.XXX.webhook.createOmniTransactionConfirmationsWebHook(callbackURL, address, confirmations, ?{allowDuplicate} = {allowDuplicate: false}) (docs) - (
BTC only
) caClient.BC.XXX.webhook.createOmniTokenWebHook(callbackURL, address, confirmations, ?{?allowDuplicate, ?everyConfirmation} = {allowDuplicate: false, everyConfirmation: false}}) (docs) - caClient.BC.XXX.webhook.listAllHooks() (docs)
- caClient.BC.XXX.webhook.deleteWebHook(webhookID) (docs)
- caClient.BC.XXX.webhook.deleteAllMyWebhooks() (docs)
- (
BTC only
) caClient.BC.XXX.omniLayer.getNodeInfo() (docs) - (
BTC only
) caClient.BC.XXX.omniLayer.getAddress(address) (docs) - (
BTC only
) caClient.BC.XXX.omniLayer.getAddressTransactions(address) (docs) - (
BTC only
) caClient.BC.XXX.omniLayer.createTransactions(from, to, value, fee, propertyID) (docs) - (
BTC only
) caClient.BC.XXX.omniLayer.signTransaction(hex, wif) (docs) - (
BTC only
) caClient.BC.XXX.omniLayer.sendTransaction(hex) (docs) - (
BTC only
) caClient.BC.XXX.omniLayer.newTransaction(from, to, value, fee, propertyID, wif) (docs) - (
BTC only
) caClient.BC.XXX.omniLayer.createHDWalletTransaction(walletName, password, from, to, value, fee, propertyID, ?{?locktime} = {locktime: 0}) (docs) - (
BTC only
) caClient.BC.XXX.omniLayer.getTransaction(txID) (docs) - (
BTC only
) caClient.BC.XXX.omniLayer.getTransactionIndexByBlock(block, ?{?index, ?limit} = {index: 0, limit: 1}) (docs) - (
BTC only
) caClient.BC.XXX.omniLayer.getTransactionsPropertyId(propertyId, ?{?index, ?limit} = {index: 0, limit: 50}) (docs) - (
BTC only
) caClient.BC.XXX.omniLayer.getUnconfirmedTransactions(?{?index} = {index: 0}) (docs)
- caClient.BC.XXX.blockchain.getInfo() (docs)
- caClient.BC.XXX.blockchain.getBlockByHash(blockHash) (docs)
- caClient.BC.XXX.blockchain.getBlockByHeight(blockHeight) (docs)
- caClient.BC.XXX.blockchain.getLatestBlock() (docs)
- caClient.BC.XXX.address.getInfo(address) (docs)
- caClient.BC.XXX.address.getTransactionsByAddress(address) (docs)
- caClient.BC.XXX.address.generateAddress() (docs)
- caClient.BC.XXX.address.generateAccount(password) (docs)
- caClient.BC.XXX.address.getAddressNonce(address) (docs)
- caClient.BC.XXX.address.multipleAddressesInfo(addresses) (docs)
- caClient.BC.XXX.transaction.getTransaction(txHash) (docs)
- caClient.BC.XXX.transaction.getTransactionsByBlock(block, ?{?index, ?limit} = {index: 0, limit: 50}) (docs)
- caClient.BC.XXX.transaction.getTransactionByBlockNumber(blockNumber, txIndex) (docs)
- caClient.BC.XXX.transaction.getTransactionByBlockHash(blockHash, txIndex) (docs)
- caClient.BC.XXX.transaction.newTransaction(fromAddress, toAddress, password, value, gasPrice, gasLimit, ?{?nonce, ?data} = {nonce: null, data: null}) (docs)
- caClient.BC.XXX.transaction.newAllTransaction(fromAddress, toAddress, password, ?{?gasPrice, ?gasLimit} = {gasPrice: null, gasLimit: null}) (docs)
- caClient.BC.XXX.transaction.newTransactionWithPrivateKey(fromAddress, toAddress, privateKey, value, gasPrice, gasLimit, ?{?nonce, ?data} = {nonce: null, data: null}) (docs)
- caClient.BC.XXX.transaction.newAllTransactionWithPrivateKey(fromAddress, toAddress, privateKey, ?{?gasPrice, ?gasLimit} = {gasPrice: null, gasLimit: null}) (docs)
- caClient.BC.XXX.transaction.sendTransaction(fromAddress, toAddress, value) (docs)
- caClient.BC.XXX.transaction.pushTransaction(hex) (docs)
- caClient.BC.XXX.transaction.getPendingTransactions(?{?limit} = {limit: 50}) (docs)
- caClient.BC.XXX.transaction.getQueuedTransactions(?{?limit} = {limit: 50}) (docs)
- caClient.BC.XXX.transaction.estimateTransactionGas(fromAddress, toAddress, value) (docs)
- caClient.BC.XXX.transaction.getTransactionsFee() (docs)
- (
ETH only
) caClient.BC.XXX.transaction.getInternalTransaction(txHash) (docs) - caClient.BC.XXX.transaction.refund(txid, wif) (docs)
- caClient.BC.XXX.contract.estimateSmartContractGas() (docs)
- caClient.BC.XXX.contract.deploySmartContract(privateKey, fromAddress, gasPrice, gasLimit, byteCode) (docs)
- (
ETH only
) caClient.BC.XXX.contract.getContractGasPrice() (docs)
- caClient.BC.XXX.token.getAddressTokenBalance(address, contract) (docs)
- caClient.BC.XXX.token.transferTokens(fromAddress, toAddress, contract, gasPrice, gasLimit, token, password/privateKey) (docs)
- (
ETH only
) caClient.BC.XXX.token.getTokenTransactionsByAddress(address, ?{?limit} = {limit: 50}) (docs) - (
ETH only
) caClient.BC.XXX.token.getAddressTokenTransfers(address, ?{?limit} = {limit: 50}) (docs) - caClient.BC.XXX.token.getTokenTotalSupplyAndDecimals(contract) (docs)
- (
ETH only
) caClient.BC.XXX.token.estimateTokenTransactionGasLimit() (docs)
- caClient.BC.XXX.paymentForwarding.createPaymentForwarding(from, to, callbackURL, wallet, password, confirmations, ?{?fee} = {fee: null}) (docs)
- (
ETH only
) caClient.BC.XXX.paymentForwarding.createPaymentForwardingWithPrivateKey(from, to, callbackURL, privateKey, confirmations, ?{?gasPrice, ?gasLimit} = {gasPrice: null, gasLimit: null}) (docs) - caClient.BC.XXX.paymentForwarding.deletePayment(paymentID) (docs)
- caClient.BC.XXX.paymentForwarding.listPayments() (docs)
- caClient.BC.XXX.paymentForwarding.listPaymentsHistory() (docs)
- caClient.BC.XXX.webhook.createNewBlockWebHook(callbackURL, ?{allowDuplicate} = {allowDuplicate: false}) (docs)
- caClient.BC.XXX.webhook.createConfirmedTransactionWebHook(callbackURL, transaction, confirmations, ?{allowDuplicate} = {allowDuplicate: false}) (docs)
- caClient.BC.XXX.webhook.createAddressTransactionWebHook(callbackURL, address, confirmations, ?{allowDuplicate} = {allowDuplicate: false}) (docs)
- caClient.BC.XXX.webhook.createTransactionConfirmationsWebHook(callbackURL, address, confirmations, ?{allowDuplicate} = {allowDuplicate: false}) (docs)
- (
ETH only
) caClient.BC.XXX.webhook.createTokenWebHook(callbackURL, address, confirmations, ?{?allowDuplicate, ?everyConfirmation} = {allowDuplicate: false, everyConfirmation: false}}) (docs) - caClient.BC.XXX.webhook.listAllHooks() (docs)
- caClient.BC.XXX.webhook.deleteWebHook(webhookID) (docs)
- caClient.BC.XXX.webhook.deleteAllMyWebhooks() (docs)
- caClient.BC.XXX.blockchain.getInfo() (docs)
- caClient.BC.XXX.blockchain.getBlockByHash(blockHash) (docs)
- caClient.BC.XXX.blockchain.getBlockByHeight(blockHeight) (docs)
- caClient.BC.XXX.blockchain.getLatestBlock() (docs)
- caClient.BC.XXX.address.getInfo(address) (docs)
- caClient.BC.XXX.address.getAddressTransactions(address, ?{?index, ?limit} = {index: 0, limit: 50}) (docs)
- caClient.BC.XXX.address.generateAddress() (docs)
- caClient.BC.XXX.transaction.getTransaction(txHash) (docs)
- caClient.BC.XXX.transaction.getTransactionsByBlock(block, ?{?index, ?limit} = {index: 0, limit: 50}) (docs)
- caClient.BC.XXX.transaction.getTransactionByBlockNumber(blockNumber, txIndex) (docs)
- caClient.BC.XXX.transaction.getTransactionByBlockHash(blockHash, txIndex) (docs)
- caClient.BC.XXX.blockchain.getInfo() (docs)
- caClient.BC.XXX.blockchain.getBlockByHash(blockHash) (docs)
- caClient.BC.XXX.blockchain.getBlockByHeight(blockHeight) (docs)
- caClient.BC.XXX.blockchain.getLatestBlock() (docs)
- caClient.BC.XXX.address.getInfo(address) (docs)
- caClient.BC.XXX.address.getAddressTransactions(address, ?{?index, ?limit} = {index: 0, limit: 50}) (docs)
- caClient.BC.XXX.address.generateAddress() (docs)
- caClient.BC.XXX.transaction.getTransaction(txHash) (docs)
- caClient.BC.XXX.transaction.getTransactionsByBlock(block, ?{?index, ?limit} = {index: 0, limit: 50}) (docs)
- caClient.BC.XXX.transaction.getTransactionByBlockNumber(blockNumber, txIndex) (docs)
- caClient.BC.XXX.transaction.getTransactionByBlockHash(blockHash, txIndex) (docs)
- caClient.BC.XXX.transaction.pushTransaction(hex) (docs)
- caClient.BC.XXX.webhook.createNewBlockWebHook(callbackURL, ?{allowDuplicate} = {allowDuplicate: false}) (docs)
- caClient.BC.XXX.webhook.createAddressTransactionWebHook(callbackURL, address, confirmations, ?{allowDuplicate} = {allowDuplicate: false}) (docs)
- caClient.BC.XXX.webhook.createTransactionConfirmationsWebHook(callbackURL, address, confirmations, ?{allowDuplicate} = {allowDuplicate: false}) (docs)
- caClient.BC.XXX.webhook.listAllHooks() (docs)
- caClient.BC.XXX.webhook.deleteWebHook(webhookID) (docs)
- caClient.BC.XXX.webhook.deleteAllMyWebhooks() (docs)
- caClient.CMD.meta.listAllExchanges(?{?skip, ?limit} = {skip: 0, limit: 50}) (docs)
- caClient.CMD.meta.listExchangesBySupportingAssets(assetId, ?{?skip, ?limit} = {skip: 0, limit: 50}) (docs)
- caClient.CMD.meta.listExchangesBySupportingPairs(assetId_1, assetId_2, ?{?skip, ?limit} = {skip: 0, limit: 50}) (docs)
- caClient.CMD.meta.listAllSymbolsSupportedInExchange(exchangeId, ?{?skip, ?limit} = {skip: 0, limit: 50}) (docs)
- caClient.CMD.meta.listAllAssets(?{?skip, ?limit} = {skip: 0, limit: 50}) (docs)
- caClient.CMD.meta.listAllSymbols(?{?skip, ?limit} = {skip: 0, limit: 50}) (docs)
- caClient.CMD.base.listAllExchanges(?{?skip, ?limit} = {skip: 0, limit: 50}) (docs)
- caClient.CMD.base.getExchangeDetails(exchangeId) (docs)
- caClient.CMD.base.listAllAssets(?{?skip, ?limit} = {skip: 0, limit: 50}) (docs)
- caClient.CMD.base.getAssetDetails(assetId) (docs)
- caClient.CMD.base.getSymbolDetails(symbolId) (docs)
- caClient.CMD.exchangeRates.getSpecificRate(baseAssetId, quoteAssetId, ?{?timestamp} = {timestamp: null}) (docs)
- caClient.CMD.exchangeRates.getAllCurrentRates(baseAssetId, ?{?skip, ?limit} = {skip: 0, limit: 50}) (docs)
- caClient.CMD.exchangeRates.getSpecificRateInSpecificExchange(exchangeId, baseAssetId, quoteAssetId, ?{?timestamp} = {timestamp: null}) (docs)
- caClient.CMD.exchangeRates.getAllCurrentRatesInSpecificExchange(exchangeId, baseAssetId, ?{?timestamp, ?skip, ?limit} = {timestamp: null, skip: 0, limit: 50}) (docs)
- caClient.CMD.OHLCV.listAllPeriods() (docs)
- caClient.CMD.OHLCV.latestData(symbolId, periodId, ?{?limit} = {limit: 50}) (docs)
- caClient.CMD.OHLCV.historicalData(symbolId, period, timePeriodStart, timePeriodEnd, ?{?limit} = {limit: 50}) (docs)
- caClient.CMD.trades.getLatestData(?{?limit} = {limit: 50}) (docs)
- caClient.CMD.trades.getLatestDataBySymbol(symbolId, ?{?skip, ?limit} = {skip: 0, limit: 50}) (docs)
- caClient.CMD.trades.getLatestDataByExchange(exchangeId, ?{?skip, ?limit} = {skip: 0, limit: 50}) (docs)
- caClient.CMD.trades.getLatestDataByAsset(baseAsset, ?{?skip, ?limit} = {skip: 0, limit: 50}) (docs)
- caClient.CMD.trades.getLatestDataByAssetsPair(baseAsset, quoteAsset, ?{?skip, ?limit} = {skip: 0, limit: 50}) (docs)
- caClient.CMD.trades.getLatestDataByExchangeAssetsPair(exchangeId, baseAsset, quoteAsset, ?{?skip, ?limit} = {skip: 0, limit: 50}) (docs)
- caClient.CMD.trades.tradesGetHistoricalData(symbolId, timeStart, timeEnd, ?{?skip, ?limit} = {skip: 0, limit: 50}) (docs)
- caClient.CMD.trades.tradesGetHistoricalDataByExchange(exchangeId, timeStart, timeEnd, ?{?skip, ?limit} = {skip: 0, limit: 50}) (docs)
- caClient.CMD.trades.tradesGetHistoricalDataByAsset(baseAsset, timeStart, timeEnd, ?{?skip, ?limit} = {skip: 0, limit: 50}) (docs)
- caClient.CMD.trades.tradesGetHistoricalDataByAssetPair(baseAsset, quoteAsset, timeStart, timeEnd, ?{?skip, ?limit} = {skip: 0, limit: 50}) (docs)
- caClient.CMD.trades.tradesGetHistoricalDataByExchangeAssetPair(exchangeId, baseAsset, quoteAsset, timeStart, timeEnd, ?{?skip, ?limit} = {skip: 0, limit: 50}) (docs)
- caClient.CMD.orderBook.getSnapshotBySymbol(symbolId) (docs)
- caClient.TR.exchangeAccounts.create(exchangeId, exchangeApiKey) (docs)
- caClient.TR.exchangeAccounts.listAll() (docs)
- caClient.TR.exchangeAccounts.get(accountId) (docs)
- caClient.TR.exchangeAccounts.update(accountId) (docs)
- caClient.TR.exchangeAccounts.delete(accountId) (docs)
- caClient.TR.privateAPIs.listAllExchanges() (docs)
- caClient.TR.privateAPIs.getBalance(accountId) (docs)
- caClient.TR.privateAPIs.getDepositAddress(accountId, code) (docs)
- caClient.TR.privateAPIs.getMyTrades(accountId) (docs)
- caClient.TR.privateAPIs.getOpenOrders(accountId) (docs)
- caClient.TR.privateAPIs.createOrder(accountId, symbol, type, side, amount, price) (docs)
- caClient.TR.privateAPIs.cancelOrder(accountId, id) (docs)
- caClient.TR.privateAPIs.withdraw(accountId, code, amount, address) (docs)
- caClient.TR.arbitrage.listAll() (docs)