SDKs & tools

TypeScript SDK

The official TypeScript/JavaScript SDK wraps the CoinMarketCap Pro API with full type definitions, automatic retries, and a namespace API grouped by endpoint category.

Get started

  1. Install the package

    TerminalCode
    npm install @coinmarketcap/sdk

    Or with Yarn / pnpm:

    TerminalCode
    yarn add @coinmarketcap/sdk pnpm add @coinmarketcap/sdk
  2. Create a client

    Set your API key from the Developer Portal. For keyless endpoints, use environment: 'public'.

    TypeScriptCode
    import { CoinMarketCap } from "@coinmarketcap/sdk"; const cmc = new CoinMarketCap({ apiKey: process.env.CMC_PRO_API_KEY!, });
  3. Call an endpoint

    Endpoints are grouped under cmc.api:

    TypeScriptCode
    const { data, error } = await cmc.api.cryptocurrency.quotesLatest({ query: { id: "1,1027" }, }); if (data) { console.log(data); }

    Or throw on error:

    TypeScriptCode
    const { data } = await cmc.api.cryptocurrency.quotesLatest({ query: { id: "1" }, throwOnError: true, });
  4. Handle errors

    The SDK returns typed error classes (or throws when throwOnError: true):

    TypeScriptCode
    import { RateLimitError, AuthenticationError, CMCError } from "@coinmarketcap/sdk"; const { data, error } = await cmc.api.cryptocurrency.quotesLatest({ query: { id: "1" }, }); if (error instanceof RateLimitError) { // 429 — check Retry-After header } else if (error instanceof AuthenticationError) { // 401 — check your API key } else if (error instanceof CMCError) { console.log(error.status, error.message); }

Public (keyless) mode

TypeScriptCode
import { CoinMarketCap } from "@coinmarketcap/sdk"; const cmc = new CoinMarketCap({ environment: "public" }); await cmc.api.cryptocurrency.listingsLatest({ query: { limit: 10 } });

See the Keyless Public API for available endpoints without a key.

Next steps