UNPKG

pharos-agent-kit

Version:
20 lines 841 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getTopGainers = getTopGainers; async function getTopGainers(agent, duration = "24h", topCoins = "all") { try { if (!agent.config?.COINGECKO_PRO_API_KEY) { throw new Error("No CoinGecko Pro API key provided"); } const url = `https://pro-api.coingecko.com/api/v3/coins/top_gainers_losers?vs_currency=usd&duration=${duration}&top_coins=${topCoins}&x_cg_pro_api_key=${agent.config?.COINGECKO_PRO_API_KEY}`; const res = await fetch(url); const data = await res.json(); return data; } catch (e) { throw new Error( // @ts-expect-error - error is an object `Error fetching top gainers from CoinGecko: ${e.message}`); } } //# sourceMappingURL=get_top_gainers.js.map