Get Weather Data

Use this recipe to get the weather data from an external source for a city and send the details to the caller as a response.

Note:

This recipe is available as Oracle REST Get Weather DataService in the Integration Store. Oracle provides this recipe as a sample only. The recipe is meant only for guidance, and is not warranted to be error-free. No support is provided for this recipe.

Overview

This recipe demonstrates how to get the weather data from an external source for a particular zip code and send the weather details to the caller as a response.

To use the recipe, you must configure the Oracle REST Weather Connection by specifying the connection URL of a weather application (for example, https://api.openweathermap.org/data/2.5/weather). Subsequently, you can trigger the first REST Adapter of the recipe by specifying a zip code and the API key for the connection URL. The second REST Adapter (which uses the REST connection you configured) is then invoked in the integration, and it fetches the weather details from the specified connection URL. The response containing the weather data is returned to you.

A logging message is created and logged to the activity stream for viewing.

You can also track the integration and monitor the message status.

You can invoke the REST API using the following command to get the weather data through the recipe:
GET: https://host:port/ic/api/integration/v1/flows/rest/ORCL-R-REST_GET_WEATHER_DATA/1.0/weather?zip={zip_code}&appid={api_key}
Example Response Payload:
{
    "coord": {
        "lon": -96.9905,
        "lat": 32.8653
    },
    "weather": [
        {
            "id": 804,
            "main": "Clouds",
            "description": "overcast clouds",
            "icon": "04d"
        }
    ],
    "base": "stations",
    "main": {
        "temp": 269.41,
        "feels_like": 262.04,
        "temp_min": 269.15,
        "temp_max": 269.82,
        "pressure": 1024,
        "humidity": 86
    },
    "visibility": 10000,
    "wind": {
        "speed": 6.69,
        "deg": 350
    },
    "clouds": {
        "all": 90
    },
    "dt": 1613058731,
    "sys": {
        "type": 1,
        "id": 3807,
        "country": "US",
        "sunrise": 1613049292,
        "sunset": 1613088582
    },
    "timezone": -21600,
    "id": 0,
    "name": "Irving",
    "cod": 200
}

System and Access Requirements

  • Oracle Integration

  • A weather application's connection URL and API key

Install, Configure, and Run the Recipe

For more information and steps to install, configure, and run recipes, see Get Started with Integration Accelerators and Recipes.

To use this recipe, you must configure the Oracle REST Weather Connection. You must supply the following information when you configure this connection:

Connection Name Parameters

Oracle REST Weather Connection

Connection Properties

  • Connection Type: REST API Base URL.
  • Connection URL: The connection URL of a weather application (for example, https://api.openweathermap.org/data/2.5/weather).

Security

  • Security Policy: API Key Based Authentication.
  • API Key: The API key for the connection URL.

For more details, see Create a REST Adapter Connection.