hko


Namehko JSON
Version 0.3.2 PyPI version JSON
download
home_pagehttps://github.com/MisterCommand/python-hko
SummaryAn unofficial Python wrapper for public API of Hong Kong Observatory
upload_time2023-03-31 08:34:09
maintainer
docs_urlNone
authorMisterCommand
requires_python>=3.7,<4.0
licenseMIT
keywords hko weather
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![GitHub Release][releases-shield]][releases]
[![PyPI][pypi-releases-shield]][pypi-releases]

# 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][hko-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](https://docs.aiohttp.org/en/stable/client_reference.html)

`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][hko-documentation]
year | - | string | refer to [Official API Documentation][hko-documentation]
month | - | string |refer to [Official API Documentation][hko-documentation]
day | - | string | refer to [Official API Documentation][hko-documentation]
hour | - | string | refer to [Official API Documentation][hko-documentation]


## Usage Example
Get and print local weather forcast general situation in English
```python
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())
```





[hko-documentation]: https://www.hko.gov.hk/en/weatherAPI/doc/files/HKO_Open_Data_API_Documentation.pdf
[releases]: https://github.com/MisterCommand/python-hko
[releases-shield]: https://img.shields.io/github/release/MisterCommand/python-hko.svg?style=popout
[pypi-releases]: https://pypi.org/project/hko/
[pypi-releases-shield]: https://img.shields.io/pypi/v/hko
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/MisterCommand/python-hko",
    "name": "hko",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7,<4.0",
    "maintainer_email": "",
    "keywords": "hko,weather",
    "author": "MisterCommand",
    "author_email": "anthony.h@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/70/5a/09d5b1b0c8817964064f50274611566b757a4ab03bffa8b91de8337d5886/hko-0.3.2.tar.gz",
    "platform": null,
    "description": "[![GitHub Release][releases-shield]][releases]\n[![PyPI][pypi-releases-shield]][pypi-releases]\n\n# python-hko\nA python warpper for retrieving Hong Kong SAR local weather from Hong Kong Observatory Open Data API.\nPlease refer to the Official Documentation for request parameters and response details.\n[Official API Documentation][hko-documentation]\n\n## Reference\n### HKO Module\n`hko.HKO(session)`\nManage and perform requests\nReturn: hko.HKO class\n\nParameter | Optional (default value) | Type | Description\n--- | --- | --- | ---\nsession | no | ClientSession | see [aiohttp](https://docs.aiohttp.org/en/stable/client_reference.html)\n\n`hko.HKO.weather(dataType, lang)`\nRetrieve weather data from Weather Information API\nReturn: dictionary\n\nParameter | Optional (default value) | Type | Description\n--- | --- | --- | ---\ndataType | no | string | type of data requested\nlang | yes (en) | string | language used in response\n\n`hko.HKO.earthquake(dataType, lang)`\nRetrieve weather data from Earthquake Information API\nReturn: dictionary\n\nParameter | Optional (default value) | Type | Description\n--- | --- | --- | ---\ndataType | no | string | type of data requested\nlang | yes (en) | string | language used in response\n\n`hko.HKO.openData(dataType, lang)`\nRetrieve weather data from Earthquake Information API\nReturn: dictionary\n\nParameter | Optional (default value) | Type | Description\n--- | --- | --- | ---\ndataType | no | string | type of data requested\nlang | yes (en) | string | language used in response\nstation | - | string | refer to [Official API Documentation][hko-documentation]\nyear | - | string | refer to [Official API Documentation][hko-documentation]\nmonth | - | string |refer to [Official API Documentation][hko-documentation]\nday | - | string | refer to [Official API Documentation][hko-documentation]\nhour | - | string | refer to [Official API Documentation][hko-documentation]\n\n\n## Usage Example\nGet and print local weather forcast general situation in English\n```python\nfrom hko import HKO, HKOError\nimport asyncio\nfrom aiohttp import ClientSession\nfrom aiohttp import ClientConnectorError\n\nasync def main():\n    async with ClientSession() as session:\n        try:\n            hko = HKO(session)\n            fnd = await hko.weather(dataType=\"fnd\")\n            print(fnd[\"generalSituation\"])\n        except HKOError as error:\n            print(error)\n\nasyncio.run(main())\n```\n\n\n\n\n\n[hko-documentation]: https://www.hko.gov.hk/en/weatherAPI/doc/files/HKO_Open_Data_API_Documentation.pdf\n[releases]: https://github.com/MisterCommand/python-hko\n[releases-shield]: https://img.shields.io/github/release/MisterCommand/python-hko.svg?style=popout\n[pypi-releases]: https://pypi.org/project/hko/\n[pypi-releases-shield]: https://img.shields.io/pypi/v/hko",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "An unofficial Python wrapper for public API of Hong Kong Observatory",
    "version": "0.3.2",
    "split_keywords": [
        "hko",
        "weather"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5a8b435abcfa3888863951b614639aa96d883bb8d31c5ddda14a4c8bba4f5ac9",
                "md5": "69f5b57bf97bb3b416107d65e6ab2d35",
                "sha256": "86c97d13d7456cb6d54b2390bc659d0f7f9a912fd2f46ca59851f3a2d379b543"
            },
            "downloads": -1,
            "filename": "hko-0.3.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "69f5b57bf97bb3b416107d65e6ab2d35",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7,<4.0",
            "size": 3858,
            "upload_time": "2023-03-31T08:34:07",
            "upload_time_iso_8601": "2023-03-31T08:34:07.800145Z",
            "url": "https://files.pythonhosted.org/packages/5a/8b/435abcfa3888863951b614639aa96d883bb8d31c5ddda14a4c8bba4f5ac9/hko-0.3.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "705a09d5b1b0c8817964064f50274611566b757a4ab03bffa8b91de8337d5886",
                "md5": "441f731d66f59f406f2d82618d1ac7fc",
                "sha256": "e85cdd6926b0eec5f9db033c1db1c51ad29d47624183707670c6673fb45f433b"
            },
            "downloads": -1,
            "filename": "hko-0.3.2.tar.gz",
            "has_sig": false,
            "md5_digest": "441f731d66f59f406f2d82618d1ac7fc",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7,<4.0",
            "size": 3643,
            "upload_time": "2023-03-31T08:34:09",
            "upload_time_iso_8601": "2023-03-31T08:34:09.938073Z",
            "url": "https://files.pythonhosted.org/packages/70/5a/09d5b1b0c8817964064f50274611566b757a4ab03bffa8b91de8337d5886/hko-0.3.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-03-31 08:34:09",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "MisterCommand",
    "github_project": "python-hko",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "hko"
}
        
Elapsed time: 0.17447s