Based on Copilot comparison there are not much difference in between https://www.weatherapi.com/docs/ and https://openweathermap.org/api/one-call-3 for my project.
openweathermap.org
- has SDK, what is big advantage, but i don’t want to use it, to showcase my skills of working with API
- To get current weather we need provide longitude and latitude of location
- To get this data for city, they provide their own Geocoding API
- Has api for human readable (parsed by AI) response: https://openweathermap.org/api/one-call-3#weather_overview
weatherapi.com ✅
- supports query location by
- city: string
- how much inaccurate request can it handle? Ex: “Berln”, “munCHEN”, etc
- zip code: number
- has Forecast API exactly what we need
Access token, security
- Both libs requires access tokens for requests, we cannot completely “hide” it from client code, since we aren’t using backend and don’t have authorization. Best we can do is to attach accessToken to bundle during build process. See: https://vite.dev/guide/env-and-mode. At least it gives us easy way to rotate them on demand and it won’t be stored in public repo
- Maybe we could limit “trusted domains” in weather API dashboard, to narrow possible usage of our access token
Alternatives:
- Proxy through
- self hosten backend
- cloud lambdas