Overview
The WeatherAPI.com prefab returns weather data from a given location, based on its latitude and longitude values. Those values can be selected from map coordinates or from the user's location data, among other things.
Important Note About Using API Keys in Play
If you are using any sensitive API keys in your Fetch nodes, these keys are exposed and can be seen by users of your prototypes and apps.
For prototypes, make sure you have your App Clip's password protected and that you are sending to trusted sources.
For Export to Xcode, we recommend you store your keys server side using services like Firebase Cloud Functions, Supabase Edge Functions, or AWS Lambda for secure request handling.
Prefab Controls
Fetch Onload
Choose if the Fetch API should occur immediately when the page loads.
API Key
Enter your API key for the Weather API. You can create an API key here.
Lat
Set the latitude value that the prefab will use. To update the latitude based on a map or user location, read the Get API Data section below.
Lon
Set the longitude value that the prefab will use. To update the longitude based on a map or user location, read the Get API Data section below.
API Loading
Add actions to fire while the API loads.
API Response
Add actions to fire when the API responds (loads successfully).
API Error
Add actions to fire if the API fails to load.
Get API Data
To dynamically access weather data for a different location, you can update the prefab's latitude and longitude values through user interaction.
Map Location Input
To set the lat and lon values based on a map location or a user location, set the lat and lon values to the coordinates of the map or user location.
Page.WeatherAPI.com.#Lat = Map.lat
Break the expression down
Break the expression down
Variable Expression:
Page—The location of the prefab
WeatherAPI.com—The prefab name
#Lat—The prefab variable
Value Expression:
Map—The map that the location is set on
value—The map property for the latitude coordinate
Populate Data
To display the Weather API's response, you can output a value from the #response Dictionary variable to a text element. This Set Text action should be placed on the API Response section on the prefab.
#response.key("location").key("name")