bmkg

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)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bmkg-1.0.4.tar.gz | 11.0 kB | Without provenance | Details for bmkg-1.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bmkg-1.0.4-py3-none-any.whl | Python 3 | none | any | Details for bmkg-1.0.4-py3-none-any.whl |
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
|
Security for bmkg 1.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.