open_weather_map_api

Ada interface to openweathermap API

View the Project on GitHub HeisenbugLtd/open_weather_map_api

Open Weather Map API

Provides services to connect to the Open Weather Map API.

Implemented services:

Dependencies:

Requires

Quick start guide

  1. Download, compile and include in your own project.
    • For now I am assuming you know how to do that (see gprinstall etc.). I may write more detailed instructions later.
  2. Get your OpenWeatherMap API key
  3. Create an account at openweathermap.
  4. Log in to openweathermap.org
  5. In your account settings go to API keys.
  6. Create an API key.

  7. Copy the config.json.example to ~/.config/openweathermap/config.json, preferrably with mode 0600.
  8. Fill in your API key information.
  9. If you have a direct connection to the internet, clear out the proxy configuration (empty strings), otherwise fill in the required information.

This completes the configuration step.

API documentation

If you just want to use the provided API without changes, you may start at the source file open_weather_map-api.ads and use one of the Create_XXX subroutines to create a query object. You may want to take a look at test/open_weather_map-application.adb to see how the API is being used.

Query objects

API queries are abstracted in tagged types specifically designed for a single specific API query. All you need to do is to call Perform_Query and read out the returned data. In case of errors etc. the Current parameter will be empty (i.e. the discriminant Valid will be False).