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
| Parameter | Optional (default value) | Type | Description |
|---|---|---|---|
| session | no | ClientSession | see aiohttp |
hko.HKO.weather(dataType, lang)
Retrieve weather data from Weather Information API
Return: dictionary
| Parameter | Optional (default value) | Type | Description |
|---|---|---|---|
| dataType | no | string | type of data requested |
| lang | yes (en) | string | language used in response |
hko.HKO.earthquake(dataType, lang)
Retrieve weather data from Earthquake Information API
Return: dictionary
| Parameter | Optional (default value) | Type | Description |
|---|---|---|---|
| dataType | no | string | type of data requested |
| lang | yes (en) | string | language used in response |
hko.HKO.openData(dataType, lang)
Retrieve weather data from Earthquake Information API
Return: dictionary
| Parameter | Optional (default value) | Type | Description |
|---|---|---|---|
| dataType | no | string | type of data requested |
| lang | yes (en) | string | language used in response |
| station | - | string | refer to Official API Documentation |
| year | - | string | refer to Official API Documentation |
| month | - | string | refer to Official API Documentation |
| day | - | string | refer to Official API Documentation |
| hour | - | string | refer 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())
Metadata
Release files for hko 0.3.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| hko-0.3.2.tar.gz | 3.6 kB | Without provenance | Details for hko-0.3.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hko-0.3.2-py3-none-any.whl | Python 3 | none | any | Details for hko-0.3.2-py3-none-any.whl |
Total release size: 7.5 kB
Release files / hko-0.3.2.tar.gz
| Download URL | hko-0.3.2.tar.gz |
|---|---|
| Size | 3.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e85cdd6926b0eec5f9db033c1db1c51ad29d47624183707670c6673fb45f433b
|
|
BLAKE2b-256 checksum How to use checksums |
705a09d5b1b0c8817964064f50274611566b757a4ab03bffa8b91de8337d5886
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.1 CPython/3.9.13 Windows/10
|
Release files / hko-0.3.2-py3-none-any.whl
| Download URL | hko-0.3.2-py3-none-any.whl |
|---|---|
| Size | 3.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
86c97d13d7456cb6d54b2390bc659d0f7f9a912fd2f46ca59851f3a2d379b543
|
|
BLAKE2b-256 checksum How to use checksums |
5a8b435abcfa3888863951b614639aa96d883bb8d31c5ddda14a4c8bba4f5ac9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.1 CPython/3.9.13 Windows/10
|
Security for hko 0.3.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.