Socket
Socket
Sign inDemoInstall

hko

Package Overview
Dependencies
1
Maintainers
1
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    hko

An unofficial Python wrapper for public API of Hong Kong Observatory


Maintainers
1

Readme

GitHub Release PyPI

python-hko

A python warpper for retrieving Hong Kong SAR local weather from Hong Kong Observatory Open Data API. Please refer to the Official Documentation for request parameters and response details. Official API Documentation

Reference

HKO Module

hko.HKO(session) Manage and perform requests Return: hko.HKO class

ParameterOptional (default value)TypeDescription
sessionnoClientSessionsee aiohttp

hko.HKO.weather(dataType, lang) Retrieve weather data from Weather Information API Return: dictionary

ParameterOptional (default value)TypeDescription
dataTypenostringtype of data requested
langyes (en)stringlanguage used in response

hko.HKO.earthquake(dataType, lang) Retrieve weather data from Earthquake Information API Return: dictionary

ParameterOptional (default value)TypeDescription
dataTypenostringtype of data requested
langyes (en)stringlanguage used in response

hko.HKO.openData(dataType, lang) Retrieve weather data from Earthquake Information API Return: dictionary

ParameterOptional (default value)TypeDescription
dataTypenostringtype of data requested
langyes (en)stringlanguage used in response
station-stringrefer to Official API Documentation
year-stringrefer to Official API Documentation
month-stringrefer to Official API Documentation
day-stringrefer to Official API Documentation
hour-stringrefer to Official API Documentation

Usage Example

Get and print local weather forcast general situation in English

from hko import HKO, HKOError
import asyncio
from aiohttp import ClientSession
from aiohttp import ClientConnectorError

async def main():
    async with ClientSession() as session:
        try:
            hko = HKO(session)
            fnd = await hko.weather(dataType="fnd")
            print(fnd["generalSituation"])
        except HKOError as error:
            print(error)

asyncio.run(main())

Keywords

FAQs


Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc