Unofficial Python wrapper for the BMKG (Meteorology, Climatology, and Geophysical Agency) API.
Project description
bmkg
Unofficial Python wrapper for the BMKG (Meteorology, Climatology, and Geophysical Agency) API.
Installation
$ pip install bmkg
Example
# 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())
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
bmkg-1.0.2.tar.gz
(10.1 kB
view hashes)
Built Distribution
bmkg-1.0.2-py3-none-any.whl
(15.8 kB
view hashes)