Weather API

Weather API pozwala na pobieranie aktualnych danych pogodowych dla dowolnej lokalizacji. API korzysta z serwisu WeatherAPI.com, aby dostarczyć precyzyjne informacje o temperaturze, wietrze, wilgotności i innych parametrach pogodowych.

Endpoint

https://www.bdfdhub.pl/api/weather/api.php?locate=NAZWA_MIASTA

Odpowiedź API

API zwraca dane w formacie JSON z następującymi polami:


{
    "bh.weatherCity": "",
    "bh.weatherRegion": "",
    "bh.weatherCountry": "",
    "bh.weatherTemperature": "",
    "bh.weatherFeelsLike": "",
    "bh.weatherPressure": "",
    "bh.weatherHumidity": "",
    "bh.weatherWindSpeed": "",
    "bh.weatherWindDirection": "",
    "bh.weatherPrecipitation": "",
    "bh.weatherVisibility": "",
    "bh.weatherUV": "",
    "bh.weatherWeather": "",
    "bh.weatherIcon": "",
    "bh.weatherSource": ""
}
    

Zastosowania Weather API w botach Discord

Weather API może być używane w botach Discord do różnych celów, takich jak:

Przykład użycia w BDFD


$httpGet[https://www.bdfdhub.pl/api/weather/api.php?locate=$message[1]]
    

Przykładowa implementacja w komendzie BDFD


$httpGet[https://www.bdfdhub.pl/api/weather/api.php?locate=$message[1]]
$title[Pogoda dla $httpResult[bh.weatherCity], $httpResult[bh.weatherCountry]]
$description[
🌡 Temperatura: $httpResult[bh.weatherTemperature]  
🌬 Wiatr: $httpResult[bh.weatherWindSpeed] ($httpResult[bh.weatherWindDirection])  
💧 Wilgotność: $httpResult[bh.weatherHumidity]  
🌤 Pogoda: $httpResult[bh.weatherWeather]
]
$image[$httpResult[bh.weatherIcon]]
$footer[Źródło: $httpResult[bh.weatherSource]]
    

Przykładowy wynik w bocie

Po wykonaniu komendy bot wyświetli aktualne informacje pogodowe dla podanej lokalizacji.