Connecting APIs into Power Apps applications can supercharge functionality by bringing in dynamic, real-time data. In this tutorial, explore how to connect Power Apps to the Open-Meteo weather API to retrieve weather information based on a user-selected city.
Application Overview
The app allows users to:
- Select a city from a dropdown menu.
- View the corresponding latitude and longitude (initially hardcoded).
- Retrieve current weather data using the Open-Meteo API.
Cities available in the dropdown:
- New York → Latitude: 40.73, Longitude: -73.93
- Dallas → Latitude: 32.77, Longitude: -96.79
- Miami → Latitude: 25.76, Longitude: -80.19
What Is an API?
An API (Application Programming Interface) allows software applications to communicate and exchange data. In this case, Power Apps sends an HTTP GET request to the Open-Meteo API, asking for weather data at specific coordinates.
Exploring the Open-Meteo API
The API endpoint accepts the following parameters:
- latitude
- longitude
- current
- temperature_unit
Example GET request:
https://api.open-meteo.com/v1/forecast?latitude=40.73&longitude=-73.93¤t=temperature_2m&temperature_unit=fahrenheit
Response includes the current temperature and other weather conditions based on provided coordinates.
Creating a Custom Connector in Power Apps
- Navigate to Custom Connectors (use the “More” menu and pin if needed).
- Create a new connector: “Create from Blank”. Name it
OpenMeteo
. - Set host to
api.open-meteo.com
and choose “No authentication”. - Define the API request:
- Add a new action:
GetTemperature
. - Use the GET method and input the base URL with parameters.
- Import parameters from a sample URL.
- Add a new action:
- Test the connector
Integrating the Connector Into the App
- Add the connector via the Data section in Power Apps.
- Configure the dropdown’s OnChange property: Set(varWeather, OpenMeteo.GetTemperature( LatitudeText, LongitudeText, “true”, “fahrenheit” ) )
- Display the temperature with a label: “Current temperature in ” & CityDropdown.Selected.Value & “: ” & varWeather.current.temperature_2m
Final Result
Changing the city dropdown updates the latitude and longitude, and automatically fetches the current temperature from Open-Meteo. This showcases the power of API integration inside Power Apps—transforming static apps into responsive, data-rich tools.
Leave a Comment