nina-api
Version:
90 lines (87 loc) • 2.93 kB
JavaScript
import { ofetch } from 'ofetch';
const API_BASE_URL = "https://nina.api.proxy.bund.dev/api31";
class Nina {
/**
* Retrieves the dashboard data for a given ARS.
* @param ars - The ARS (Amtlicher Regional Schlüssel).
* @see https://www.xrepository.de/api/xrepository/urn:de:bund:destatis:bevoelkerungsstatistik:schluessel:rs_2021-07-31/download/Regionalschl_ssel_2021-07-31.json
* @returns A promise that resolves to an array of NinaDashboardItem objects, or undefined if the request fails.
*/
async getDashboard(ars) {
const res = await ofetch(`${API_BASE_URL}/dashboard/${ars}.json`, {
method: "GET"
});
return res;
}
/**
* Retrieves the map data for the Katwarn service.
* @returns A promise that resolves to an unknown object, or undefined if the request fails.
*/
async getKatwarnMapData() {
const res = await ofetch(`${API_BASE_URL}/katwarn/mapData.json`, {
method: "GET"
});
return res;
}
/**
* Retrieves the map data for the Biwapp service.
* @returns A promise that resolves to an array of MapData objects, or undefined if the request fails.
*/
async getBiwappMapData() {
const res = await ofetch(`${API_BASE_URL}/biwapp/mapData.json`, {
method: "GET"
});
return res;
}
/**
* Retrieves the map data for the Mowas service.
* @returns A promise that resolves to an array of MapData objects, or undefined if the request fails.
*/
async getMowasMapData() {
const res = await ofetch(`${API_BASE_URL}/mowas/mapData.json`, {
method: "GET"
});
return res;
}
/**
* Retrieves the map data for the DWD (Deutscher Wetterdienst) service.
* @returns A promise that resolves to an array of MapData objects, or undefined if the request fails.
*/
async getDwdMapData() {
const res = await ofetch(`${API_BASE_URL}/dwd/mapData.json`, {
method: "GET"
});
return res;
}
/**
* Retrieves the map data for the LHP (Länderübergreifende Hochwasserportal) service.
* @returns A promise that resolves to an array of MapData objects, or undefined if the request fails.
*/
async getLhpMapData() {
const res = await ofetch(`${API_BASE_URL}/lhp/mapData.json`, {
method: "GET"
});
return res;
}
/**
* Retrieves the map data for the Police Information service.
* @returns A promise that resolves to an array of MapData objects, or undefined if the request fails.
*/
async getPoliceMapData() {
const res = await ofetch(`${API_BASE_URL}/police/mapData.json`, {
method: "GET"
});
return res;
}
/**
* Retrieves a specific warning by its ID.
* @returns A promise that resolves to a Warning object, or undefined if the request fails.
*/
async getWarning(id) {
const res = await ofetch(`${API_BASE_URL}/warnings/${id}.json`, {
method: "GET"
});
return res;
}
}
export { Nina as default };