Weather All docs

Weather API Reference

3 routes. Base URL https://api.apifor.dev, authenticated with x-api-key. Failed calls are not charged. Overview, limits and sources are on the Weather forecast API page.

GET/v1/weather1 credit

Forecast for a place. Indonesia: 3-day BMKG forecast in 3-hour steps by region code or point. Anywhere else: MET Norway forecast for a lat/lng point (hourly, then 6-hourly, about 9 days). Malaysia: country=MY with location or location_id for the 7-day MET Malaysia daily forecast. BMKG issues forecasts twice a day; each location's copy is refreshed from BMKG once it is 6 hours old, and meta.freshness says when. 1 credit.

ParameterInTypeRules
regionquerystringVillage (10 digits), district (6) or regency (4) code, dots optional, e.g. 34.02.16.2003 (Indonesia only)
latquerynumber-90 to 90 · Latitude, use with lng. Any point on earth (MET Norway outside Indonesia)
lngquerynumber-180 to 180 · Longitude, use with lat
countryquerystringISO 3166-1 alpha-2 · ISO 3166-1 alpha-2 code, optional. ID forces BMKG; MY enables location/location_id
locationquerystringmax 100 chars · country=MY: MET Malaysia forecast location (partial name). country=SG: data.gov.sg 2-hour forecast area (e.g. Bedok, Changi).
location_idquerystringMalaysia only (country=MY): MET Malaysia location id, e.g. Ds001
GET/v1/weather
curl 'https://api.apifor.dev/v1/weather' \
  -H 'x-api-key: YOUR_API_KEY'
Example response · 200
{
  "success": true,
  "data": {
    "location": {
      "country": "ID",
      "region_code": "34.02.16.2003",
      "province": "Daerah Istimewa Yogyakarta",
      "regency": "Bantul",
      "district": "Kasihan",
      "village": "Tamantirto",
      "lat": -7.8210832262,
      "lng": 110.3255892396,
      "timezone_offset": "+0700",
      "distance_km": 1.1
    },
    "issued_at": "2026-11-30T12:00:00Z",
    "fetched_at": "2026-11-30T13:02:11.512Z",
    "stale": false,
    "source": "BMKG",
    "forecasts": [
      {
        "time": "2026-11-30T13:00:00Z",
        "local_time": "2026-11-30 20:00:00",
        "condition": "Mostly Cloudy",
        "condition_local": "Berawan",
        "condition_code": "3",
        "temperature_c": 25,
        "humidity_percent": 96,
        "cloud_cover_percent": 98,
        "precipitation_mm": 0.1,
        "wind_speed_kmh": 1.2,
        "wind_from": "NW",
        "wind_to": "SE",
        "wind_degrees": 357,
        "visibility_m": null,
        "visibility_text": null
      },
      {
        "time": "2026-11-30T16:00:00Z",
        "local_time": "2026-11-30 23:00:00",
        "condition": "Mostly Cloudy",
        "condition_local": "Berawan",
        "condition_code": "3",
        "temperature_c": 25,
        "humidity_percent": 96,
        "cloud_cover_percent": 98,
        "precipitation_mm": 0,
        "wind_speed_kmh": 2.3,
        "wind_from": "W",
        "wind_to": "E",
        "wind_degrees": 310,
        "visibility_m": null,
        "visibility_text": null
      }
    ]
  },
  "meta": {
    "attribution": {
      "source": "BMKG (Badan Meteorologi, Klimatologi, dan Geofisika)",
      "licence": "BMKG open data, attribution required",
      "license": "BMKG open data, attribution required",
      "license_url": "https://data.bmkg.go.id",
      "source_url": "https://data.bmkg.go.id",
      "attribution_page": "https://apifor.dev/sources",
      "notice": "Source: BMKG (Badan Meteorologi, Klimatologi, dan Geofisika). Show BMKG as the data source wherever you display this data. Fields normali..."
    },
    "freshness": {
      "mode": "cached",
      "source": "BMKG",
      "source_published_at": "2026-11-30T12:00:00Z",
      "fetched_at": "2026-11-30T13:02:11.512Z",
      "refresh_interval_minutes": 360,
      "max_lag_minutes": 360
    }
  }
}
  • 200Forecast for the matched location. distance_km appears when you searched by point.
  • 400Invalid parameters
  • 404No location matched, including a region code that is not in the administrative regions list
  • 502Upstream unavailable or timed out (8 s) and nothing cached. No credits are used
  • 503Live lookup budget used up for this minute and nothing cached. Retry after 60 s. No credits are used
GET/v1/weather/locations1 credit

Search villages, districts and regencies by name to get a region code. 1 credit.

ParameterInTypeRules
qquerystringmax 100 chars · Place name, 2 to 100 characters
countryquerystringISO 3166-1 alpha-2 · ISO 3166-1 alpha-2 code. Covered today: ID
pagequeryinteger1 to 100 · default 1 · Page number
limitqueryinteger1 to 100 · default 20 · Rows per page
GET/v1/weather/locations
curl 'https://api.apifor.dev/v1/weather/locations' \
  -H 'x-api-key: YOUR_API_KEY'
Example response · 200
{
  "success": true,
  "data": [
    {
      "country": "ID",
      "region_code": "34.02.16.2003",
      "village": "Tamantirto",
      "district": "Kasihan",
      "regency": "Kabupaten Bantul",
      "province": "Daerah Istimewa Yogyakarta"
    }
  ],
  "meta": {
    "total": 1,
    "page": 1,
    "per_page": 20,
    "total_pages": 1,
    "attribution": {
      "source": "https://github.com/open-admin-data/indonesia-administrative-divisions",
      "licence": "CC BY 4.0",
      "license": "CC BY 4.0",
      "license_url": "https://creativecommons.org/licenses/by/4.0/",
      "source_url": "https://github.com/open-admin-data/indonesia-administrative-divisions",
      "attribution_page": "https://apifor.dev/sources",
      "notice": "Source: https://github.com/open-admin-data/indonesia-administrative-divisions. Licensed under CC BY 4.0. Fields normalized by APIFor."
    }
  }
}
  • 200Matching places
  • 400Invalid parameters
GET/v1/weather/coverageFree

Countries this service covers, with sources, licences, row counts and country-only fields. Free (0 credits), still needs an API key. Price note: Free.

GET/v1/weather/coverage
curl 'https://api.apifor.dev/v1/weather/coverage' \
  -H 'x-api-key: YOUR_API_KEY'
Example response · 200
{
  "success": true,
  "data": {
    "service": "weather",
    "global": true,
    "country_param": "optional",
    "param_name": "country",
    "countries": [
      {
        "country": "ID",
        "market": null,
        "subdivision_levels": [
          "province",
          "regency"
        ],
        "rows": null,
        "updated_at": null,
        "sources": [
          {
            "name": "BMKG",
            "url": "https://data.bmkg.go.id",
            "licence": "BMKG open data, attribution required",
            "attribution": "Source: BMKG (Badan Meteorologi, Klimatologi, dan Geofisika)"
          },
          {
            "name": "open-admin-data administrative divisions",
            "url": "https://github.com/open-admin-data/indonesia-administrative-divisions",
            "licence": "CC BY 4.0",
            "attribution": null
          }
        ],
        "local_fields": [],
        "notes": "3-day BMKG forecasts in 3-hour steps by region code or point. BMKG issues forecasts twice a day; each location is refreshed from BMKG onc..."
      },
      {
        "country": "MY",
        "market": null,
        "subdivision_levels": [],
        "rows": null,
        "updated_at": null,
        "sources": [
          {
            "name": "MET Malaysia via data.gov.my",
            "url": "https://developer.data.gov.my/realtime-api/weather",
            "licence": "CC BY 4.0",
            "attribution": "Source: MET Malaysia via data.gov.my"
          },
          {
            "name": "MET Norway Locationforecast 2.0",
            "url": "https://api.met.no/weatherapi/locationforecast/2.0/",
            "licence": "CC BY 4.0 / NLOD 2.0",
            "attribution": "Data from MET Norway (The Norwegian Meteorological Institute)"
          }
        ],
        "local_fields": [
          "local.met_location_id",
          "local.other_matches"
        ],
        "notes": "country=MY with location (name) or location_id (Ds001): 7-day daily MET Malaysia forecast, Malay text with English rendering. lat/lng: ho..."
      }
    ]
  }
}
  • 200Coverage

Error handling · Rate limits · Prices