UNPKG

cmc-api

Version:

CoinMarketCap RESTful API Wrapper. Supports endpoints cryptocurrency, exchanges (CEX), decentralized exchange (DEX), global metrics, community content and trends, tools and others.

96 lines 3.89 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CoinMarketCapApi = void 0; const cex_repository_1 = require("../repositories/cex.repository"); const community_repository_1 = require("../repositories/community.repository"); const crypto_repository_1 = require("../repositories/crypto.repository"); const dex_repository_1 = require("../repositories/dex.repository"); const metric_repository_1 = require("../repositories/metric.repository"); const misc_repository_1 = require("../repositories/misc.repository"); const client_1 = require("./client"); /** * The CoinMarketCap API. * * **Quick Start Guide** * 1. Sign up for a free API key at [CoinMarketCap](https://pro.coinmarketcap.com/signup). * 2. Copy your API Key. Once you sign up you'll land on your Developer Portal account dashboard. Copy your API from the API Key box in the top left panel. * 3. Install the [cmc-api](https://www.npmjs.com/package/cmc-api) package using npm or yarn. * 4. Create a new instance of the CoinMarketCapApi class and pass your API key as an argument. * 5. Start making API calls! * * @remarks * The **[cmc-api](https://www.npmjs.com/package/cmc-api)** is an generic api wrapper for [CoinMarketCap](https://coinmarketcap.com). * The [CoinMarketCap API](https://pro.coinmarketcap.com/api/v1) is a suite of high-performance RESTful JSON endpoints that are specifically designed to meet the mission-critical demands of application developers, data scientists, and enterprise business platforms. * It provides access to high-frequency cryptocurrency market data such as price, volume, and market cap. * * @example using an production API key * ```typescript * import { CoinMarketCapApi } from "cmc-api"; * * const apikey = process.env.COINMARKETCAP_APIKEY; * const cmc = new CoinMarketCapApi(apikey); * ``` * * @example using sandbox * ```typescript * import { CoinMarketCapApi } from "cmc-api"; * const cmc = CoinMarketCapApi.sandbox(); // or (new CoinMarketCapApi()).sandbox(); * ``` */ class CoinMarketCapApi { /** * Creates an instance of CoinMarketCapApi. * @param apikey - Optional API key for authentication. */ constructor(apikey) { /** * The client instance used to make API requests. */ this.client = new client_1.Client(); /** * Repository for cryptocurrency-related operations. */ this.crypto = new crypto_repository_1.CryptoRepository(this); /** * Repository for decentralized exchange-related operations. */ this.dex = new dex_repository_1.DexRepository(this); /** * Repository for centralized exchange-related operations. */ this.cex = new cex_repository_1.CexRepository(this); /** * Repository for metric-related operations. */ this.metric = new metric_repository_1.MetricRepository(this); /** * Repository for community-related operations. */ this.community = new community_repository_1.CommunityRepository(this); /** * Repository for miscellaneous operations. */ this.misc = new misc_repository_1.MiscRepository(this); if (apikey) this.client.setApiKey(apikey); } /** * Switches the client to sandbox mode. * @returns The CoinMarketCapApi instance in sandbox mode. */ sandbox() { this.client.sandbox(); return this; } /** * Creates a new CoinMarketCapApi instance in sandbox mode. * @returns A new CoinMarketCapApi instance in sandbox mode. */ static sandbox() { const instance = new CoinMarketCapApi(); instance.client = instance.client.sandbox(); return instance; } } exports.CoinMarketCapApi = CoinMarketCapApi; //# sourceMappingURL=api.js.map