From 1f0b831835be37bd08f98198be5fbc1744de9784 Mon Sep 17 00:00:00 2001 From: Sirius DevOps Date: Mon, 24 Aug 2026 21:32:55 -0400 Subject: [PATCH] fires: append FIRMS day-range param; API 400s without it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit FIRMS area-CSV requires an explicit [1..5] day range — requests without it return 'Invalid day range. Expects [1..5].' as a 400. New FIRMS_DAYS env (default 1). --- app/config.py | 3 +++ app/fire_sources.py | 12 +++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/config.py b/app/config.py index d349010..bb1e689 100644 --- a/app/config.py +++ b/app/config.py @@ -54,5 +54,8 @@ FIRMS_DATASET = os.getenv("FIRMS_DATASET", "VIIRS_SNPP_NRT") FIRMS_BBOX = os.getenv("FIRMS_BBOX", "-180,-60,180,75") # Poll cadence in seconds. FIRMS NRT updates every ~5-10 min; 900 = 15 min. FIRMS_INTERVAL = int(os.getenv("FIRMS_INTERVAL", "900")) +# Day range for the area-CSV request. FIRMS accepts [1..5] days of NRT +# detections; the API 400s when this parameter is omitted. +FIRMS_DAYS = int(os.getenv("FIRMS_DAYS", "1")) # Outbound HTTP timeout for the FIRMS CSV download. FIRMS_TIMEOUT = float(os.getenv("FIRMS_TIMEOUT", "60")) diff --git a/app/fire_sources.py b/app/fire_sources.py index 920c045..0da0593 100644 --- a/app/fire_sources.py +++ b/app/fire_sources.py @@ -31,7 +31,13 @@ from datetime import datetime, timezone import httpx import nats -from config import FIRMS_DATASET, FIRMS_BBOX, FIRMS_TIMEOUT, NATS_URL +from config import ( + FIRMS_BBOX, + FIRMS_DATASET, + FIRMS_DAYS, + FIRMS_TIMEOUT, + NATS_URL, +) from keystore import get_api_key logger = logging.getLogger("osint.firms") @@ -39,7 +45,7 @@ logger = logging.getLogger("osint.firms") # ── FIRMS API ───────────────────────────────────────────────────────────── FIRMS_AREA_CSV = ( - "https://firms.modaps.eosdis.nasa.gov/api/area/csv/{key}/{dataset}/{bbox}" + "https://firms.modaps.eosdis.nasa.gov/api/area/csv/{key}/{dataset}/{bbox}/{days}" ) # The canonical VIIRS CSV header FIRMS returns. Used to (a) locate the real @@ -175,7 +181,7 @@ async def ingest_fires(bbox: str | None = None) -> int: area = bbox or FIRMS_BBOX url = FIRMS_AREA_CSV.format( - key=map_key, dataset=FIRMS_DATASET, bbox=area + key=map_key, dataset=FIRMS_DATASET, bbox=area, days=FIRMS_DAYS ) async with httpx.AsyncClient(timeout=FIRMS_TIMEOUT) as client: