Realtime APIs
Weather API

Weather API Endpoint

GET https://api.data.gov.my/weather/forecast
GET https://api.data.gov.my/weather/warning
GET https://api.data.gov.my/weather/warning/earthquake

Source of Weather Data

The Weather API offers real-time weather information, including a 7-day general forecast and live weather warnings. Additionally, earthquake warnings are provided in a separate endpoint due to their unique format. The data is provided by MET Malaysia (Malaysian Meteorological Department). For more comprehensive weather-related information and additional resources, you can visit MET Malaysia's Official Portal (opens in a new tab).

Note: Marine forecast data is currently unavailable.

Frequency of Data Update

  • The 7-day general forecast data is updated daily.
  • The warning data (including earthquake data) is updated when required.

Request Query & Response Format

To filter and request data, use the standard filtering operations in the Request Query. For information on how the API responds to your requests, refer to the Response Format section.

7-day General Forecast

GET https://api.data.gov.my/weather/forecast

Example Query

To fetch data from the Weather API, use the following curl command. Open your terminal and enter this command:

curl --location 'https://api.data.gov.my/weather/forecast?limit=3'

Querying Nested Fields

    {
        // double underscore is used
        "location": {
            "location_id": "Ds001", // location__location_id
            "location_name": "Langkawi" // location__location_name
        },
        "date": "1957-08-31",
        "morning_forecast": "Hujan di satu dua tempat",
        "afternoon_forecast": "Ribut petir di satu dua tempat",
        "night_forecast": "Tiada hujan",
        "summary_forecast": "Ribut petir di satu dua tempat",
        "summary_when": "Petang",
        "min_temp": 26,
        "max_temp": 32
    },

The response data is structured as above. You can access nested fields using a double underscore. For instance, to filter forecast data for Langkawi, you can use the query parameter ?contains=Langkawi@location__location_name.

Filtering by Location Category

GET https://api.data.gov.my/weather/forecast?contains=<prefix>@location__location_id

The location_id is in "AA000" format, where the aphabetical prefix represents the type of location. There are five possible types of locations:

  • St for State
  • Rc for Recreation Centre
  • Ds for District
  • Tn for Town
  • Dv for Division

To filter for forecast data for a specific location category, simply use the contains query parameter. For example, to retrieve State location forecast data only, use ?contains=St@location__location_id.

Understanding the Field Values

KeyTypeDescriptionExample Value
location_idstringUnique identifier for the location. See Filtering by location category for more details.
  • "St001" (State)
  • "Rc001" (Recreation Centre)
  • "Ds001" (District)
  • "Tn001" (Town)
  • "Dv001" (Division)
location_namestringName of the location."Langkawi"
datedateDate of the weather forecast."1957-08-31"
morning_forecaststringForecast for the morning period."Hujan di satu dua tempat"
afternoon_forecaststringForecast for the afternoon period."Ribut petir di satu dua tempat"
night_forecaststringForecast for the night period."Tiada hujan"
summary_forecaststringSummary of the day's forecast."Ribut petir di satu dua tempat"
summary_whenstringTiming of the summarized forecast."Petang"
min_tempintegerMinimum temperature for the day in Celsius.26
max_tempintegerMaximum temperature for the day in Celsius.32

Possible Values for *_forecast Fields

Possible values for morning_forecast, afternoon_forecast, night_forecast, and summary_forecast:

ValueDescription
BerjerebuHazy.
Tiada hujanNo rain.
HujanRain.
Hujan di beberapa tempatScattered rain.
Hujan di satu dua tempatIsolated Rain.
Hujan di satu dua tempat di kawasan pantaiIsolated rain over coastal areas.
Hujan di satu dua tempat di kawasan pedalamanIsolated rain over inland areas.
Ribut petirThunderstorms.
Ribut petir di beberapa tempatScattered thunderstorms.
Ribut petir di beberapa tempat di kawasan pedalamanScattered thunderstorms over inland areas.
Ribut petir di satu dua tempatIsolated thunderstorms.
Ribut petir di satu dua tempat di kawasan pantaiIsolated thunderstorms over coastal areas.
Ribut petir di satu dua tempat di kawasan pedalamanIsolated thunderstorms over inland areas.

Possible Values for summary_when Field

ValueDescription
PagiMorning.
MalamNight.
PetangAfternoon.
Pagi dan PetangMorning and Afternoon.
Pagi dan MalamMorning and Night.
Petang dan MalamAfternoon and Night.
Sepanjang HariThroughout the Day.

Note: Please be aware that the above field values are currently only available in Bahasa Melayu.

Warning Forecast

GET https://api.data.gov.my/weather/warning

Example Query

To fetch data from the Weather API, use the following curl command. Open your terminal and enter this command:

curl --location 'https://api.data.gov.my/weather/warning?limit=3'

Querying Nested Fields

    {
        // double underscore is used
        "warning_issue": {
            "issued": "1957-08-31T00:00:00", // warning_issue__issued
            "title_bm": "", // warning_issue__title_bm
            "title_en": "" // warning_issue__title_en
        },
        "valid_from": "1957-08-31T00:00:00",
        "valid_to": "2023-08-31T00:00:00",
        "heading_en": "",
        "text_en": "",
        "instruction_en": "",
        "heading_bm": "",
        "text_bm": "",
        "instruction_bm": ""
    },

The response data is structured as above. You can access nested fields using a double underscore. For instance, to filter for warnings issued from 1957-08-31 onwards, you can use the query parameter ?timestamp_start=1957-08-31 00:00:00@warning_issue__issued.

Understanding the Field Values

KeyTypeDescriptionExample Value
issueddatetimeDate and time when the warning was issued."1957-08-31T00:00:00"
title_bmstringTitle of the warning in Bahasa Melayu."Amaran Angin Kencang Kategori Pertama"
title_enstringTitle of the warning in English."First Category Warning on Strong Winds"
valid_fromdatetimeDate and time from which the warning is valid."2023-10-05T14:00:00"
valid_todatetimeDate and time until which the warning is valid."2023-10-07T00:00:00"
heading_enstringHeading of the warning in English."Strong Wind and Rough Seas (First Category)"
text_enstringDetailed warning text in English."Strong winds of 40-50 kmph with wave height up to 3.5m"
instruction_enstringInstructions related to the warning in English."Stay safe!"
heading_bmstringHeading of the warning in Bahasa Melayu."Amaran Angin Kencang (Kategori Pertama)"
text_bmstringDetailed warning text in Bahasa Melayu."Angin kencang 40-50 kmsj dengan ombak mencapai 3.5m"
instruction_bmstringInstructions related to the warning in Bahasa Melayu."Jaga diri!"

Earthquake Warning

GET https://api.data.gov.my/weather/warning/earthquake

Earthquake data is provided in a dedicated endpoint from weather/warning due to its unique format.

Example Query

To fetch data from the Weather API, use the following curl command. Open your terminal and enter this command:

curl --location 'https://api.data.gov.my/weather/warning/earthquake?limit=3'

Understanding the Field Values

KeyTypeDescriptionExample Value
utcdatetimedatetimeUTC date and time of the earthquake."2023-10-09T03:50:50"
localdatetimedatetimeLocal date and time (UTC+08:00) of the earthquake."2023-10-09T11:50:50"
latfloatLatitude of the earthquake.0.350031
lonfloatLongitude of the earthquake.122.238975
depthfloatDepth of the earthquake in kilometers.135.0
locationstringLocation description of the earthquake in Bahasa Melayu."Semenanjung Minahassa, Sulawesi"
location_originalstringLocation description of the earthquake in English."Minahassa Peninsula, Sulawesi"
n_distancemasstringDistance from Malaysia in English."613km SE Semporna, Sabah"
n_distancereststringDistance from other locations in English."97km W Gorontalo, Indonesia"
nbm_distancemasstringDistance from Malaysia in Bahasa Melayu."613km TG Semporna, Sabah"
nbm_distancereststringDistance from other locations in Bahasa Melayu."97km B Gorontalo, Indonesia"
magdefaultfloatDefault magnitude of the earthquake.5.5
magtypedefaultstringDefault magnitude type of the earthquake."mb"
statusstringStatus of the earthquake."NORMAL"
visiblebooleanVisibility status of the earthquake.true
lat_vectorstringLatitude vector representation in Bahasa Melayu."0.3500° U"
lon_vectorstringLongitude vector representation in Bahasa Melayu."122.2390° T"