Weather Forecast Actor
Pricing
from $0.05 / 1,000 results
Weather Forecast Actor
Pricing
from $0.05 / 1,000 results
Rating
0.0
(0)
Developer

Uma Mahesh
Actor stats
0
Bookmarked
1
Total users
0
Monthly active users
5 days ago
Last modified
Categories
Share
π€οΈ Weather Forecast Actor
Get accurate 7-day weather forecasts for any location worldwide using GPS coordinates.
Built for the Apify $1M Challenge π
β¨ Features
- π GPS-Based Forecasts - Use precise latitude/longitude coordinates
- π 7-Day Outlook - Comprehensive weekly weather predictions
- π‘οΈ Flexible Units - Support for both metric (Celsius) and imperial (Fahrenheit)
- β‘ Lightning Fast - Executes in 1-3 seconds
- π Rich Data - Temperature, humidity, wind, precipitation, and more
- π Type-Safe - Built with TypeScript for reliability
- π Global Coverage - Works for any location on Earth
π Quick Start
Input Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
latitude | number | β Yes | GPS latitude (-90 to 90) |
longitude | number | β Yes | GPS longitude (-180 to 180) |
units | string | No | "metric" (Celsius) or "imperial" (Fahrenheit). Default: "metric" |
apiKey | string | β Yes | OpenWeatherMap API key (Get free key) |
Example Input
{"latitude": 40.7128,"longitude": -74.0060,"units": "metric","apiKey": "your_openweathermap_api_key"}
Example Output
{"location": {"latitude": 40.7128,"longitude": -74.006,"city": "New York","country": "US","timezone": -18000},"units": "metric","forecast_period": "6-day forecast","retrieved_at": "2025-12-25T05:01:20.441Z","data_points": 40,"daily_forecast": [{"date": "2025-12-25","temperature": {"min": 2,"max": 6,"average": 4.2,"unit": "Β°C"},"feels_like": {"day": -1,"night": -3},"humidity": 60,"pressure": 1017,"weather": {"main": "Clouds","description": "overcast clouds"},"wind": {"speed": 5.5,"direction": 280},"precipitation": {"probability": 0,"amount": 0},"clouds": 100,"visibility": 10000}// ... more days]}
π Getting Started
Prerequisites
-
Get a FREE API Key from OpenWeatherMap
- Sign up for a free account
- Navigate to API Keys section
- Copy your API key
- Wait 10-15 minutes for activation
-
Choose your method:
- Option A: Run on Apify Platform (easiest)
- Option B: Run locally with Node.js
- Option C: Run with Docker
π¦ Installation & Usage
Option A: Running on Apify Platform (Recommended)
- Visit Apify Console
- Create a new Actor or search for "Weather Forecast GPS"
- Provide your input:
{"latitude": 40.7128,"longitude": -74.0060,"units": "metric","apiKey": "your_api_key_here"}
- Click "Start" and collect results from the dataset
Advantages: No setup, runs in cloud, always available
Option B: Running Locally with Node.js
# 1. Clone or download this repositorycd weather-forecast-actor# 2. Install dependenciesnpm install# 3. Build the projectnpm run build# 4. Create input file# Create storage/key_value_stores/default/INPUT.json with:{"latitude": 40.7128,"longitude": -74.0060,"units": "metric","apiKey": "your_openweathermap_api_key"}# 5. Run with Apify CLInpx apify run# 6. View outputcat storage/datasets/default/000000001.json
Advantages: Fast iteration, easy debugging, no internet required for code changes
Option C: Running with Docker
# 1. Start Docker Desktop application# 2. Navigate to project directorycd weather-forecast-actor# 3. Build Docker imagedocker build -t weather-forecast-actor .# 4. Run the containerdocker run --rm -v ${PWD}/storage:/actor/storage weather-forecast-actor# 5. View outputcat storage/datasets/default/000000001.json
Advantages: Exact production environment, isolated dependencies, reproducible builds
Quick Test (Any Method)
After running, you should see:
β Success! Retrieved 6-day forecast for New York
And your output file will contain rich weather data like:
{"location": {"city": "New York","country": "US"},"daily_forecast": [{"date": "2025-12-25","temperature": {"min": 2,"max": 6,"average": 4.2,"unit": "Β°C"},"weather": {"main": "Clouds","description": "overcast clouds"}}]}
π Finding GPS Coordinates
Quick Methods
- Google Maps: Right-click any location β Click the coordinates
- Current Location: Use browser's geolocation API
- Address Lookup: LatLong.net
Popular Locations
| City | Latitude | Longitude |
|---|---|---|
| New York, USA | 40.7128 | -74.0060 |
| London, UK | 51.5074 | -0.1278 |
| Tokyo, Japan | 35.6762 | 139.6503 |
| Paris, France | 48.8566 | 2.3522 |
| Sydney, Australia | -33.8688 | 151.2093 |
| Dubai, UAE | 25.2048 | 55.2708 |
| SΓ£o Paulo, Brazil | -23.5505 | -46.6333 |
π Getting an API Key
This Actor uses the OpenWeatherMap API:
- Visit OpenWeatherMap
- Sign up for a free account
- Navigate to API Keys section
- Copy your API key
- Wait 10-15 minutes for activation
Free tier includes:
- 60 calls per minute
- 1,000,000 calls per month
- Perfect for most use cases!
π Output Data Schema
Location Object
latitude,longitude- Input coordinatescity,country- Resolved location namestimezone- UTC offset in seconds
Daily Forecast Object
date- ISO date string (YYYY-MM-DD)temperature- Min, max, average temps with unitfeels_like- Day and night apparent temperaturehumidity- Average relative humidity (%)pressure- Average atmospheric pressure (hPa)weather- Main condition and descriptionwind- Speed and directionprecipitation- Probability (%) and amount (mm)clouds- Cloud coverage (%)visibility- Visibility distance (meters)
π― Use Cases
For Travelers βοΈ
- Check weather before booking flights
- Plan clothing and gear for trips
- Avoid bad weather destinations
For Event Planners πͺ
- Schedule outdoor events with confidence
- Have backup plans for rain
- Optimize attendee comfort
For Developers π€
- Integrate weather into apps
- Build AI agents with weather awareness
- Create automated weather alerts
For Data Analysis π
- Collect weather patterns over time
- Correlate weather with business metrics
- Build predictive models
ποΈ Technical Stack
- Runtime: Node.js 20+
- Language: TypeScript 5.3
- Framework: Apify SDK 3.2
- HTTP Client: Axios
- Data Source: OpenWeatherMap API
- Deployment: Docker containerized
π οΈ Development
Project Structure
weather-forecast-actor/βββ src/β βββ main.ts # Main Actor logic (430 lines)βββ .actor/β βββ actor.json # Actor metadataβ βββ input_schema.json # Input validationβ βββ INPUT.json # Local input (git-ignored)βββ storage/ # Local storage (git-ignored)β βββ datasets/ # Output dataβ βββ key_value_stores/ # Input dataβββ dist/ # Compiled JavaScriptβββ package.jsonβββ tsconfig.jsonβββ Dockerfileβββ README.md
Available Scripts
npm run build # Compile TypeScriptnpm run start # Run compiled codenpm run dev # Run with ts-nodenpm run lint # Type-check codenpm run clean # Remove dist foldernpm run rebuild # Clean and build
Building for Production
# Clean buildnpm run rebuild# Test locallynpx apify run# Test with Dockerdocker build -t weather-forecast-actor .docker run --rm -v ${PWD}/storage:/actor/storage weather-forecast-actor# Deploy to Apifyapify loginapify push
π³ Docker Commands
Build the image:
$docker build -t weather-forecast-actor .
Run the container:
$docker run --rm -v ${PWD}/storage:/actor/storage weather-forecast-actor
Run with custom input:
# Create input file first, then:docker run --rm \-v ${PWD}/storage:/actor/storage \weather-forecast-actor
Debug inside container:
docker run -it --rm \-v ${PWD}/storage:/actor/storage \--entrypoint /bin/bash \weather-forecast-actor
List images:
$docker images
Remove image:
$docker rmi weather-forecast-actor
π Error Handling
The Actor handles common errors gracefully:
- Invalid API Key (401): Clear message with activation instructions
- Location Not Found (404): Suggests checking coordinates
- Rate Limit (429): Advises waiting or upgrading
- Network Errors: Provides connectivity troubleshooting
- Invalid Input: Validates all parameters with helpful messages
π Troubleshooting
Docker Issues
"Docker daemon is not running"
# Solution: Start Docker Desktop application# Check if running:docker ps
"Cannot find the file specified" (Windows)
# Solution: Ensure Docker Desktop is running# Restart Docker Desktop if needed
Build fails with npm errors
# Solution: Clean build without cachedocker build --no-cache -t weather-forecast-actor .
Container can't find INPUT.json
# Solution: Ensure the file existsls storage/key_value_stores/default/INPUT.json# Create the directory structure if missing:mkdir -p storage/key_value_stores/default
Local Run Issues
"Input is required"
# Solution: Use npx apify run instead of npm startnpx apify run
API Key errors
# Solution: Wait 10-15 minutes after creating OpenWeatherMap account# Check key status at: https://home.openweathermap.org/api_keys
Module not found
# Solution: Reinstall dependenciesrm -rf node_modules package-lock.jsonnpm installnpm run build
Network Issues
"Failed to fetch weather data"
# Test API directly:curl "https://api.openweathermap.org/data/2.5/forecast?lat=40.7128&lon=-74.0060&appid=YOUR_KEY&units=metric"# Check DNS:nslookup api.openweathermap.org
π Performance
- Execution Time: 1-3 seconds average
- Memory Usage: ~50MB
- API Calls: 1 per Actor run
- Cost: <$0.01 per execution on Apify platform
π API Rate Limits
Free Tier (OpenWeatherMap)
- 60 calls/minute
- 1,000,000 calls/month
- 3-hour forecast intervals
Recommended Usage
- Cache results when possible
- Respect rate limits
- Consider upgrading for high-volume use
π€ Contributing
Contributions are welcome! Ideas for enhancement:
- Add more weather providers (Weather.com, AccuWeather)
- Support for weather alerts and warnings
- Historical weather data comparison
- Batch processing for multiple locations
- Weather-based recommendations
- Air quality index integration
- Multi-language support
π License
MIT License - feel free to use and modify!
π Apify $1M Challenge
This Actor was built for the Apify $1M Challenge - a global competition to build AI-powered data extraction and automation tools.
Categories
- βοΈ Travel
- π€ Automation
- π Integrations
π Support
- Documentation: docs.apify.com
- Discord: Apify Community
- OpenWeather: openweathermap.org/faq
- Issues: GitHub Issues
π Acknowledgments
- Built with Apify Platform
- Weather data from OpenWeatherMap
- Inspired by the developer community
Made with β€οΈ for the Apify $1M Challenge
Get started now: Deploy this Actor