🌎 English | 🌎 Português | 🌎 Español
A Node.js library for interacting with the Coinsamba API, which provides access to cryptocurrency data and exchange information.
npm install @coinsamba/coinsamba-node-sdk
const { Coinsamba } = require('@coinsamba/coinsamba-node-sdk');
// Create an instance of Coinsamba API
const coinsamba = new Coinsamba({ isDev: true });
// Retrieve ticker data
coinsamba.getTicker('BTC', 'USD', 'exchange123')
.then(ticker => {
console.log(ticker);
})
.catch(error => {
console.error(error);
});
// Retrieve index data
coinsamba.getIndex('BTC', 'USD')
.then(index => {
console.log(index);
})
.catch(error => {
console.error(error);
});
// Retrieve available exchanges
coinsamba.getExchanges()
.then(exchanges => {
console.log(exchanges);
})
.catch(error => {
console.error(error);
});
Creates a new instance of the Coinsamba API.
options
(optional): An object containing configuration options for the Coinsamba API instance.isDev
(optional): A boolean indicating whether the library is in development mode. Default:false
.
Retrieves ticker data for the specified base and quote currency.
base
(string): The base currency symbol.quote
(string): The quote currency symbol.exchangeId
(optional): The exchange ID. If provided, it will filter the results based on the exchange.
- A Promise that resolves to an array of
Ticker
objects.
Retrieves index data for the specified base and quote currency.
base
(string): The base currency symbol.quote
(string): The quote currency symbol.
- A Promise that resolves to an
Index
object.
Retrieves a list of available exchanges.
- A Promise that resolves to an array of exchange names.
The library includes the following types for better code organization and type safety:
Represents ticker data for a cryptocurrency pair.
interface Ticker {
exchangeId: string;
base: string;
quote: string;
last: number;
ask: number;
bid: number;
vol: number;
updatedAt: string;
}
Represents index data for a cryptocurrency pair.
interface Index {
open: number;
high: number;
low: number;
close: number;
vol: number;
change: number;
}