How to use OpenWeatherMap — a practical guide

If you're here, you probably want working code in five minutes. That's exactly what this guide does.

Five steps to get started

  1. 1
    Register at openweathermap.org and get a key by email.
  2. 2
    Wait ~10 minutes for activation.
  3. 3
    Call /data/2.5/weather with lat/lon or city name.
  4. 4
    Add units=metric for Celsius (default is Kelvin).

Shortest snippet that will actually run

curl "https://api.openweathermap.org/data/2.5/weather?q=Tel+Aviv&units=metric&lang=he&appid=YOUR_KEY"

Common mistakes (the honest list)

Use the One Call API (3.0) — current + hourly + daily in one call.
Cache for at least 10 minutes. Weather doesn't change every second.