Skip to content

Commit b54ba87

Browse files
committed
Allow overwriting FiatApi's Coingecko API URL
1 parent 1f23f16 commit b54ba87

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/fiat-api/FiatApi.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ const CPL_API_BRIDGED_FIAT_CURRENCIES: Array<CplApiBridgedFiatCurrency> = Object
262262
!FIAT_API_HISTORY_SUPPORTED_BRIDGED_FIAT_CURRENCIES.includes(currency as any)
263263
));
264264

265-
const API_URL = 'https://api.coingecko.com/api/v3';
265+
let API_URL = 'https://api.coingecko.com/api/v3';
266266
const COINGECKO_COIN_IDS = {
267267
[FiatApiSupportedCryptoCurrency.NIM]: 'nimiq-2',
268268
[FiatApiSupportedCryptoCurrency.BTC]: 'bitcoin',
@@ -274,6 +274,13 @@ const ONE_MINUTE = 60 * 1000;
274274
const ONE_HOUR = 60 * ONE_MINUTE;
275275
const ONE_DAY = 24 * ONE_HOUR;
276276

277+
/**
278+
* @param url The URL to the Coingecko v3 API. Defaults to https://api.coingecko.com/api/v3.
279+
*/
280+
export function setCoingeckoApiUrl(url: string) {
281+
API_URL = url;
282+
}
283+
277284
type VsCurrency = FiatApiSupportedFiatCurrency | FiatApiBridgedFiatCurrency | FiatApiSupportedCryptoCurrency;
278285
export async function getExchangeRates<C extends FiatApiSupportedCryptoCurrency, V extends VsCurrency>(
279286
cryptoCurrencies: C[],

0 commit comments

Comments
 (0)