Skip to main content

An unofficial Python wrapper for public API of Hong Kong Observatory

Project description

GitHub Release PyPI

python-hko

A python warpper for getting 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(websession) Manage and perform requests Return: hko.HKO class

Parameter Optional Type Description
websession no ClientSession see aiphttp

hko.HKO.weather(type, lang="en") Retrieve weather data from Weather Information API Return: dictionary

Parameter Optional Type Description Accepted values
dataType no string type of data requested see Official API Documentation
lang yes string language used in response see Official API Documentation

Usage Example

Get and print local weather forcast general situation in English

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

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

loop = asyncio.get_event_loop()
loop.run_until_complete(main())
loop.close()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hko-0.1.2.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

hko-0.1.2-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

Details for the file hko-0.1.2.tar.gz.

File metadata

  • Download URL: hko-0.1.2.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.6 CPython/3.7.0 Windows/10

File hashes

Hashes for hko-0.1.2.tar.gz
Algorithm Hash digest
SHA256 037ca068930ed5ade6098fb8e8230956ef9a7a079a033b1d84bd58fed51407a4
MD5 4c1a5b427642cae56dc3ce53aa4ba409
BLAKE2b-256 c347226ae0e29422d51af64e33a2dac270c307a915c6b4f5bb37dc58bcfaf174

See more details on using hashes here.

File details

Details for the file hko-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: hko-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 3.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.6 CPython/3.7.0 Windows/10

File hashes

Hashes for hko-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7b10040658da7e1c346f82effa4c4ea2d830fbbbc89f160af1924877dc73d87e
MD5 89e856f2022f53e0830c14c1f79e0a10
BLAKE2b-256 e5725326c16efa1e0a248469c40283fc570f33932be2f09f8e1fd1d01af2c204

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page