// npm install coincapjs --save
const CoinCap = require('coincapjs');
CoinCap.getAssets({
cb: function (err, status, result) {
if (err) throw err;
console.log(`Data Length: ${result.dataLen}`);
console.log(`First Result: ${JSON.parse(result.data[0])}`);
},
});
CoinCap.getAssets({ ...params?, function: cb? })
CoinCap.getRates({ ...params?, function: cb? })
CoinCap.getExchanges({ ...params?, function: cb? })
CoinCap.getMarkets({ ...params?, function: cb })
CoinCap.getCandles({ ...params?, function: cb })
- Changed around prototypes to match hierarchy.
- Deprecated
collection(Object: params, function: cb)
- Interfaces now do the same job as
collection
did.
- Interfaces now do the same job as
// OLD
CoinCap.getAssets.collection({}, function (err, status, result) {});
// CURRENT
CoinCap.getAssets({ cb: function (err, status, result) {} });
// Call assets directly
CoinCap.call('assets', '{{id}}', { id: 'bitcoin' }, (err, status, res) => {
if (err) throw err;
console.log(
`CoinCap.call('assets', '{{id}}', { id: 'bitcoin' })[ ${status} ]: ${res.dataLen}`,
);
});
// Get asset collection
CoinCap.getAssets({
cb: function (err, status, res) {
if (err) {
throw err;
}
console.log(
`CoinCap.getAssets()[${status}]: ${res.dataLen}\n${res.data[0]}`,
);
},
});
// Get asset by id "bitcoin"
CoinCap.getAssets().byId('bitcoin', function (err, status, res) {
if (err) {
throw err;
}
console.log(
`CoinCap.getAssets().byId('bitcoin')[${status}]: ${res.dataLen}\n${res.data[0]}`,
);
});
// interval: m1, m5, m15, m30, h1, h2, h6, h12, d1
CoinCap.getAssets({ interval: 'd1' })
.byId('bitcoin')
.history(function (err, status, res) {
if (err) {
throw err;
}
console.log(
`CoinCap.getAssets({ interval: 'd1' }).byId('bitcoin')[${status}]: ${res.dataLen}\n${res.data[0]}`,
);
});
CoinCap.getAssets()
.byId('bitcoin')
.markets(function (err, status, res) {
if (err) {
throw err;
}
console.log(
`CoinCap.getAssets().byId('bitcoin').markets[${status}]:`,
res.dataLen,
);
});
CoinCap.getRates({
cb: function (err, status, res) {
if (err) {
throw err;
}
console.log(`CoinCap.getRates[${status}]:`, res.dataLen);
},
});
CoinCap.getRates().byId('bitcoin', function (err, status, res) {
if (err) {
throw err;
}
console.log(`CoinCap.getRates().byId('bitcoin')[${status}]:`, res.dataLen);
});
CoinCap.getExchanges().byId('bitcoin', function (err, status, res) {
if (err) {
throw err;
}
console.log(
`CoinCap.getExchanges().byId('bitcoin')[${status}]:`,
res.dataLen,
);
});
CoinCap.getMarkets({
exchangeId: 'quoine',
cb: function (err, status, res) {
if (err) {
throw err;
}
console.log(
`CoinCap.getMarkets({ exchangeId: 'quoine' })[${status}]:`,
res.dataLen,
);
},
});
CoinCap.getCandles({
exchange: 'poloniex',
interval: 'm1',
baseId: 'ethereum',
quoteId: 'bitcoin',
cb: function (err, status, res) {
if (err) {
throw err;
}
console.log(
`CoinCap.getCandles({ exchange: 'poloniex', interval: 'm1', baseId: 'ethereum', quoteId: 'bitcoin' })[${status}]:`,
res.dataLen,
);
},
});