Beginner 2-3 hours · 3 APIs

Build a Rain Alert App

Get notified on your phone whenever rain is expected in your area. Combines weather forecasts with IP-based location detection and push notifications.

APIs Used

Data Flow

USER User opens the app API Detect location from IP address via IP Geolocation API Fetch hourly weather forecast via OpenWeatherMap PROCESS Check for rain probability above 60% API Send rain alert push notification via OneSignal
User Action
API Call
Transform
Output

How It Works

1

Detect the user's location using IP Geolocation API

2

Fetch the hourly weather forecast for that location from OpenWeatherMap

3

Check if any upcoming hours have rain probability above 60%

4

If rain is expected, send a push notification via OneSignal

Code Outline

Pseudocode / JavaScript
// 1. Get user location
const geo = await fetch('https://api.ipgeolocation.io/ipgeo?apiKey=YOUR_API_KEY');
const { latitude, longitude } = await geo.json();

// 2. Fetch weather forecast
const weather = await fetch(
  `https://api.openweathermap.org/data/2.5/forecast?lat=${latitude}&lon=${longitude}&appid=YOUR_API_KEY`
);
const forecast = await weather.json();

// 3. Check for rain in next 6 hours
const rainyHours = forecast.list.slice(0, 6).filter(
  h => h.weather[0].main === 'Rain'
);

// 4. Send notification if rain expected
if (rainyHours.length > 0) {
  await fetch('https://onesignal.com/api/v1/notifications', {
    method: 'POST',
    headers: { 'Authorization': 'Basic YOUR_ONESIGNAL_KEY' },
    body: JSON.stringify({ contents: { en: 'Rain expected today!' } })
  });
}

Note: These recipes are AI-generated suggestions based on API capabilities. Actual implementation may vary. Always refer to official API documentation for the latest specifications.