cmc-api
Version:
CoinMarketCap RESTful API Wrapper. Supports endpoints cryptocurrency, exchanges (CEX), decentralized exchange (DEX), global metrics, community content and trends, tools and others.
159 lines • 7.57 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CmcRequestError = exports.CmcMonthlyRateLimitError = exports.CmcMinuteRateLimitError = exports.CmcIpRateLimitError = exports.CmcDailyRateLimitError = exports.CmcPlanUnauthorizeError = exports.CmcPaymentRequiredError = exports.CmcPaymentExpiredError = exports.CmcMissingError = exports.CmcInvalidError = exports.CmcApikeyRequiredError = exports.CmcApikeyDisabledError = exports.CmcError = exports.CmcErrorCode = void 0;
/**
* Enumeration of possible error codes returned by the CMC API.
* @see {@link https://pro.coinmarketcap.com/api/v1#section/Errors-and-Rate-Limits | Error Response Codes}
* @enum
*/
var CmcErrorCode;
(function (CmcErrorCode) {
/** This API Key is invalid */
CmcErrorCode[CmcErrorCode["ApikeyInvalid"] = 1001] = "ApikeyInvalid";
/** API key missing */
CmcErrorCode[CmcErrorCode["ApikeyMissing"] = 1002] = "ApikeyMissing";
/**
* Your API Key must be activated.
* Please go to {@link https://pro.coinmarketcap.com/account/plan | CoinMarketCap Account Plan}
*/
CmcErrorCode[CmcErrorCode["ApikeyPlanRequiresPayment"] = 1003] = "ApikeyPlanRequiresPayment";
/** Your API Key's subscription plan has expired */
CmcErrorCode[CmcErrorCode["ApikeyPlanPaymentExpired"] = 1004] = "ApikeyPlanPaymentExpired";
/** An API Key is required for this call */
CmcErrorCode[CmcErrorCode["ApikeyRequired"] = 1005] = "ApikeyRequired";
/** Your API Key subscription plan doesn't support this endpoint */
CmcErrorCode[CmcErrorCode["ApikeyPlanNotAuthorized"] = 1006] = "ApikeyPlanNotAuthorized";
/** This API Key has been disabled. Please contact support */
CmcErrorCode[CmcErrorCode["ApikeyDisable"] = 1007] = "ApikeyDisable";
/** You've exceeded your API Key's HTTP request rate limit. Rate limits reset every minute */
CmcErrorCode[CmcErrorCode["ApikeyPlanMinuteRateLimitReached"] = 1008] = "ApikeyPlanMinuteRateLimitReached";
/** You've exceeded your API Key's daily rate limit */
CmcErrorCode[CmcErrorCode["ApikeyPlanDailyRateLimitReached"] = 1009] = "ApikeyPlanDailyRateLimitReached";
/** You've exceeded your API Key's monthly rate limit */
CmcErrorCode[CmcErrorCode["ApikeyPlanMonthlyRateLimitReached"] = 1010] = "ApikeyPlanMonthlyRateLimitReached";
/** You've hit an IP rate limit */
CmcErrorCode[CmcErrorCode["IpRateLimitReached"] = 1011] = "IpRateLimitReached";
})(CmcErrorCode || (exports.CmcErrorCode = CmcErrorCode = {}));
/**
* Abstract class representing a error of CMC API.
*
* @abstract
* @extends {Error}
*/
class CmcError extends Error {
/**
* Creates an instance of CmcError.
*
* @param {CmcStatusResponse} response - The response object from the CMC API.
* @param {unknown} data - Additional data associated with the error.
*/
constructor(response, data) {
super(response.error_message);
this.data = data;
this.errorCode = response.error_code;
this.errorMessage = response.error_message;
this.creditCount = response.credit_count;
this.elapsed = response.elapsed;
this.timestamp = response.timestamp;
if (this.notice)
this.notice = response.notice;
}
}
exports.CmcError = CmcError;
/**
* Error thrown when the provided API key for CoinMarketCap is disabled.
* @see {@link https://pro.coinmarketcap.com/api/v1#section/Errors-and-Rate-Limits | CoinMarketCap Errors and Rate Limits}
* @extends {CmcError}
*/
class CmcApikeyDisabledError extends CmcError {
}
exports.CmcApikeyDisabledError = CmcApikeyDisabledError;
/**
* Error thrown when a required API key for CoinMarketCap is missing.
* @see {@link https://pro.coinmarketcap.com/api/v1#section/Errors-and-Rate-Limits | CoinMarketCap Errors and Rate Limits}
* @extends {CmcError}
*/
class CmcApikeyRequiredError extends CmcError {
}
exports.CmcApikeyRequiredError = CmcApikeyRequiredError;
/**
* Error thrown when the provided API key for CoinMarketCap is invalid.
* @see {@link https://pro.coinmarketcap.com/api/v1#section/Errors-and-Rate-Limits | CoinMarketCap Errors and Rate Limits}
* @extends {CmcError}
*/
class CmcInvalidError extends CmcError {
}
exports.CmcInvalidError = CmcInvalidError;
/**
* Error thrown when the provided API key for CoinMarketCap is missing.
* @see {@link https://pro.coinmarketcap.com/api/v1#section/Errors-and-Rate-Limits | CoinMarketCap Errors and Rate Limits}
* @extends {CmcError}
*/
class CmcMissingError extends CmcError {
}
exports.CmcMissingError = CmcMissingError;
/**
* Error thrown when the provided API key for CoinMarketCap's subscription plan has expired.
* @see {@link https://pro.coinmarketcap.com/api/v1#section/Errors-and-Rate-Limits | CoinMarketCap Errors and Rate Limits}
* @extends {CmcError}
*/
class CmcPaymentExpiredError extends CmcError {
}
exports.CmcPaymentExpiredError = CmcPaymentExpiredError;
/**
* Error thrown when the provided API key for CoinMarketCap requires payment.
* @see {@link https://pro.coinmarketcap.com/api/v1#section/Errors-and-Rate-Limits | CoinMarketCap Errors and Rate Limits}
* @extends {CmcError}
*/
class CmcPaymentRequiredError extends CmcError {
}
exports.CmcPaymentRequiredError = CmcPaymentRequiredError;
/**
* Error thrown when the provided API key for CoinMarketCap's subscription plan does not support the endpoint.
* @see {@link https://pro.coinmarketcap.com/api/v1#section/Errors-and-Rate-Limits | CoinMarketCap Errors and Rate Limits}
* @extends {CmcError}
*/
class CmcPlanUnauthorizeError extends CmcError {
}
exports.CmcPlanUnauthorizeError = CmcPlanUnauthorizeError;
/**
* Error thrown when the provided API key for CoinMarketCap's subscription plan requires activation.
* @see {@link https://pro.coinmarketcap.com/api/v1#section/Errors-and-Rate-Limits | CoinMarketCap Errors and Rate Limits}
* @extends {CmcError}
*/
class CmcDailyRateLimitError extends CmcError {
}
exports.CmcDailyRateLimitError = CmcDailyRateLimitError;
/**
* Error thrown when the provided API key for CoinMarketCap's subscription plan has reached the daily rate limit.
* @see {@link https://pro.coinmarketcap.com/api/v1#section/Errors-and-Rate-Limits | CoinMarketCap Errors and Rate Limits}
* @extends {CmcError}
*/
class CmcIpRateLimitError extends CmcError {
}
exports.CmcIpRateLimitError = CmcIpRateLimitError;
/**
* Error thrown when the provided API key for CoinMarketCap's subscription plan has reached the minute rate limit.
* @see {@link https://pro.coinmarketcap.com/api/v1#section/Errors-and-Rate-Limits | CoinMarketCap Errors and Rate Limits}
* @extends {CmcError}
*/
class CmcMinuteRateLimitError extends CmcError {
}
exports.CmcMinuteRateLimitError = CmcMinuteRateLimitError;
/**
* Error thrown when the provided API key for CoinMarketCap's subscription plan has reached the monthly rate limit.
* @see {@link https://pro.coinmarketcap.com/api/v1#section/Errors-and-Rate-Limits | CoinMarketCap Errors and Rate Limits}
* @extends {CmcError}
*/
class CmcMonthlyRateLimitError extends CmcError {
}
exports.CmcMonthlyRateLimitError = CmcMonthlyRateLimitError;
/**
* Error thrown when the provided API key for CoinMarketCap's subscription plan does not support the endpoint or general request errors.
* @see {@link https://pro.coinmarketcap.com/api/v1#section/Errors-and-Rate-Limits | CoinMarketCap Errors and Rate Limits}
* @extends {CmcError}
*/
class CmcRequestError extends CmcError {
}
exports.CmcRequestError = CmcRequestError;
//# sourceMappingURL=errors.js.map