bmkg


Namebmkg JSON
Version 1.0.3 PyPI version JSON
download
home_page
SummaryUnofficial Python wrapper for the BMKG (Meteorology, Climatology, and Geophysical Agency) API.
upload_time2023-04-27 17:10:48
maintainer
docs_urlNone
authornull8626
requires_python>=3.7
licenseMIT
keywords weather forecast indonesia weather-api weather-forecast bmkg
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # [bmkg][pypi-url] [![pypi][pypi-image]][pypi-url] [![downloads][downloads-image]][pypi-url] [![Build Status][ci-image]][ci-url] [![license][github-license-image]][github-license-url] [![BLAZINGLY FAST!!!][blazingly-fast-image]][blazingly-fast-url]

[pypi-image]: https://img.shields.io/pypi/v/bmkg.svg?style=flat-square
[pypi-url]: https://pypi.org/project/bmkg/
[downloads-image]: https://img.shields.io/pypi/dm/bmkg?style=flat-square
[ci-image]: https://github.com/null8626/bmkg/workflows/CI/badge.svg
[ci-url]: https://github.com/null8626/bmkg/actions/workflows/CI.yml
[github-license-image]: https://img.shields.io/github/license/null8626/bmkg?style=flat-square
[github-license-url]: https://github.com/null8626/bmkg/blob/main/LICENSE
[blazingly-fast-image]: https://img.shields.io/badge/speed-BLAZINGLY%20FAST!!!%20%F0%9F%94%A5%F0%9F%9A%80%F0%9F%92%AA%F0%9F%98%8E-brightgreen.svg?style=flat-square
[blazingly-fast-url]: https://twitter.com/acdlite/status/974390255393505280

Unofficial Python wrapper for the [BMKG (Meteorology, Climatology, and Geophysical Agency)](https://www.bmkg.go.id/) API.

## Installation

```console
$ pip install bmkg
```

## Examples

<details>
<summary><b>Fetching the weather of a specific province</b></summary>

```py
# import the module
import bmkg

import asyncio
import os

async def getweather():
  # declare the client. the measuring unit used defaults to the metric system (celcius, km/h, etc.)
  async with bmkg.Client(unit=bmkg.IMPERIAL) as client:
    # fetch a weather forecast from a province
    weather = await client.get_forecast(bmkg.Province.JAKARTA)
    
    # get the weather forecast across various locations
    for forecast in weather.forecasts:
    
      # temperature of this forecast across various timeframes
      for temp in weather.temperature:
        print(f'temperature at {temp.date!r} is {temp.value!r}')

if __name__ == '__main__':
  # see https://stackoverflow.com/questions/45600579/asyncio-event-loop-is-closed-when-getting-loop
  # for more details
  if os.name == 'nt':
    asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
  
  asyncio.run(getweather())
```

</details>
<details>
<summary><b>Fetching the latest earthquake</b></summary>

```py
# import the module
import bmkg

import asyncio
import os

async def getweather():
  # declare the client. the measuring unit used defaults to the metric system (celcius, km/h, etc.)
  async with bmkg.Client(unit=bmkg.IMPERIAL) as client:
    # fetch the latest earthquake
    earthquake = await client.get_latest_earthquake()
    
    print(repr(earthquake))

if __name__ == '__main__':
  # see https://stackoverflow.com/questions/45600579/asyncio-event-loop-is-closed-when-getting-loop
  # for more details
  if os.name == 'nt':
    asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
  
  asyncio.run(getweather())
```

</details>
<details>
<summary><b>Fetching the most recent earthquakes magnitude 5 or higher</b></summary>

```py
# import the module
import bmkg

import asyncio
import os

async def getweather():
  # declare the client. the measuring unit used defaults to the metric system (celcius, km/h, etc.)
  async with bmkg.Client(unit=bmkg.IMPERIAL) as client:
    # fetch the most recent earthquakes magnitude 5 or higher
    earthquakes = await client.get_recent_earthquakes()
    
    # iterate through the generator
    for earthquake in earthquakes:
      print(repr(earthquake))

if __name__ == '__main__':
  # see https://stackoverflow.com/questions/45600579/asyncio-event-loop-is-closed-when-getting-loop
  # for more details
  if os.name == 'nt':
    asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
  
  asyncio.run(getweather())
```

</details>
<details>
<summary><b>Fetching the most recent earthquakes regardless of their magnitude</b></summary>

```py
# import the module
import bmkg

import asyncio
import os

async def getweather():
  # declare the client. the measuring unit used defaults to the metric system (celcius, km/h, etc.)
  async with bmkg.Client(unit=bmkg.IMPERIAL) as client:
    # fetch the most recent earthquakes regardless of their magnitude
    earthquakes = await client.get_felt_earthquakes()
    
    # iterate through the generator
    for earthquake in earthquakes:
      print(repr(earthquake))

if __name__ == '__main__':
  # see https://stackoverflow.com/questions/45600579/asyncio-event-loop-is-closed-when-getting-loop
  # for more details
  if os.name == 'nt':
    asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
  
  asyncio.run(getweather())
```

</details>

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "bmkg",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "weather,forecast,indonesia,weather-api,weather-forecast,bmkg",
    "author": "null8626",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/e6/82/36beda05cb7e454fe122b483cfa5a96515659e2f47509631c0c236f9eaf6/bmkg-1.0.3.tar.gz",
    "platform": null,
    "description": "# [bmkg][pypi-url] [![pypi][pypi-image]][pypi-url] [![downloads][downloads-image]][pypi-url] [![Build Status][ci-image]][ci-url] [![license][github-license-image]][github-license-url] [![BLAZINGLY FAST!!!][blazingly-fast-image]][blazingly-fast-url]\r\n\r\n[pypi-image]: https://img.shields.io/pypi/v/bmkg.svg?style=flat-square\r\n[pypi-url]: https://pypi.org/project/bmkg/\r\n[downloads-image]: https://img.shields.io/pypi/dm/bmkg?style=flat-square\r\n[ci-image]: https://github.com/null8626/bmkg/workflows/CI/badge.svg\r\n[ci-url]: https://github.com/null8626/bmkg/actions/workflows/CI.yml\r\n[github-license-image]: https://img.shields.io/github/license/null8626/bmkg?style=flat-square\r\n[github-license-url]: https://github.com/null8626/bmkg/blob/main/LICENSE\r\n[blazingly-fast-image]: https://img.shields.io/badge/speed-BLAZINGLY%20FAST!!!%20%F0%9F%94%A5%F0%9F%9A%80%F0%9F%92%AA%F0%9F%98%8E-brightgreen.svg?style=flat-square\r\n[blazingly-fast-url]: https://twitter.com/acdlite/status/974390255393505280\r\n\r\nUnofficial Python wrapper for the [BMKG (Meteorology, Climatology, and Geophysical Agency)](https://www.bmkg.go.id/) API.\r\n\r\n## Installation\r\n\r\n```console\r\n$ pip install bmkg\r\n```\r\n\r\n## Examples\r\n\r\n<details>\r\n<summary><b>Fetching the weather of a specific province</b></summary>\r\n\r\n```py\r\n# import the module\r\nimport bmkg\r\n\r\nimport asyncio\r\nimport os\r\n\r\nasync def getweather():\r\n  # declare the client. the measuring unit used defaults to the metric system (celcius, km/h, etc.)\r\n  async with bmkg.Client(unit=bmkg.IMPERIAL) as client:\r\n    # fetch a weather forecast from a province\r\n    weather = await client.get_forecast(bmkg.Province.JAKARTA)\r\n    \r\n    # get the weather forecast across various locations\r\n    for forecast in weather.forecasts:\r\n    \r\n      # temperature of this forecast across various timeframes\r\n      for temp in weather.temperature:\r\n        print(f'temperature at {temp.date!r} is {temp.value!r}')\r\n\r\nif __name__ == '__main__':\r\n  # see https://stackoverflow.com/questions/45600579/asyncio-event-loop-is-closed-when-getting-loop\r\n  # for more details\r\n  if os.name == 'nt':\r\n    asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())\r\n  \r\n  asyncio.run(getweather())\r\n```\r\n\r\n</details>\r\n<details>\r\n<summary><b>Fetching the latest earthquake</b></summary>\r\n\r\n```py\r\n# import the module\r\nimport bmkg\r\n\r\nimport asyncio\r\nimport os\r\n\r\nasync def getweather():\r\n  # declare the client. the measuring unit used defaults to the metric system (celcius, km/h, etc.)\r\n  async with bmkg.Client(unit=bmkg.IMPERIAL) as client:\r\n    # fetch the latest earthquake\r\n    earthquake = await client.get_latest_earthquake()\r\n    \r\n    print(repr(earthquake))\r\n\r\nif __name__ == '__main__':\r\n  # see https://stackoverflow.com/questions/45600579/asyncio-event-loop-is-closed-when-getting-loop\r\n  # for more details\r\n  if os.name == 'nt':\r\n    asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())\r\n  \r\n  asyncio.run(getweather())\r\n```\r\n\r\n</details>\r\n<details>\r\n<summary><b>Fetching the most recent earthquakes magnitude 5 or higher</b></summary>\r\n\r\n```py\r\n# import the module\r\nimport bmkg\r\n\r\nimport asyncio\r\nimport os\r\n\r\nasync def getweather():\r\n  # declare the client. the measuring unit used defaults to the metric system (celcius, km/h, etc.)\r\n  async with bmkg.Client(unit=bmkg.IMPERIAL) as client:\r\n    # fetch the most recent earthquakes magnitude 5 or higher\r\n    earthquakes = await client.get_recent_earthquakes()\r\n    \r\n    # iterate through the generator\r\n    for earthquake in earthquakes:\r\n      print(repr(earthquake))\r\n\r\nif __name__ == '__main__':\r\n  # see https://stackoverflow.com/questions/45600579/asyncio-event-loop-is-closed-when-getting-loop\r\n  # for more details\r\n  if os.name == 'nt':\r\n    asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())\r\n  \r\n  asyncio.run(getweather())\r\n```\r\n\r\n</details>\r\n<details>\r\n<summary><b>Fetching the most recent earthquakes regardless of their magnitude</b></summary>\r\n\r\n```py\r\n# import the module\r\nimport bmkg\r\n\r\nimport asyncio\r\nimport os\r\n\r\nasync def getweather():\r\n  # declare the client. the measuring unit used defaults to the metric system (celcius, km/h, etc.)\r\n  async with bmkg.Client(unit=bmkg.IMPERIAL) as client:\r\n    # fetch the most recent earthquakes regardless of their magnitude\r\n    earthquakes = await client.get_felt_earthquakes()\r\n    \r\n    # iterate through the generator\r\n    for earthquake in earthquakes:\r\n      print(repr(earthquake))\r\n\r\nif __name__ == '__main__':\r\n  # see https://stackoverflow.com/questions/45600579/asyncio-event-loop-is-closed-when-getting-loop\r\n  # for more details\r\n  if os.name == 'nt':\r\n    asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())\r\n  \r\n  asyncio.run(getweather())\r\n```\r\n\r\n</details>\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Unofficial Python wrapper for the BMKG (Meteorology, Climatology, and Geophysical Agency) API.",
    "version": "1.0.3",
    "split_keywords": [
        "weather",
        "forecast",
        "indonesia",
        "weather-api",
        "weather-forecast",
        "bmkg"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "425f7f601330e984b380c45193f75045f6c61b2a2225ec4a783380c92073bf67",
                "md5": "a73deae811903acd88963ac7bfc651b9",
                "sha256": "49f2e231f94e979fb374929f6a1d98b71afc199e68f81faf241650b06706ae18"
            },
            "downloads": -1,
            "filename": "bmkg-1.0.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a73deae811903acd88963ac7bfc651b9",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 16575,
            "upload_time": "2023-04-27T17:10:45",
            "upload_time_iso_8601": "2023-04-27T17:10:45.765948Z",
            "url": "https://files.pythonhosted.org/packages/42/5f/7f601330e984b380c45193f75045f6c61b2a2225ec4a783380c92073bf67/bmkg-1.0.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e68236beda05cb7e454fe122b483cfa5a96515659e2f47509631c0c236f9eaf6",
                "md5": "fa926131787abd4265ddab0ced86c33c",
                "sha256": "ccbee8c765d1901c32a00c6910aa86570d9825cbd3b8fddf64e3b03aee535405"
            },
            "downloads": -1,
            "filename": "bmkg-1.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "fa926131787abd4265ddab0ced86c33c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 10993,
            "upload_time": "2023-04-27T17:10:48",
            "upload_time_iso_8601": "2023-04-27T17:10:48.421594Z",
            "url": "https://files.pythonhosted.org/packages/e6/82/36beda05cb7e454fe122b483cfa5a96515659e2f47509631c0c236f9eaf6/bmkg-1.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-27 17:10:48",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "bmkg"
}
        
Elapsed time: 0.10205s