Javascript SDK for CoinMarketCap
npm install coinmarketcap-jsA javascript SDK for interacting with the free version of the CoinMarketCap API.
``bash`
npm install coinmarketcap-js
To take advantage of the TypeScript typings (for intellisense / autocomplete) while using CommonJS imports with require(), use the following approach:
`js
const restClient = require("coinmarketcap-js").default;
const rest = restClient("API KEY");
// rest.
`
`typescript
import { restClient } from "coinmarketcap-js";
const rest = restClient("API KEY");
// Can now use API
const idMapResult = await rest.crypto.idMap({ limit: 1 });
const infoResult = await rest.crypto.info({ symbol: "BTC" });
`
- Cryptocurrency
- categories
- category
- idMap
- info
- latestListings
- latestQuotes
- Fiat
- idMap
- Exchange
- info
- idMap
- Global
- latestQuotes
- Tools
- priceConversion
Returns paginated data about all coin categories.
Options Object?:
| | |
| ------- | -------- |
| id? | String |Number
| start? | |Number
| limit? | |String
| slug? | |String
| symbol? | |
Example:
`typescript
import { restClient } from "coinmarketcap-js";
const rest = restClient("API KEY");
try {
const result = await rest.crypto.categories({ limit: 1, symbol: "BTC" });
} catch (error) {
console.log(error);
}
`
Returns data about a single coin category.
Options Object:
| | |
| ---------- | -------- |
| id | String |Number
| start? | |Number
| limit? | |String
| convert? | |String
| convertId? | |
Example:
`typescript
import { restClient } from "coinmarketcap-js";
const rest = restClient("API KEY");
try {
const category = await rest.crypto.category({
id: "categoryID",
limit: 1,
});
} catch (error) {
console.log(error);
}
`
Returns all or a paginated list of cryptocurrencies.
Options Object?:
| | |
| -------------- | -------- |
| listingStatus? | String |Number
| start? | |Number
| limit? | |String
| sort? | |String
| symbol? | |String
| aux? | |
Example:
`typescript
import { restClient } from "coinmarketcap-js";
const rest = restClient("API KEY");
try {
const result = await rest.crypto.idMap({ limit: 100 });
} catch (error) {
console.log(error);
}
`
Returns static data for one or many cryptocurrencies.
Options Object?:
| | |
| -------- | -------- |
| id? | String |String
| slug? | |String
| symbol? | |String
| address? | |String
| aux? | |
Example:
`typescript
import { restClient } from "coinmarketcap-js";
const rest = restClient("API KEY");
try {
const result = await rest.crypto.info({ symbol: "BTC" });
} catch (error) {
console.log(error);
}
`
Returns paginated list of all active cryptocurrencies along with latest market data.
Options Object?:
| | |
| --------------------- | -------- |
| start? | Number |Number
| limit? | |Number
| priceMin? | |Number
| priceMax? | |Number
| marketCapMin? | |Number
| marketCapMax? | |Number
| volume24hMin? | |Number
| volume24hMax? | |Number
| circulatingSupplyMin? | |Number
| circulatingSupplyMax? | |Number
| percentChange24hMin? | |Number
| percentChange24hMax? | |String
| convert? | |String
| convertId? | |String
| sort? | |String
| sortDir? | |String
| cryptocurrencyType? | |String
| tag? | |String
| aux? | |
Example:
`typescript
import { restClient } from "coinmarketcap-js";
const rest = restClient("API KEY");
try {
const result = await rest.crypto.latestListings({ limit: 50 });
} catch (error) {
console.log(error);
}
`
Returns the latest market quote data for one or many cryptocurrencies.
Options Object?:
| | |
| ------------ | --------- |
| id? | Number |String
| slug? | |String
| symbol? | |String
| convert? | |String
| convertId? | |String
| aux? | |Boolean
| skipInvalid? | |
Example:
`typescript
import { restClient } from "coinmarketcap-js";
const rest = restClient("API KEY");
try {
const result = await rest.crypto.latestQuotes({ symbol: "BTC" });
} catch (error) {
console.log(error);
}
`
Returns data about fiat currencies with unique CoinMarketCap ids.
Options Object?:
| | |
| -------------- | --------- |
| start? | Number |Number
| limit? | |String
| sort? | |Boolean
| includeMetals? | |
Example:
`typescript
import { restClient } from "coinmarketcap-js";
const rest = restClient("API KEY");
try {
const result = await rest.fiat.idMap({ limit: 1 });
} catch (error) {
console.log(error);
}
`
Returns static data for one or more exchanges.
Options Object?:
| | |
| ----- | -------- |
| id? | String |String
| slug? | |String
| aux? | |
Example:
`typescript
import { restClient } from "coinmarketcap-js";
const rest = restClient("API KEY");
try {
const result = await rest.exchange.info({ id: "270" });
} catch (error) {
console.log(error);
}
`
Returns a paginated list of all active cryptocurrency exchanges per CoinMarketCap ID
Options Object?:
| | |
| -------------- | -------- |
| listingStatus? | String |String
| slug? | |Number
| start? | |Number
| limit? | |String
| sort? | |String
| aux? | |String
| cryptoId? | |
Example:
`typescript
import { restClient } from "coinmarketcap-js";
const rest = restClient("API KEY");
try {
const result = await rest.exchange.idMap({ limit: 1 });
} catch (error) {
console.log(error);
}
`
Returns the latest global cryptocurrency market metrics.
Options Object?:
| | |
| ---------- | -------- |
| convert? | String |String
| convertId? | |
Example:
`typescript
import { restClient } from "coinmarketcap-js";
const rest = restClient("API KEY");
try {
const result = await rest.global.latestQuotes();
} catch (error) {
console.log(error);
}
`
Convert provided amount of one cryptocurrency or fiat currency into one or more different currencies using the latest market rate for each currency.
Options Object:
| | |
| ---------- | -------- |
| amount | Number |String
| id? | |String
| symbol? | |String
| time? | |String
| convert? | |String
| convertId? | |
Example:
`typescript
import { restClient } from "coinmarketcap-js";
const rest = restClient("API KEY");
try {
const result = await rest.tools.priceConversion({
amount: 100,
symbol: "BTC",
});
} catch (error) {
console.log(error);
}
``