Skip to content

Latest commit

History

27 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

GitHub ReleasePyPI

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

fromhkoimportHKO, HKOErrorimportasynciofromaiohttpimportClientSessionfromaiohttpimportClientConnectorErrorasyncdefmain():
asyncwithClientSession() assession:
try:
hko=HKO(session)
fnd=awaithko.weather(dataType="fnd")
print(fnd["generalSituation"])
exceptHKOErroraserror:
print(error)
asyncio.run(main())

About

No description, website, or topics provided.

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages