Skip to content

omurtsckr/Node.js-Library

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Previous version of this doc here

JavaScript SDK for CryptoAPIs.io

You can get API key here.

Docs here.

How to install

$ npm install cryptoapis.io

How to use

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)

Generate new address

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"
  }
}

Usage notes

  • required arguments (e.g. getBlockByHeight(blockHeight) means the correct usage is getBlockByHeight(567)
  • one of arguments (e.g. transferTokens(fromAddress, toAddress, contract, gasPrice, gasLimit, token, password/privateKey) means the following are correct usages:
    1. transferTokens(fromAddress, toAddress, contract, gasPrice, gasLimit, token, password)
    2. 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:
    1. getAddressTransactions(address)
    2. getAddressTransactions(address, {index: 1})
    3. getAddressTransactions(address, {limit: 10})
    4. getAddressTransactions(address, {index: 1, limit: 10}) and if omitted, the default values are given in = {index: 0, limit: 50} meaning getAddressTransactions(address) implies index: 0 and limit: 50 unless specified otherwise via usages ii, iii, iv

Blockchain as a Service APIs

List of all methods available

NOTES:

  • XXX - blockchain (BTC / BCH / LTC / DOGE / DASH / ETH / ETC / ZIL)
  • doc links target BTC / ETH in our documentation to avoid repetition. For other blockchains refer to the corresponding parts in our documentation

BTC / BCH / LTC / DOGE / DASH methods

Blockchain methods

  • 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)

Addresses methods

  • 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)

Wallets methods

  • 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)

Transaction methods

  • caClient.BC.XXX.transaction.getTransaction(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)

Payment Forwarding methods

  • 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)

Webhook methods

  • caClient.BC.XXX.webhook.createNewBlockWebHook(callbackURL) (docs)
  • caClient.BC.XXX.webhook.createConfirmedTransactionWebHook(callbackURL, transaction, confirmations) (docs)
  • caClient.BC.XXX.webhook.createAddressTransactionWebHook(callbackURL, address, confirmations) (docs)
  • caClient.BC.XXX.webhook.createTransactionConfirmationsWebHook(callbackURL, address, confirmations) (docs)
  • (BTC only) caClient.BC.XXX.webhook.createOmniConfirmedTransactionWebHook(callbackURL, transaction, confirmations) (docs)
  • (BTC only) caClient.BC.XXX.webhook.createOmniTransactionConfirmationsWebHook(callbackURL, address, confirmations) (docs)
  • (BTC only) caClient.BC.XXX.webhook.createOmniTokenWebHook(callbackURL, address, confirmations) (docs)
  • caClient.BC.XXX.webhook.listAllHooks() (docs)
  • caClient.BC.XXX.webhook.deleteWebHook(webhookID) (docs)
  • caClient.BC.XXX.webhook.deleteAllMyWebhooks() (docs)

Omni Layer methods

  • (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)

ETH / ETC methods

Blockchain methods

  • 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)

Addresses methods

  • 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)

Transaction methods

  • 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)

Contract methods

  • caClient.BC.XXX.contract.estimateSmartContractGas() (docs)
  • caClient.BC.XXX.contract.deploySmartContract(privateKey, fromAddress, gasPrice, gasLimit, byteCode) (docs)

Tokens methods

  • 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)

Payment Forwarding methods

  • caClient.BC.XXX.paymentForwarding.createPaymentForwarding(from, to, callbackURL, wallet, password, confirmations, ?{?fee} = {fee: null}) (docs)
  • caClient.BC.XXX.paymentForwarding.deletePayment(paymentID) (docs)
  • caClient.BC.XXX.paymentForwarding.listPayments() (docs)
  • caClient.BC.XXX.paymentForwarding.listPaymentsHistory() (docs)

Webhook methods

  • caClient.BC.XXX.webhook.createNewBlockWebHook(callbackURL) (docs)
  • caClient.BC.XXX.webhook.createConfirmedTransactionWebHook(callbackURL, transaction, confirmations) (docs)
  • caClient.BC.XXX.webhook.createAddressTransactionWebHook(callbackURL, address, confirmations) (docs)
  • caClient.BC.XXX.webhook.createTransactionConfirmationsWebHook(callbackURL, address, confirmations) (docs)
  • (ETH only) caClient.BC.XXX.webhook.createTokenWebHook(callbackURL, address, confirmations) (docs)
  • caClient.BC.XXX.webhook.listAllHooks() (docs)
  • caClient.BC.XXX.webhook.deleteWebHook(webhookID) (docs)
  • caClient.BC.XXX.webhook.deleteAllMyWebhooks() (docs)

ZIL methods

Blockchain methods

  • 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)

Addresses methods

  • 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)

Transaction methods

  • 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)

Crypto Market Data APIs

Metadata

  • 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)

Base data

  • 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)

Exchange Rates

  • 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)

OHLCV

  • 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)

Trades

  • 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)

Order Book

  • caClient.CMD.orderBook.getSnapshotBySymbol(symbolId) (docs)

Trading APIs

Exchange Accounts

  • 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)

Private APIs

  • 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)

Arbitrage

  • caClient.TR.arbitrage.listAll() (docs)

About

Node.js wrapper for Crypto APIs

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%