# Mediastack API 104 usage limit reached

## TL;DR
Mediastack error 104 means the monthly request allocation for the plan is spent. This is the plan meter, not a malfunction. The fix is usage discipline for the rest of the cycle: cache aggressively, stop polling, and queue non-urgent queries for the reset. If the briefing needs this volume every month, upgrade the plan; the free allocation is small by design.

## The error
```text
{"error": {"code": 104, "type": "usage_limit_reached", "info": "Your monthly API request volume has been reached."}}
```

## When this helps
- Mediastack returns error 104
- a news pipeline exhausts the monthly allocation
- budgeting news API usage per cycle
- deciding whether to upgrade a Mediastack plan

## When it doesn't
- the error is 101; that is the API key
- the reset is tomorrow; waiting beats re-architecting
- you need the volume permanently; upgrade instead of rationing

## Works with
Mediastack API v1 as of 2026. Plan allocations are provider-side.

## Steps
### 1. Confirm the 104 and check the reset date
```bash
K="access_key"
curl -s "http://api.mediastack.com/v1/news?${K}=${MEDIASTACK_KEY}&languages=en" -o ms.json -w "HTTP %{http_code}\n"
python3 -c "import json; print(json.load(open("ms.json")).get("error"))"
```
Expected: The 104 error body. The plan dashboard shows the monthly reset date; note it.

### 2. Stop all polling until the reset
```python
import json
state = {"mediastack": "paused_until_reset", "reason": "104 usage limit"}
open("api_state.json", "w").write(json.dumps(state, indent=2))
print("mediastack polling paused; further calls waste nothing but also achieve nothing")
```
Expected: A paused state file. Calls against a spent allocation return 104 forever; stop making them.

### 3. Serve the rest of the cycle from cache and fallbacks
```python
import json
routing = {"primary": "cached mediastack results", "fallback": "other news api"}
open("news_routing.json", "w").write(json.dumps(routing, indent=2))
print("cache plus fallback covers the cycle")
```
Expected: Updated routing. Cached articles plus a fallback news API keep briefings running.

### 4. Size the next cycle's usage or upgrade
```python
import json
plan = {"monthly_cap": 500, "per_briefing": 10, "briefings_per_month": 30}
open("mediastack_budget.json", "w").write(json.dumps(plan, indent=2))
print("300 calls per month budgeted inside a 500 cap; upgrade if briefings need more")
```
Expected: A budget file. Explicit math shows whether the plan fits or an upgrade is due.

## Other ways people phrase this
### mediastack 104 usage limit
Monthly allocation spent. Pause, serve from cache, budget the next cycle.

### mediastack monthly request limit reached
The free allocation is small. Production use needs a paid plan.

### mediastack api request volume exceeded
Ration the remainder of the cycle; upgrade for sustained volume.

## Why it happens
Mediastack meters requests per month per plan, and the free allocation is small. Error 104 is the meter saying the allocation is spent. Further calls cannot succeed until the reset or an upgrade; the only useful work is budgeting and fallbacks.

## Edge cases
- The 104 body includes the reset info on some plans; parse it for the exact date.
- Historical queries cost the same as live ones; budget them too.
- Multiple keys to dodge the cap violates the terms.
- Track usage per data source so one hungry pipeline does not starve the others.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_tN4V5kjL8l466tmbNS8NNg
