npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

coinmarketcap-js

v1.7.0

Published

Javascript SDK for CoinMarketCap

Downloads

1,385

Readme

coinmarketcap-js

A javascript SDK for interacting with the free version of the CoinMarketCap API.

Install

npm install coinmarketcap-js

Quick Start

Note: CommonJS usage

To take advantage of the TypeScript typings (for intellisense / autocomplete) while using CommonJS imports with require(), use the following approach:

const restClient = require("coinmarketcap-js").default;

const rest = restClient("API KEY");

// rest.<method> will now provide autocomplete and parameter typings

ESM usage

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

API Methods

Cryptocurrency

categories

Returns paginated data about all coin categories.

Options Object?:

| | | | ------- | -------- | | id? | String | | start? | Number | | limit? | Number | | slug? | String | | symbol? | String |

Example:

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);
}

category

Returns data about a single coin category.

Options Object:

| | | | ---------- | -------- | | id | String | | start? | Number | | limit? | Number | | convert? | String | | convertId? | String |

Example:

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);
}

idMap

Returns all or a paginated list of cryptocurrencies.

Options Object?:

| | | | -------------- | -------- | | listingStatus? | String | | start? | Number | | limit? | Number | | sort? | String | | symbol? | String | | aux? | String |

Example:

import { restClient } from "coinmarketcap-js";

const rest = restClient("API KEY");

try {
  const result = await rest.crypto.idMap({ limit: 100 });
} catch (error) {
  console.log(error);
}

info

Returns static data for one or many cryptocurrencies.

Options Object?:

| | | | -------- | -------- | | id? | String | | slug? | String | | symbol? | String | | address? | String | | aux? | String |

Example:

import { restClient } from "coinmarketcap-js";

const rest = restClient("API KEY");

try {
  const result = await rest.crypto.info({ symbol: "BTC" });
} catch (error) {
  console.log(error);
}

latestListings

Returns paginated list of all active cryptocurrencies along with latest market data.

Options Object?:

| | | | --------------------- | -------- | | start? | Number | | limit? | Number | | priceMin? | Number | | priceMax? | Number | | marketCapMin? | Number | | marketCapMax? | Number | | volume24hMin? | Number | | volume24hMax? | Number | | circulatingSupplyMin? | Number | | circulatingSupplyMax? | Number | | percentChange24hMin? | Number | | percentChange24hMax? | Number | | convert? | String | | convertId? | String | | sort? | String | | sortDir? | String | | cryptocurrencyType? | String | | tag? | String | | aux? | String |

Example:

import { restClient } from "coinmarketcap-js";

const rest = restClient("API KEY");

try {
  const result = await rest.crypto.latestListings({ limit: 50 });
} catch (error) {
  console.log(error);
}

latestQuotes

Returns the latest market quote data for one or many cryptocurrencies.

Options Object?:

| | | | ------------ | --------- | | id? | Number | | slug? | String | | symbol? | String | | convert? | String | | convertId? | String | | aux? | String | | skipInvalid? | Boolean |

Example:

import { restClient } from "coinmarketcap-js";

const rest = restClient("API KEY");

try {
  const result = await rest.crypto.latestQuotes({ symbol: "BTC" });
} catch (error) {
  console.log(error);
}

Fiat

idMap

Returns data about fiat currencies with unique CoinMarketCap ids.

Options Object?:

| | | | -------------- | --------- | | start? | Number | | limit? | Number | | sort? | String | | includeMetals? | Boolean |

Example:

import { restClient } from "coinmarketcap-js";

const rest = restClient("API KEY");

try {
  const result = await rest.fiat.idMap({ limit: 1 });
} catch (error) {
  console.log(error);
}

Exchange

info

Returns static data for one or more exchanges.

Options Object?:

| | | | ----- | -------- | | id? | String | | slug? | String | | aux? | String |

Example:

import { restClient } from "coinmarketcap-js";

const rest = restClient("API KEY");

try {
  const result = await rest.exchange.info({ id: "270" });
} catch (error) {
  console.log(error);
}

idMap

Returns a paginated list of all active cryptocurrency exchanges per CoinMarketCap ID

Options Object?:

| | | | -------------- | -------- | | listingStatus? | String | | slug? | String | | start? | Number | | limit? | Number | | sort? | String | | aux? | String | | cryptoId? | String |

Example:

import { restClient } from "coinmarketcap-js";

const rest = restClient("API KEY");

try {
  const result = await rest.exchange.idMap({ limit: 1 });
} catch (error) {
  console.log(error);
}

Global

latestQuotes

Returns the latest global cryptocurrency market metrics.

Options Object?:

| | | | ---------- | -------- | | convert? | String | | convertId? | String |

Example:

import { restClient } from "coinmarketcap-js";

const rest = restClient("API KEY");

try {
  const result = await rest.global.latestQuotes();
} catch (error) {
  console.log(error);
}

Tools

priceConversion

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 | | id? | String | | symbol? | String | | time? | String | | convert? | String | | convertId? | String |

Example:

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);
}