Skip to main content

bmkg pypi downloads Build Status license BLAZINGLY FAST!!!

Unofficial Python wrapper for the BMKG (Meteorology, Climatology, and Geophysical Agency) API.

Installation

$ pip install bmkg

Examples

Fetching the weather of a specific province
# 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())
Fetching the latest earthquake
# 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())
Fetching the most recent earthquakes magnitude 5 or higher
# 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())
Fetching the most recent earthquakes regardless of their magnitude
# 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())

Metadata

Release files for bmkg 1.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bmkg 1.0.4
File Size Uploaded
bmkg-1.0.4.tar.gz 11.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bmkg 1.0.4
File Interpreter ABI Platform
bmkg-1.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 27.6 kB

Release files / bmkg-1.0.4.tar.gz

Download URL bmkg-1.0.4.tar.gz
Size 11.0 kB
Tags Source
SHA-256 checksum
How to use checksums
8f60ae90a683947c2ef7582d9556530c8efd6ec47c37a8d38b120e3f54ceca15
BLAKE2b-256 checksum
How to use checksums
0dcca96e569cfe16ae1255528179c7612aeb94b75c2f28e8945b6e6821c698f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release files / bmkg-1.0.4-py3-none-any.whl

Download URL bmkg-1.0.4-py3-none-any.whl
Size 16.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d5b86f4ed4e9f72bf59b4f265bb10d8063ba6daa6e677c2bfa0b6c601c34bc5f
BLAKE2b-256 checksum
How to use checksums
20acafae260d518716734939b8b5b34d1edb5e92d5e7fc689d80f4b8a4e943d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release history Release notifications | RSS feed

This release

1.0.4 This release

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.1.1

1 release file

0.1.0

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page