Skip to content

API

bmkg.api

Earthquake

Bases: API

Earthquake API Wrapper from BMKG API.

get_felt_earthquake() async

Request felt earthquake from earthquake API.

Returns:

Type Description
Iterator[FeltEarthquake]

An iterator of fifteen FeltEarthquake schema.

Examples:

>>> import asyncio
>>> from bmkg import Earthquake
>>> async def main():
...     async with Earthquake() as earthquake:
...         felt_earthquake = await earthquake.get_felt_earthquake()
...         print(felt_earthquake)
>>> asyncio.run(main())
<generator object parse_felt_earthquake_data at ...>

get_latest_earthquake() async

Request latest earthquake from earthquake API.

Returns:

Type Description
LatestEarthquake

A LatestEarthquake schema.

Examples:

>>> import asyncio
>>> from bmkg import Earthquake
>>> async def main():
...     async with Earthquake() as earthquake:
...         latest_earthquake = await earthquake.get_latest_earthquake()
...         print(latest_earthquake)
>>> asyncio.run(main())
LatestEarthquake(earthquake=Earthquake(datetime=datetime.datetime(...)
Notes

The LatestEarthquake schema has a shakemap field which is the Shakemap API.

get_strong_earthquake() async

Request strong earthquake that has magnitude 5.0 above from earthquake API.

Returns:

Type Description
Iterator[StrongEarthquake]

An iterator of fifteen StrongEarthquake schema.

Examples:

>>> import asyncio
>>> from bmkg import Earthquake
>>> async def main():
...     async with Earthquake() as earthquake:
...         strong_earthquake = await earthquake.get_strong_earthquake()
...         print(strong_earthquake)
>>> asyncio.run(main())
<generator object parse_strong_earthquake_data at ...>

Shakemap

Bases: API, Shakemap

Shakemap API Wrapper from BMKG API.

get_content() async

Get the shakemap file content.

Returns:

Type Description
bytes

A bytes of Shakemap image.

Examples:

>>> import asyncio
>>> from bmkg import Earthquake
>>> async def main():
...     async with Earthquake() as earthquake:
...         latest_earthquake = await earthquake.get_latest_earthquake()
...         shakemap = latest_earthquake.shakemap
...         shakemap_content = await shakemap.get_content()
...         print(shakemap_content)
>>> asyncio.run(main())
b'...'

WeatherForecast

Bases: API

Weather Forecast API Wrapper from BMKG API.

get_weather_forecast(region_code) async

Request weather forecast from weather forecast API.

Parameters:

Name Type Description Default
region_code str

The administrative region code (level IV) for a subdistrict or village in Indonesia. The code is formatted as W.X.Y.Z (e.g., "11.01.01.2001"). You can find the list of available region codes at https://kodewilayah.id.

required

Returns:

Type Description
WeatherForecast

A WeatherForecastData schema.

Examples:

>>> import asyncio
>>> from bmkg import WeatherForecast
>>> async def main():
...     async with WeatherForecast() as weather_forecast:
...         weather_forecast_data = await weather_forecast.get_weather_forecast(
...             "11.01.01.2001"
...         )
...         print(weather_forecast_data)
>>> asyncio.run(main())
WeatherForecast(location=Location(admin_level_1=...)