coinmarketcap-node
Advanced tools
Comparing version 0.0.4 to 0.0.5
#!/usr/bin/env node | ||
'use strict'; | ||
var __importDefault = | ||
(this && this.__importDefault) || | ||
function(mod) { | ||
return mod && mod.__esModule ? mod : { default: mod }; | ||
}; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
const assert_1 = require('assert'); | ||
const yargs_1 = __importDefault(require('yargs')); | ||
const index_1 = __importDefault(require('./index')); | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const assert_1 = require("assert"); | ||
const yargs_1 = __importDefault(require("yargs")); | ||
const index_1 = __importDefault(require("./index")); | ||
const { argv } = yargs_1.default.options({ | ||
apiKey: { type: 'string', demandOption: true }, | ||
api_key: { type: 'string', demandOption: true }, | ||
}); | ||
assert_1.strict.ok(argv.apiKey); | ||
assert_1.strict.ok(argv.api_key); | ||
(async () => { | ||
const coinmarketcap = new index_1.default(argv.apiKey); | ||
// console.info(await coinmarketcap.listingsLatest()); | ||
console.info( | ||
await coinmarketcap.quotesLatest({ | ||
symbol: ['BTC', 'DAI', 'EOS', 'ETH', 'PAX', 'TRX', 'USDC', 'USDT'], | ||
convert: 'USD', | ||
}), | ||
); | ||
const coinmarketcap = new index_1.default(argv.api_key); | ||
// console.info(await coinmarketcap.listingsLatest()); | ||
console.info(await coinmarketcap.fetchLatestGlobalMetrics({})); | ||
})(); |
import { Currency } from './pojo/currency'; | ||
import { Metrics } from './pojo/metrics'; | ||
export default class CoinMarketCap { | ||
private apiKey; | ||
constructor(apiKey: string); | ||
private get; | ||
listingsLatest(params?: { | ||
start: number; | ||
limit: number; | ||
volume_24h_min?: number; | ||
convert: string | Array<'USD' | 'USDT' | 'BTC' | 'ETH' | 'XRP' | 'BCH' | 'LTC'>; | ||
convert_id?: string | number[]; | ||
sort: | ||
| 'name' | ||
| 'symbol' | ||
| 'date_added' | ||
| 'market_cap' | ||
| 'market_cap_strict' | ||
| 'price' | ||
| 'circulating_supply' | ||
| 'total_supply' | ||
| 'max_supply' | ||
| 'num_market_pairs' | ||
| 'volume_24h' | ||
| 'percent_change_1h' | ||
| 'percent_change_24h' | ||
| 'percent_change_7d' | ||
| 'market_cap_by_total_supply_strict' | ||
| 'volume_7d' | ||
| 'volume_30d'; | ||
sort_dir: 'desc' | 'asc'; | ||
cryptocurrency_type: 'all' | 'coins' | 'tokens'; | ||
aux?: | ||
| string | ||
| Array< | ||
| 'num_market_pairs' | ||
| 'cmc_rank' | ||
| 'date_added' | ||
| 'tags' | ||
| 'platform' | ||
| 'max_supply' | ||
| 'circulating_supply' | ||
| 'total_supply' | ||
| 'market_cap_by_total_supply' | ||
| 'volume_24h_reported' | ||
| 'volume_7d' | ||
| 'volume_7d_reported' | ||
| 'volume_30d' | ||
| 'volume_30d_reported' | ||
>; | ||
}): Promise<Currency[]>; | ||
quotesLatest(params?: { | ||
id?: string | number[]; | ||
symbol?: string | string[]; | ||
convert: string | Array<'USD' | 'USDT' | 'BTC' | 'ETH' | 'XRP' | 'BCH' | 'LTC'>; | ||
convert_id?: string | number[]; | ||
aux?: | ||
| string | ||
| Array< | ||
| 'num_market_pairs' | ||
| 'cmc_rank' | ||
| 'date_added' | ||
| 'tags' | ||
| 'platform' | ||
| 'max_supply' | ||
| 'circulating_supply' | ||
| 'total_supply' | ||
| 'market_cap_by_total_supply' | ||
| 'volume_24h_reported' | ||
| 'volume_7d' | ||
| 'volume_7d_reported' | ||
| 'volume_30d' | ||
| 'volume_30d_reported' | ||
>; | ||
skip_invalid?: boolean; | ||
}): Promise<{ | ||
[key: string]: Currency; | ||
}>; | ||
private apiKey; | ||
constructor(apiKey: string); | ||
private get; | ||
listingsLatest(params?: { | ||
start: number; | ||
limit: number; | ||
volume_24h_min?: number; | ||
convert: string | Array<'USD' | 'USDT' | 'BTC' | 'ETH' | 'XRP' | 'BCH' | 'LTC'>; | ||
convert_id?: string | number[]; | ||
sort: 'name' | 'symbol' | 'date_added' | 'market_cap' | 'market_cap_strict' | 'price' | 'circulating_supply' | 'total_supply' | 'max_supply' | 'num_market_pairs' | 'volume_24h' | 'percent_change_1h' | 'percent_change_24h' | 'percent_change_7d' | 'market_cap_by_total_supply_strict' | 'volume_7d' | 'volume_30d'; | ||
sort_dir: 'desc' | 'asc'; | ||
cryptocurrency_type: 'all' | 'coins' | 'tokens'; | ||
aux?: string | Array<'num_market_pairs' | 'cmc_rank' | 'date_added' | 'tags' | 'platform' | 'max_supply' | 'circulating_supply' | 'total_supply' | 'market_cap_by_total_supply' | 'volume_24h_reported' | 'volume_7d' | 'volume_7d_reported' | 'volume_30d' | 'volume_30d_reported'>; | ||
}): Promise<Currency[]>; | ||
quotesLatest(params?: { | ||
id?: string | number[]; | ||
symbol?: string | string[]; | ||
convert: string | Array<'USD' | 'USDT' | 'BTC' | 'ETH' | 'XRP' | 'BCH' | 'LTC'>; | ||
convert_id?: string | number[]; | ||
aux?: string | Array<'num_market_pairs' | 'cmc_rank' | 'date_added' | 'tags' | 'platform' | 'max_supply' | 'circulating_supply' | 'total_supply' | 'market_cap_by_total_supply' | 'volume_24h_reported' | 'volume_7d' | 'volume_7d_reported' | 'volume_30d' | 'volume_30d_reported'>; | ||
skip_invalid?: boolean; | ||
}): Promise<{ | ||
[key: string]: Currency; | ||
}>; | ||
fetchLatestGlobalMetrics(params: { | ||
convert?: string | string[]; | ||
convert_id?: string | number[]; | ||
}): Promise<Metrics>; | ||
} |
@@ -1,94 +0,102 @@ | ||
'use strict'; | ||
var __importDefault = | ||
(this && this.__importDefault) || | ||
function(mod) { | ||
return mod && mod.__esModule ? mod : { default: mod }; | ||
}; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
const assert_1 = require('assert'); | ||
const axios_1 = __importDefault(require('axios')); | ||
const qs_1 = __importDefault(require('qs')); | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const assert_1 = require("assert"); | ||
const axios_1 = __importDefault(require("axios")); | ||
const qs_1 = __importDefault(require("qs")); | ||
const BASE_URL = 'https://pro-api.coinmarketcap.com/v1'; | ||
class CoinMarketCap { | ||
constructor(apiKey) { | ||
this.apiKey = apiKey; | ||
} | ||
async get(path, params) { | ||
const response = await axios_1.default.get(`${BASE_URL}${path}?${params}`, { | ||
headers: { | ||
'X-CMC_PRO_API_KEY': this.apiKey, | ||
Accept: 'application/json', | ||
'Accept-Charset': 'utf-8', | ||
'Accept-Encoding': 'deflate, gzip', | ||
}, | ||
}); | ||
assert_1.strict.equal(response.status, 200); | ||
assert_1.strict.equal(response.data.status.error_code, 0); | ||
return response.data.data; | ||
} | ||
async listingsLatest( | ||
params = { | ||
start: 1, | ||
limit: 100, | ||
convert: ['USD'], | ||
sort: 'market_cap', | ||
sort_dir: 'desc', | ||
cryptocurrency_type: 'all', | ||
}, | ||
) { | ||
const path = '/cryptocurrency/listings/latest'; | ||
if (Array.isArray(params.convert)) { | ||
params.convert = params.convert.join(','); // eslint-disable-line no-param-reassign | ||
constructor(apiKey) { | ||
this.apiKey = apiKey; | ||
} | ||
if (params.convert_id) { | ||
if (Array.isArray(params.convert_id)) { | ||
params.convert_id = params.convert_id.join(','); // eslint-disable-line no-param-reassign | ||
} | ||
async get(path, params) { | ||
const response = await axios_1.default.get(`${BASE_URL}${path}?${params}`, { | ||
headers: { | ||
'X-CMC_PRO_API_KEY': this.apiKey, | ||
Accept: 'application/json', | ||
'Accept-Charset': 'utf-8', | ||
'Accept-Encoding': 'deflate, gzip', | ||
}, | ||
}); | ||
assert_1.strict.equal(response.status, 200); | ||
assert_1.strict.equal(response.data.status.error_code, 0); | ||
return response.data.data; | ||
} | ||
if (params.aux) { | ||
if (Array.isArray(params.aux)) { | ||
params.aux = params.aux.join(','); // eslint-disable-line no-param-reassign | ||
} | ||
async listingsLatest(params = { | ||
start: 1, | ||
limit: 100, | ||
convert: ['USD'], | ||
sort: 'market_cap', | ||
sort_dir: 'desc', | ||
cryptocurrency_type: 'all', | ||
}) { | ||
const path = '/cryptocurrency/listings/latest'; | ||
if (Array.isArray(params.convert)) { | ||
params.convert = params.convert.join(','); // eslint-disable-line no-param-reassign | ||
} | ||
if (params.convert_id) { | ||
if (Array.isArray(params.convert_id)) { | ||
params.convert_id = params.convert_id.join(','); // eslint-disable-line no-param-reassign | ||
} | ||
} | ||
if (params.aux) { | ||
if (Array.isArray(params.aux)) { | ||
params.aux = params.aux.join(','); // eslint-disable-line no-param-reassign | ||
} | ||
} | ||
return this.get(path, qs_1.default.stringify(params)); | ||
} | ||
return this.get(path, qs_1.default.stringify(params)); | ||
} | ||
async quotesLatest( | ||
params = { | ||
symbol: ['BTC', 'ETH', 'USDT'], | ||
convert: ['USD'], | ||
}, | ||
) { | ||
if (!params.id && !params.symbol) { | ||
throw new Error('At least one "id" or "symbol" is required'); | ||
async quotesLatest(params = { | ||
symbol: ['BTC', 'ETH', 'USDT'], | ||
convert: ['USD'], | ||
}) { | ||
if (!params.id && !params.symbol) { | ||
throw new Error('At least one "id" or "symbol" is required'); | ||
} | ||
if (params.id && params.symbol) { | ||
throw new Error('ID and symbol cannot be passed in at the same time.'); | ||
} | ||
const path = '/cryptocurrency/quotes/latest'; | ||
if (params.id) { | ||
if (Array.isArray(params.id)) { | ||
params.id = params.id.join(','); // eslint-disable-line no-param-reassign | ||
} | ||
} | ||
if (params.symbol) { | ||
if (Array.isArray(params.symbol)) { | ||
params.symbol = params.symbol.join(','); // eslint-disable-line no-param-reassign | ||
} | ||
} | ||
if (Array.isArray(params.convert)) { | ||
params.convert = params.convert.join(','); // eslint-disable-line no-param-reassign | ||
} | ||
if (params.convert_id) { | ||
if (Array.isArray(params.convert_id)) { | ||
params.convert_id = params.convert_id.join(','); // eslint-disable-line no-param-reassign | ||
} | ||
} | ||
if (params.aux) { | ||
if (Array.isArray(params.aux)) { | ||
params.aux = params.aux.join(','); // eslint-disable-line no-param-reassign | ||
} | ||
} | ||
return this.get(path, qs_1.default.stringify(params)); | ||
} | ||
if (params.id && params.symbol) { | ||
throw new Error('ID and symbol cannot be passed in at the same time.'); | ||
async fetchLatestGlobalMetrics(params) { | ||
const path = '/global-metrics/quotes/latest'; | ||
if (params.convert) { | ||
if (Array.isArray(params.convert)) { | ||
params.convert = params.convert.join(','); // eslint-disable-line no-param-reassign | ||
} | ||
} | ||
if (params.convert_id) { | ||
if (Array.isArray(params.convert_id)) { | ||
params.convert_id = params.convert_id.join(','); // eslint-disable-line no-param-reassign | ||
} | ||
} | ||
return this.get(path, qs_1.default.stringify(params)); | ||
} | ||
const path = '/cryptocurrency/quotes/latest'; | ||
if (params.id) { | ||
if (Array.isArray(params.id)) { | ||
params.id = params.id.join(','); // eslint-disable-line no-param-reassign | ||
} | ||
} | ||
if (params.symbol) { | ||
if (Array.isArray(params.symbol)) { | ||
params.symbol = params.symbol.join(','); // eslint-disable-line no-param-reassign | ||
} | ||
} | ||
if (Array.isArray(params.convert)) { | ||
params.convert = params.convert.join(','); // eslint-disable-line no-param-reassign | ||
} | ||
if (params.convert_id) { | ||
if (Array.isArray(params.convert_id)) { | ||
params.convert_id = params.convert_id.join(','); // eslint-disable-line no-param-reassign | ||
} | ||
} | ||
if (params.aux) { | ||
if (Array.isArray(params.aux)) { | ||
params.aux = params.aux.join(','); // eslint-disable-line no-param-reassign | ||
} | ||
} | ||
return this.get(path, qs_1.default.stringify(params)); | ||
} | ||
} | ||
exports.default = CoinMarketCap; |
import { Quote } from './quote'; | ||
export interface Currency { | ||
id: number; | ||
name: string; | ||
symbol: string; | ||
slug: string; | ||
last_updated: string; | ||
quote: { | ||
[key: string]: Quote; | ||
}; | ||
[key: string]: any; | ||
id: number; | ||
name: string; | ||
symbol: string; | ||
slug: string; | ||
last_updated: string; | ||
quote: { | ||
[key: string]: Quote; | ||
}; | ||
[key: string]: unknown; | ||
} |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
export interface Quote { | ||
price: number; | ||
volume_24h: number; | ||
percent_change_1h: number; | ||
percent_change_24h: number; | ||
percent_change_7d: number; | ||
market_cap: number; | ||
last_updated: string; | ||
price: number; | ||
volume_24h: number; | ||
percent_change_1h: number; | ||
percent_change_24h: number; | ||
percent_change_7d: number; | ||
market_cap: number; | ||
last_updated: string; | ||
} |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
{ | ||
"name": "coinmarketcap-node", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "A complete Node.js library for CoinmarketCap.", | ||
@@ -36,25 +36,25 @@ "main": "dist/index.js", | ||
"devDependencies": { | ||
"@types/figlet": "^1.2.0", | ||
"@types/node": "^13.1.7", | ||
"@types/qs": "^6.9.0", | ||
"@types/yargs": "^15.0.0", | ||
"@typescript-eslint/eslint-plugin": "^2.16.0", | ||
"@typescript-eslint/parser": "^2.16.0", | ||
"eslint": "^6.8.0", | ||
"eslint-config-airbnb-base": "^14.0.0", | ||
"eslint-config-prettier": "^6.9.0", | ||
"eslint-plugin-import": "^2.20.0", | ||
"eslint-plugin-jest": "^23.6.0", | ||
"eslint-plugin-markdown": "^1.0.1", | ||
"eslint-plugin-prettier": "^3.1.2", | ||
"prettier": "^1.19.1", | ||
"typescript": "^3.7.5" | ||
"@types/figlet": "^1.2.1", | ||
"@types/node": "^14.14.35", | ||
"@types/qs": "^6.9.6", | ||
"@types/yargs": "^16.0.0", | ||
"@typescript-eslint/eslint-plugin": "^4.19.0", | ||
"@typescript-eslint/parser": "^4.19.0", | ||
"eslint": "^7.22.0", | ||
"eslint-config-airbnb": "^18.2.1", | ||
"eslint-config-prettier": "^8.1.0", | ||
"eslint-plugin-import": "^2.22.1", | ||
"eslint-plugin-jest": "^24.3.2", | ||
"eslint-plugin-markdown": "^2.0.0", | ||
"eslint-plugin-prettier": "^3.3.1", | ||
"prettier": "^2.2.1", | ||
"typescript": "^4.2.3" | ||
}, | ||
"dependencies": { | ||
"axios": "^0.19.2", | ||
"chalk": "^3.0.0", | ||
"figlet": "^1.2.4", | ||
"qs": "^6.9.1", | ||
"yargs": "^15.1.0" | ||
"axios": "^0.21.1", | ||
"chalk": "^4.1.0", | ||
"figlet": "^1.5.0", | ||
"qs": "^6.10.1", | ||
"yargs": "^16.2.0" | ||
} | ||
} |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
21738
13
214
1
+ Addedaxios@0.21.4(transitive)
+ Addedchalk@4.1.2(transitive)
+ Addedcliui@7.0.4(transitive)
+ Addedescalade@3.2.0(transitive)
+ Addedfollow-redirects@1.15.9(transitive)
+ Addedwrap-ansi@7.0.0(transitive)
+ Addedy18n@5.0.8(transitive)
+ Addedyargs@16.2.0(transitive)
+ Addedyargs-parser@20.2.9(transitive)
- Removedaxios@0.19.2(transitive)
- Removedcamelcase@5.3.1(transitive)
- Removedchalk@3.0.0(transitive)
- Removedcliui@6.0.0(transitive)
- Removeddecamelize@1.2.0(transitive)
- Removedfind-up@4.1.0(transitive)
- Removedfollow-redirects@1.5.10(transitive)
- Removedlocate-path@5.0.0(transitive)
- Removedp-limit@2.3.0(transitive)
- Removedp-locate@4.1.0(transitive)
- Removedp-try@2.2.0(transitive)
- Removedpath-exists@4.0.0(transitive)
- Removedrequire-main-filename@2.0.0(transitive)
- Removedset-blocking@2.0.0(transitive)
- Removedwhich-module@2.0.1(transitive)
- Removedwrap-ansi@6.2.0(transitive)
- Removedy18n@4.0.3(transitive)
- Removedyargs@15.4.1(transitive)
- Removedyargs-parser@18.1.3(transitive)
Updatedaxios@^0.21.1
Updatedchalk@^4.1.0
Updatedfiglet@^1.5.0
Updatedqs@^6.10.1
Updatedyargs@^16.2.0