Overview

The Hong Kong Observatory (HKO) is the official meteorological authority for Hong Kong, established in 1883. Its primary mission is to provide meteorological services, including weather forecasts, warnings of hazardous weather, and climate services, for the public and specific sectors such as aviation and marine transport. Beyond its core public services, the HKO offers a suite of Open Data APIs, enabling developers and technical buyers to programmatically access a comprehensive array of meteorological and geophysical information.

These APIs are designed for applications requiring localized, real-time weather data for Hong Kong and its adjacent waters. Data streams include current weather conditions such as temperature, humidity, rainfall, and wind speed from various automatic weather stations. Forecasts cover short-range, extended-range, and specialized marine forecasts. Crucially, the HKO APIs also provide access to warning signals for tropical cyclones, heavy rain, thunderstorms, and landslips, which are vital for public safety and operational planning within the region. Historical climate data, including monthly and annual summaries, is also available for research and long-term trend analysis.

The HKO's developer offerings are particularly valuable for use cases such as developing public information displays in smart city initiatives, integrating real-time weather into logistics and transportation management systems, enhancing agricultural planning, or creating educational tools. For instance, a smart building management system could use real-time temperature and humidity data to optimize HVAC operations, while a maritime application could consume typhoon warnings to plot safe routes. The HKO's commitment to open data aligns with broader governmental efforts to promote transparency and data-driven innovation, making its APIs a foundational resource for developers building solutions pertinent to Hong Kong's environment and infrastructure. The API documentation provides details on various data endpoints and formats, typically JSON or XML, facilitating integration into diverse programming environments.

Key features

  • Real-time Weather Observations: Access current temperature, humidity, rainfall, wind speed, and other parameters from a network of automatic weather stations across Hong Kong via the Current Weather Report API.
  • Weather Forecasts: Obtain short-range (9-day), extended-range, and specialized forecasts, including specific forecasts for local districts and marine areas.
  • Hazardous Weather Warnings: Receive immediate notifications for tropical cyclones, heavy rain, thunderstorms, landslips, and other significant weather events through dedicated warning signal APIs.
  • Climate Data: Programmatic access to historical meteorological data, including monthly and annual summaries of temperature, rainfall, and sunshine hours, suitable for climate research and analysis.
  • Seismological Monitoring: Data related to local and regional seismic activity, providing insights into earth tremors affecting Hong Kong.
  • UV Index and Radiation Monitoring: Information on ultraviolet radiation levels and other environmental monitoring data.
  • Data Formats: Data available primarily in JSON and XML formats, supporting integration with a wide range of programming languages and platforms.

Pricing

The Hong Kong Observatory operates as a public service, and access to its meteorological and geophysical data through the official APIs is provided free of charge. There are no subscription fees or usage-based costs associated with consuming the data from the HKO's Open Data APIs.

Service Tier Description Cost (as of 2026-05-28)
Public Data Access Access to all available meteorological, climate, and warning data via HKO Open APIs. Free

For detailed information on the specific data available and terms of use, refer to the Hong Kong Observatory Open Data API documentation.

Common integrations

The Hong Kong Observatory APIs can be integrated into various applications and systems. Common integration patterns include:

  • Web and Mobile Applications: Displaying real-time weather conditions, forecasts, and warnings directly within local news apps, travel planners, or public information dashboards.
  • Smart City Platforms: Incorporating environmental data for urban planning, traffic management, and public safety systems.
  • Logistics and Transportation Systems: Using weather forecasts and warnings to optimize delivery routes, manage shipping schedules, and enhance aviation safety.
  • Building Management Systems: Automating HVAC systems based on real-time temperature and humidity data to improve energy efficiency.
  • Agricultural and Fisheries Management: Utilizing climate data and forecasts for crop planning, irrigation scheduling, and marine operations.
  • Educational and Research Tools: Developing interactive visualizations or conducting climate studies using historical and real-time data.

Alternatives

While the Hong Kong Observatory provides authoritative data for its specific region, other global and regional weather API providers offer similar services for different geographic scopes or with varying feature sets:

  • OpenWeatherMap: Offers global weather data, forecasts, and historical data with various API plans.
  • AccuWeather API: Provides global weather forecasts, historical data, and specialized weather content for commercial use.
  • The Weather Company (IBM): Enterprise-grade weather data and analytics, including highly localized forecasts and severe weather alerts.
  • Google Maps Platform: Can include weather overlays as part of its mapping services, although not a primary weather data provider. For example, the Google Maps JavaScript API weather layer can display basic weather information.
  • National Weather Services (e.g., NOAA for US): Similar to HKO, national meteorological organizations often provide their own public APIs for their respective regions.

Getting started

To begin consuming data from the Hong Kong Observatory APIs, developers typically make HTTP GET requests to specific endpoints. Here's a Python example demonstrating how to retrieve the current weather report for Hong Kong in JSON format.

import requests
import json

def get_current_weather():
    url = "https://data.weather.gov.hk/weatherAPI/opendata/weather.php?dataType=rhrread&lang=en"
    try:
        response = requests.get(url)
        response.raise_for_status()  # Raise an HTTPError for bad responses (4xx or 5xx)
        weather_data = response.json()
        
        # Extracting key information
        temperature_data = weather_data.get('temperature', {}).get('data', [])
        humidity_data = weather_data.get('humidity', {}).get('data', [])
        rainfall_data = weather_data.get('rainfall', {}).get('data', [])

        print("--- Current Weather Report for Hong Kong ---")
        
        if temperature_data:
            # Assuming the first entry is the general reading or picking a specific station
            temp_value = temperature_data[0].get('value')
            temp_unit = temperature_data[0].get('unit')
            print(f"Temperature: {temp_value}°{temp_unit}")
        
        if humidity_data:
            humidity_value = humidity_data[0].get('value')
            humidity_unit = humidity_data[0].get('unit')
            print(f"Humidity: {humidity_value}{humidity_unit}")

        if rainfall_data:
            # Summing up recent rainfall for a general idea
            total_rainfall = sum(item.get('max', 0) for item in rainfall_data if item.get('unit') == 'mm')
            print(f"Recent Rainfall (past hour, max across stations): {total_rainfall} mm")

        # You can further parse other fields like icon, warning messages, etc.
        icon_code = weather_data.get('icon')
        if icon_code:
            print(f"Weather Icon Code: {icon_code} (Refer to HKO docs for meaning)")

        warning_messages = weather_data.get('warningMessage', "No active warnings.")
        print(f"Warnings: {warning_messages}")

    except requests.exceptions.RequestException as e:
        print(f"Error fetching weather data: {e}")
    except json.JSONDecodeError:
        print("Error decoding JSON response.")

if __name__ == "__main__":
    get_current_weather()

This Python script fetches the current weather report using the rhrread data type, which provides real-time observations. The requests library handles HTTP communication, and the json library is used to parse the response. The script then prints out key details such as temperature, humidity, rainfall, and any active warning messages. For a complete list of available data types and parameters, consult the Hong Kong Observatory Open Data API reference.