Basic Example: How To Connect OpenWeatherMap API to Titan Web and Flow
Business Background
This guide demonstrates how to integrate OpenWeatherMap’s Current Weather API with Titan Web, allowing users to enter their city name and instantly retrieve local weather information (e.g., temperature, description).
Prerequisites
- A free OpenWeatherMap account.
- A valid API key from your OpenWeatherMap dashboard.
(If newly created, wait 5–10 minutes for activation.)
Flow Setup
You’ll first create a Flow that connects to the Weather API, sends the city name entered by the user, and receives the weather data in return. This Flow acts as the bridge between your Web Project and the external API. The goal is to display live weather data for the city entered by the user in a Web project.
PART 1: Build the API in Titan Flow
Create Flow Variables
- Create the following variables in the Flow project using the Static Variables window. Click Apply.
- cityname – Stores the city name entered by the user in the Web project. The value will be sent to the API.
- temperature – Stores the specific temperature value extracted from the API response.
Configure the API Hub Node
- Open the API Hub Call node.
- Set the Request Type to GET.
- Add the following Parameters:
- q – field – GV/cityname
- units- static – metric
- api – static – Paste in your real OpenWeatherMap key
Titan will automatically build a URL like this:
https://api.openweathermap.org/data/2.5/weather?q=London&units=metric&appid=YOUR_API_KEY
For this example, no Authorization, Headers, or Body is required.
- In the Output tab, select JSON as the output format.
- Click Add Mapping Path and configure:
- String – main.temp – GV/temperature
This ensures you only store parts of the JSON and display the temperature only.
- String – main.temp – GV/temperature
- Add a Finish node and connect it to the API Hub Node. This ensures the Flow returns the mapped variables to the Web project.
- Save and Publish the Flow so a Web Project can trigger it.
PART 2: Build the Web Project
Once the Flow is published, you’ll create a Web Project to capture the user’s input and display the city temperature.
Create your Titan Web Variables
- Create the following variables in the Flow project using the Static Variables window. Click Apply.
- temperature
Add Elements to your Titan Project
In your Web project:
- Add a Text Box called ‘City Name’. This is where the user will input a city name.
- Add a Text Box called ‘Temperature’. The temperature for the city will populate this field.
- Add a Button labeled Get Temperature.
Configure On-Click Action Button
This button will: capture what city the user types, pass it to the flow, and display the temperature results.
- Navigate to the Get Temperature On Click Actions window.
- Click the Start + icon, choose Launch Flow node, and click Next.
- Choose your configured Flow (the one that includes your OpenWeatherMap API Hub call) and click Configure Parameters.
- Under Parameters, for cityname select Field and choose the city name input field. This sends the user’s city name from the Web project to the Flow so the API knows which city to query. Click Apply.
- Click Return Parameters. For temperature, select ‘Field’ and choose ‘temperature’. This returns the temperature value from the Flow to the Web project. Click Apply.
- Save the node once the mapping is complete.
- From the After Finish connector of the Launch Flow node, add an Affected Element node.
- Select the textbox that will display the temperature, choose Set Value From in the dropdown, and GV/temperature as the Value. Click Next and apply the configuration. This node updates the text box with the temperature value returned from the Flow.
- From the Affected Elements node, add a Show Toast node. Enter a short message to confirm that the API call was completed successfully. Apply the configuration.
Review your completed action flow. It should follow this sequence:
Result
When a user types a city name and clicks “Get Temperature,” the input is sent to the Flow. The Flow then runs and retrieves live weather data from OpenWeatherMap. Once the API call completes, the returned temperature is populated in the designated textbox, and a success toast message appears to confirm that the process has finished. All of this happens seamlessly within the same On Click Action window, forming one continuous workflow from user input to final output, exactly as shown in the example screenshot.
Part of this workflow:
- Invoke External API using Titan Flow
- Run Titan Flow from API
- Generate File
- Create Variables in Titan Flow
- Return Data from Titan Flow
- Environment Variables – Flow Trigger
- System Variables
- Custom Variables
- Configure On Click Actions
- Titan Flow Essentials course on Titan Academy
- Invoke External API using Titan Flow
- Run Titan Flow from API
- Generate File