
Security News
rv Is a New Rust-Powered Ruby Version Manager Inspired by Python's uv
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
@coingecko/cg-api-ts
Advanced tools
npm i --save @coingecko/cg-api-ts
yarn add @coingecko/cg-api-ts
Endpoint | Status | Testing | Function |
---|---|---|---|
/ping | [/] | [/] | getPing |
/simple/price | [/] | [/] | getSimplePrice |
/simple/supported_vs_currencies | [/] | [/] | getSimpleSupportedVsCurrencies |
/simple/token_price/{id} | [x] | [x] | |
/coins/list | [/] | [/] | getCoinsList |
/coins/markets | [x] | [x] | |
/coins/{id} | [/] | [x] | getCoinsId |
/coins/{id}/market_chart | [/] | [/] | getCoinsIdMarketChart |
/coins/{id}/status_updates | [/] | [/] | getCoinsIdStatusUpdates |
/status_updates | [/] | [/] | getStatusUpdates |
/global | [/] | [/] | getGlobal |
import { CoinGeckoAPI } from "@coingecko/cg-api-ts";
const cg = new CoinGeckoAPI(fetch);
// sometimes fetch is not bind properly need to use following:
// export const cg = new CoinGeckoAPI(window.fetch.bind(window));
cg.getPing()
.then(({ data, response, endpoint }) => {
console.log(data);
console.log(response);
console.log(endpoint);
})
// Error Handling
.catch(err => {
if (err.type === APIError.SERVER) {
// Resouces not found (Error 404)
console.error("API resources not found");
} else if (err.type === APIError.DOWN) {
// CoinGecko API Down (Error 500)
console.error("API Down");
} else if (err.type === APIError.TIMEOUT) {
// API Request timeout after 20s (default)
console.error("API Timeout");
console.error(err.message); // Request timeout after 20000ms
} else {
console.error(err.message);
}
});
CoinGeckoAPI class used fetch API, which requires browser support for Fetch API. Consider using Polyfill library
import { CoinGeckoAPI, APIError } from "@coingecko/cg-api-ts";
const cg = new CoinGeckoAPI(fetch);
cg.getPing().then(({ data, response }) => {
if (data) {
console.log("Server online");
} else {
console.error("Server not responding properly");
}
});
(async () => {
const cg = new CoinGeckoAPI(fetch);
const { data, response } = await cg.getPing();
if (data) {
console.log("Server online");
} else {
console.error("Server offline");
}
})();
const nodeFetch = require("node-fetch");
const cg = new CoinGeckoAPI(nodeFetch);
cg.getPing().then(({ data, response }) => {
if (data) {
console.log("Server online");
} else {
console.error("Server offline");
}
});
FAQs
JavaScript wrapper for coingecko.com/api
We found that @coingecko/cg-api-ts demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.
Security News
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.