Connecting Power Apps to an External Weather API

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&current=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

  1. Navigate to Custom Connectors (use the “More” menu and pin if needed).
  2. Create a new connector: “Create from Blank”. Name it OpenMeteo.
  3. Set host to api.open-meteo.com and choose “No authentication”.
  4. 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.
  5. Test the connector

Integrating the Connector Into the App

  1. Add the connector via the Data section in Power Apps.
  2. Configure the dropdown’s OnChange property: Set(varWeather, OpenMeteo.GetTemperature( LatitudeText, LongitudeText, “true”, “fahrenheit” ) )
  3. 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.

Comments

Leave a Comment

Your email address will not be published. Required fields are marked *