Data Observatory: add optional coingecko API key

This commit is contained in:
Mark Sinclair
2026-02-20 14:55:41 +00:00
parent 8bd6a1006b
commit 6131082cee
3 changed files with 12 additions and 3 deletions
Generated
+1 -1
View File
@@ -6209,7 +6209,7 @@ dependencies = [
[[package]]
name = "nym-data-observatory"
version = "1.0.3"
version = "1.0.4"
dependencies = [
"anyhow",
"async-trait",
+1 -1
View File
@@ -3,7 +3,7 @@
[package]
name = "nym-data-observatory"
version = "1.0.3"
version = "1.0.4"
authors.workspace = true
repository.workspace = true
homepage.workspace = true
+10 -1
View File
@@ -3,6 +3,7 @@ use crate::db::{
queries::price::insert_nym_prices,
};
use core::str;
use std::env;
use tokio::time::Duration;
use crate::db::DbPool;
@@ -29,7 +30,15 @@ impl PriceScraper {
async fn get_coingecko_prices(&self) -> anyhow::Result<CoingeckoPriceResponse> {
tracing::info!("💰 Fetching CoinGecko prices from {COINGECKO_API_URL}");
let response = reqwest::get(COINGECKO_API_URL).await?;
let mut url = COINGECKO_API_URL.to_string();
let coin_gecko_api_key = env::var("COINGECKO_API_KEY").ok();
if let Some(api_key) = coin_gecko_api_key {
url = format!("{url}&x_cg_demo_api_key={api_key}")
}
let response = reqwest::get(url).await?;
if !response.status().is_success() {
tracing::error!(