Why I Used wttr.in Instead of OpenWeatherMap for My Firefox Extension
Source: Dev.to
API Options Compared
| Service | Cost | API Key | Data Formats | Typical Use |
|---|---|---|---|---|
| OpenWeatherMap | Free tier: 1,000 calls/day | Required | JSON | General purpose |
| wttr.in | Free, no key | Not required | JSON, ASCII art, PNG | Terminal / curl usage |
| WeatherAPI.com | Free tier (different limits) | Required | JSON | Similar to OWM |
| Open-Meteo | Completely free, no key | Not required | JSON | Forecasts by coordinates |
| National Weather Service (US only) | Free, no key | Not required | JSON | US only |
Friction Difference
OpenWeatherMap requires users to:
- Create an account
- Generate an API key
- Paste the key into the extension settings
- Wait for the key to become active (can take hours)
wttr.in only needs the city name. Removing these steps dramatically improves install‑to‑active‑user conversion.
Code Examples
wttr.in request (JavaScript)
// wttr.in request
const url = `https://wttr.in/${encodeURIComponent(city)}?format=j1`;
OpenWeatherMap request (JavaScript)
// OpenWeatherMap request
const url = `https://api.openweathermap.org/data/2.5/forecast?q=${encodeURIComponent(city)}&appid=${userApiKey}&units=metric`;
Simpler code means fewer bugs.
Sample Response from wttr.in
{
"current_condition": [
{
"temp_C": "18",
"weatherDesc": [{ "value": "Partly cloudy" }],
"humidity": "65",
"windspeedKmph": "20"
}
],
"weather": [
{
"date": "2024-01-15",
"hourly": [{ "tempC": "15", "...": "..." }],
"maxtempC": "22",
"mintempC": "12"
}
]
}
One request provides current conditions plus a 3‑day forecast.
Reliability Considerations
- Single developer project – could go down or impose rate limits without SLA.
- Rate limiting – per‑IP limits may block high‑traffic scenarios (e.g., corporate NAT).
- Data sources – wttr.in aggregates from multiple providers; quality varies by region.
- No paid tier – you cannot increase limits or obtain guarantees.
When to Choose Each Service
| Situation | Recommended API |
|---|---|
| Need commercial reliability guarantees | OpenWeatherMap (or another paid service) |
| Need weather for coordinates or remote areas | Open-Meteo |
| Require hourly precision and technical users are okay with API keys | OpenWeatherMap / WeatherAPI.com |
| Want zero‑friction setup for consumer‑facing tools | wttr.in |
| Side project or personal tool, non‑critical display | wttr.in |
Aggressive Caching with wttr.in
Because wttr.in has no paid tier, I implemented client‑side caching to reduce request frequency:
const CACHE_DURATION = 30 * 60 * 1000; // 30 minutes
async function fetchWeather(city) {
const cacheKey = `weather_${city}`;
const cached = await browser.storage.local.get(cacheKey);
if (cached[cacheKey]) {
const { data, timestamp } = cached[cacheKey];
if (Date.now() - timestamp < CACHE_DURATION) {
return data; // Return cached data
}
}
// Fetch fresh data
const resp = await fetch(`https://wttr.in/${encodeURIComponent(city)}?format=j1`);
const data = await resp.json();
// Cache it
await browser.storage.local.set({
[cacheKey]: { data, timestamp: Date.now() }
});
return data;
}
This limits API calls to once per 30 minutes per user, rather than on every new tab.
Conclusion
The Weather & Clock Dashboard currently uses wttr.in and works well for its target audience. If reliability becomes an issue at scale, I plan to add OpenWeatherMap as a fallback or primary option.
Install the extension on Firefox – source code is available on GitHub.