Build a weather forecast app in Bubble by connecting to the OpenWeatherMap API through the API Connector, displaying current conditions and multi-day forecasts, and using geolocation to detect the user's location automatically. This tutorial covers API setup, data parsing, and building a clean weather dashboard.
Overview: Weather Forecast App in Bubble
A weather app fetches and displays weather data from an external API. This tutorial connects Bubble to OpenWeatherMap's free API, shows current conditions with icons, and displays a multi-day forecast — all without writing code.
Prerequisites
- A Bubble account with an app
- A free API key from openweathermap.org
- Basic understanding of the API Connector plugin
Step-by-step guide
Set up the OpenWeatherMap API
Set up the OpenWeatherMap API
Sign up at openweathermap.org and get a free API key. In Bubble, go to Plugins → API Connector → Add API named 'Weather.' Add a GET call 'Current Weather' with URL: https://api.openweathermap.org/data/2.5/weather?q=[city]&appid=[api_key]&units=metric. Mark api_key as Private. Set Use as Data. Initialize with a test city.
1GET https://api.openweathermap.org/data/2.5/weather?q=[city]&appid=[api_key]&units=metric23Response:4{5 "main": { "temp": 22.5, "humidity": 65 },6 "weather": [{ "description": "clear sky", "icon": "01d" }],7 "wind": { "speed": 5.2 },8 "name": "London"9}Expected result: The API call returns weather data for the test city.
Build the search and current weather display
Build the search and current weather display
Add a Search Input for city name and a Search button. On click: Set state 'current_city' = Input value. Below, add a Group with data source: Get data from external API → Weather - Current Weather (city = current_city). Display: city name, temperature with °C, weather description, humidity percentage, wind speed, and the weather icon (URL: https://openweathermap.org/img/wn/[icon_code]@2x.png).
Expected result: Users can search a city and see current weather conditions with an icon.
Add a multi-day forecast
Add a multi-day forecast
Add a second API call 'Forecast' with URL: https://api.openweathermap.org/data/2.5/forecast?q=[city]&appid=[api_key]&units=metric. Initialize it. This returns 5-day/3-hour forecasts. Display in a horizontal Repeating Group, filtering to one entry per day (noon reading). Show day name, icon, high/low temperatures.
Expected result: A 5-day forecast strip displays below the current weather.
Add geolocation for automatic location detection
Add geolocation for automatic location detection
Use the 'Current Geographic Position' data source (available on any element). On Page is loaded: use the user's latitude/longitude with a location-based API call. Add a second API call variant using lat/lon parameters instead of city name. Show a 'Use My Location' button that fetches weather for the detected coordinates.
Pro tip: Geolocation requires HTTPS and user permission. Fall back to a city search if permission is denied.
Expected result: The app detects the user's location and shows local weather automatically.
Style the weather dashboard
Style the weather dashboard
Add weather-appropriate background colors or gradients based on conditions (blue for clear, gray for cloudy, dark for rain). Use conditional formatting: When weather description contains 'rain' → background = gray gradient. Add a temperature unit toggle (°C/°F) that switches the API parameter between metric and imperial.
Expected result: A polished weather dashboard with dynamic styling based on conditions.
Complete working example
1WEATHER APP — SETUP SUMMARY2=============================34API CONNECTOR:5 Current Weather: GET .../weather?q=[city]&appid=[key]&units=metric6 Forecast: GET .../forecast?q=[city]&appid=[key]&units=metric7 By Location: GET .../weather?lat=[lat]&lon=[lon]&appid=[key]&units=metric89DISPLAY:10 Current: city, temp, description, icon, humidity, wind11 Forecast: 5-day strip with day, icon, high/low12 Icon URL: https://openweathermap.org/img/wn/{code}@2x.png1314GEOLOCATION:15 Current Geographic Position → lat/lon16 Fall back to city search if denied1718UNIT TOGGLE:19 Custom state: units (metric/imperial)20 Metric: °C, m/s | Imperial: °F, mphCommon mistakes when building a weather forecast app in Bubble
Why it's a problem: Not handling the API key activation delay
How to avoid: Wait for activation before testing. Use the API key test page on OpenWeatherMap to verify.
Why it's a problem: Calling the API on every keystroke in the search input
How to avoid: Use a Search button to trigger the call, not auto-search on input change
Why it's a problem: Not handling cities with special characters or spaces
How to avoid: Bubble's API Connector handles URL encoding automatically for bracketed parameters
Best practices
- Cache weather data for 30 minutes to reduce API calls
- Use the weather icon codes from OpenWeatherMap for consistent imagery
- Add a loading indicator while the API call is processing
- Fall back gracefully when geolocation is denied
- Display temperatures with one decimal place for clean formatting
- Add error handling for invalid city names
Still stuck?
Copy one of these prompts to get a personalized, step-by-step explanation.
I want to build a weather app in Bubble.io using OpenWeatherMap API. I need current weather, a 5-day forecast, and automatic location detection. Can you walk me through the API setup and display layout?
Build a weather forecast app. Connect to OpenWeatherMap API, display current weather with icons, add a 5-day forecast strip, and include geolocation for automatic location detection.
Frequently asked questions
Is the OpenWeatherMap API free?
Yes. The free tier allows 1,000 API calls per day, which is plenty for personal apps. Paid plans start at $40/month for higher limits.
Can I show weather in Fahrenheit?
Yes. Change the units parameter from 'metric' to 'imperial' in the API call. Add a toggle that switches between the two.
How do I cache weather data?
Create a WeatherCache data type. Store results with a timestamp. Check the cache before calling the API — if data is less than 30 minutes old, use the cached version.
Can I show weather for multiple cities at once?
Yes. Store a list of favorite cities on the User record. Use a Repeating Group that calls the weather API for each city.
Why does geolocation not work?
Geolocation requires HTTPS and user permission. Ensure your app is on a secure URL and handle the case when the user denies permission.
Can RapidDev build a weather-based application?
Yes. RapidDev builds location-aware apps with weather integration, maps, and environmental data dashboards.
Talk to an Expert
Our team has built 600+ apps. Get personalized help with your project.
Book a free consultation