Hong Kong Obervatory API

Beginner's Pick Weather / No Auth Required Beginner HTTPS
Free to Use
84 A
Measured Score 0 50 100 Speed 21/30 Consistency 20/20 Security 20/20 Browser access 15/15 Transparency 8/15 TESTED 2026-08-10

Overview

The Hong Kong Observatory Open Data API provides free access to weather observations, forecasts, earthquake reports, and climate data for Hong Kong and the surrounding region. No authentication is required — you can call it directly from any application without signing up. It is a great no-cost option for learning API integration while building weather apps for the Hong Kong area.

Beginner Tip

No API key is needed — just call the endpoint URLs directly. Use the dataType query parameter to select the data product you want, such as rhrread for hourly readings or fnd for a 9-day forecast.

Measurement Record

What actually happened when we called this API from our own infrastructure. Every value below was recorded by the request, not copied from the provider's documentation.

Request
GET https://data.weather.gov.hk/weatherAPI/opendata/weather.php?dataType=rhrread&lang=en
Result
HTTP 200 · application/json · 3,052 bytes · compressed
Response time
96 ms (median of 3) · fastest 95 ms
Transport
TLSv1.3 · TLS_AES_256_GCM_SHA384 · certificate issued by Hongkong Post
Browser CORS
Allowed — Access-Control-Allow-Origin: *
Served by
HKO
Recorded
2026-08-10

Fields Returned

Top-level fields present in the response we captured, with the type and value we actually received.

Field Type Value received
rainfall object {3 fields}
icon array [1 item]
iconUpdateTime string (date) 2026-08-10T21:40:00+08:00
uvindex string
updateTime string (date) 2026-08-11T03:02:00+08:00
temperature object {2 fields}
warningMessage array [1 item]
mintempFrom00To09 string
rainfallFrom00To12 string
rainfallLastMonth string
rainfallJanuaryToLastMonth string
tcmessage string
humidity object {2 fields}

Captured Response

Captured from a real request to https://data.weather.gov.hk/weatherAPI/opendata/weather.php?dataType=rhrread&lang=en on 2026-08-10. Long arrays and nested objects are truncated to keep the shape readable.

JSON Response · Captured
{
  "rainfall": {
    "data": [
      {
        "…": "(4 more fields)"
      }
    ],
    "startTime": "2026-08-11T01:45:00+08:00",
    "endTime": "2026-08-11T02:45:00+08:00"
  },
  "icon": [
    77
  ],
  "iconUpdateTime": "2026-08-10T21:40:00+08:00",
  "uvindex": "",
  "updateTime": "2026-08-11T03:02:00+08:00",
  "temperature": {
    "data": [
      {
        "…": "(3 more fields)"
      }
    ],
    "recordTime": "2026-08-11T03:00:00+08:00"
  },
  "warningMessage": [
    "The Very Hot Weather Warning is now in force. Prolonged heat alert! Please drink sufficient water. If feeling unwell, take rest or seek help immediately. If …"
  ],
  "mintempFrom00To09": "",
  "rainfallFrom00To12": "",
  "rainfallLastMonth": "",
  "rainfallJanuaryToLastMonth": "",
  "tcmessage": "",
  "humidity": {
    "recordTime": "2026-08-11T03:00:00+08:00",
    "data": [
      {
        "…": "(3 more fields)"
      }
    ]
  }
}

Field Reference

updateTime ISO 8601 timestamp of when this data was last updated by HKO.
warningMessage List of active weather warning messages issued by the Observatory.

Implementation Example

Calls a real endpoint of this API. Replace any placeholder credentials with your own key.

Request
const url = "https://www.hko.gov.hk/en/abouthko/";
const response = await fetch(url);
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
const data = await response.json();
console.log(data);

What Can You Build?

Note: These code examples are AI-generated and unverified. Always refer to the official API documentation for accurate usage.

How This API Fails

We deliberately sent this API a broken request and recorded exactly what came back on 2026-08-10. Knowing the shape of an error before you hit it makes error handling much easier to write.

HTTP 404 Requesting a path that does not exist text/html

Returned an HTML error page rather than JSON — worth knowing if your client assumes every response can be parsed as JSON.

Common Errors & Troubleshooting

Generated guidance based on this API's documentation, not observed by us. Treat it as a starting point and check against the provider's own error reference.

Empty or unexpected JSON response An unsupported dataType value was used.
Check the HKO documentation for the exact dataType string (e.g., rhrread, fnd, warnsum) and ensure spelling is correct.
CORS error in browser The browser blocks cross-origin requests to the HKO API.
Proxy the request through a backend or use a server-side language; only enable CORS overrides locally for testing.
Stale data / unexpected timestamps The API updates on its own schedule (hourly or sub-hourly depending on dataType).
Cache the response and refresh on a schedule aligned with the API update frequency rather than polling continuously.

Measured Score Breakdown

Live HTTP request to the API endpoint

Speed 21/30
Consistency 20/20
Security 20/20
Browser access 15/15
Transparency 8/15
Endpoint Response Time 96ms

Fully tested on Aug 10, 2026

Technical Specifications

Auth No Auth
HTTPS REQUIRED
CORS UNKNOWN
Category Weather
Difficulty Beginner
Endpoint last called: 2026-08-10

Related Tags

Similar APIs

View All →