With Serenum API, you will get a detailed overview over the current weather and weather forecast for a place. You will also get detailed information about a place's local date and time, including astronomical data like the current positions of the Sun and the Moon. And the best part: Serenum API are completely open sourced and you can install it on your own server!
The API are divided in 2 sections: getting all the data about a single place (index.php
), and see the difference between 2 places (diff.php
).
Before you can use Serenum API, you must get your own API key from OpenWeatherMap.
[your-api-key]
for the variable $apikey
in both index.php
and diff.php
.&key=[your-api-key]
to domain.com/api?coor=59.38079,13.50239
in your browser.Now go to https://domain.com/api
and follow the instructions which will say that you need to append the coordinates for the place you want to fetch the weather data for. You can get the coordinates for the place by go to OpenStreetMap or use the default ones that the API gives you.
If you choose to get coordinates from OSM, go to the place of choice and right-click on the place and choose "Centre map here". Now copy the coordinates from the URL and append them to domain.com/api
or domain.com/api/diff
. Follow the example in Serenum API for how it must look like.
/
with ,
for the coordinates before you continue.Serenum API only provides data in JSON.
https://domain.com/?coor=[latitude]
,[longitude]
&key=[apikey]
https://domain.com/diff?coor=[latitude]
,[longitude]
;[latitude]
,[longitude]
&key=[apikey]
Parameter | Required | Description |
latitude & longitude | Required Yes | Geographical coordinates. |
apikey | Required Yes | Your own API key from OpenWeatherMap. |
exclude | Not required No | Exclude stuff from the API call, seperated with a comma and no spaces. Available values: place , pollen , airp , astronomy . |
Despite the API itself are very self-explainable, there are fields that aren't and those are listed below. Other fields that needs more information are included.
Fields with the same name that can be found on more than 1 place, are listed with a wildcard (*).
apikey | Shows the entered API key. |
latitude | Geographical coordinates of the place in latitude (truncated to 5 digits). |
longitude | Geographical coordinates of the place in longitude (truncated to 5 digits). |
* . twentyfourhours | Shows the time in 24h format for the chosen place. |
* . twelvehours | Shows the time in 12h format for the chosen place. |
* . clouds | Cloud cover in percentage (%) |
* . humidity | Humidity in percentage (%) |
prob_precip | The probability of precipitation in percentage (%) |
moon . schedules . * . countdown . * | How many days, hours, and minutes there are left until the moon phase occures. The countdown goes after the chosen place's date and time. |
When an error occurs in Serenum API, you will get the error code, a message saying what the error means in short, and (depending on the error) 1 or 2 other variable(s) that will help you getting on the right path. All errors are listed below with further explaination.
Error code | Description |
Error 110 110 | The geographical coordinates (latitude and longitude) are missing in the URL. You need to specify these in order to get the data from OpenWeatherMap. Please see "Get the weather data" for how to get the coordinates for a place. |
Error 140 140 | The geographical coordinates (latitude and longitude) are not valid. To get a valid latitude och longitude, they need to be 5 or more digits and with - and/or . . You can get one from OpenStreetMap (see "Get the weather data" to learn how). |
Error 150 150 | The API key from OpenWeatherMap are missing in the URL. You need to login to your account at openweathermap.org and retrieve your API key from there. See "Get the API key" for more information. |
Error 160 160 | The API key from OpenWeatherMap are not valid. Go to openweathermap.org and login to your account and either create a new API key or confirm that the entered API key are activated. |
Error 170 170 | At least 1 excluded variable are missing in the URL. See "Get started" for more information. |
Error 200 200 | The API were not able to fetch the data from OpenWeatherMap. This can occur if the API key from OSM are not valid based on their standards or not activated. |
If you have stumbled upon any issues, feel free to contact us on either Codeberg or Telegram.