Hyper Local Aqi Actor
Pricing
Pay per usage
Hyper Local Aqi Actor
Aggregates hyper-local air quality data from OpenAQ for AI agents. Provides AQI calculations with confidence scoring and outlier removal.
Pricing
Pay per usage
Rating
0.0
(0)
Developer
Pranav Bagal
Maintained by CommunityActor stats
2
Bookmarked
2
Total users
0
Monthly active users
5 months ago
Last modified
Share
π Global Hyper-Local AQI Actor
Real-time, hyper-accurate air quality intelligence for AI agents and applications
Get scientifically-validated Air Quality Index data from anywhere on Earth. This actor aggregates readings from multiple ground-level PM2.5 sensors, applies advanced statistical cleaning (IQR outlier removal), and delivers reliable AQI calculations with confidence scoringβpurpose-built for AI agents, health apps, and intelligent automation systems.
π― Built for the Apify $1M Challenge β solving real-world air quality monitoring challenges at scale.
π₯ Why This Actor Exists
The Problem
Air quality affects 91% of the world's population living in areas exceeding WHO guidelines. However:
- β Single-sensor readings are unreliable (sensor malfunctions, local interference)
- β City-wide averages miss hyperlocal variations (pollution can vary 10x within kilometers)
- β No standardized confidence metrics for AI decision-making
- β Existing APIs lack real-time aggregation and statistical validation
The Solution
This actor provides statistically-validated, hyperlocal AQI by:
β
Aggregating multiple sensors within your specified radius
β
Cleaning outliers using IQR (Interquartile Range) statistical method
β
Calculating confidence scores (0-100%) based on data quality
β
Delivering actionable insights optimized for AI agent consumption
Perfect for: AI chatbots answering health queries, smart home automation, fitness apps, location-based services, environmental monitoring, and public health systems.
β¨ Key Features
π― Hyper-Local Precision
Unlike city-wide averages, get AQI for specific neighborhoods, parks, or addresses by aggregating sensors within 1-25km radius.
π Statistical Rigor
- Removes sensor malfunctions and outliers using proven IQR method
- Calculates mean, median, and standard deviation
- Filters stale data (only readings <48 hours old)
π€ AI-Agent Ready
Structured JSON output designed for LLM function calling and programmatic decision-making with built-in confidence scores.
π Global Coverage
Works anywhere with OpenAQ sensor network coverage (200+ countries, 10,000+ locations).
β‘ Fast & Reliable
- Concurrent sensor querying (10 parallel requests)
- Automatic retries on failures
- Typical execution: 5-30 seconds
π What You Get
{"result": {"aqi": 42, // EPA-standard Air Quality Index (0-500)"category": "Good", // Good, Moderate, Unhealthy, etc."pm25_concentration": 10.5, // PM2.5 in Β΅g/mΒ³"confidence_score": 87 // 0-100% reliability metric},"health_context": {"advice": "Air quality is satisfactory.","is_safe_for_jogging": true // Boolean for quick AI decisions},"metadata": {"sensors_found": 45, // Total sensors discovered"sensors_used": 38, // Valid readings after cleaning"outliers_removed": 7 // Statistical outliers filtered}}
Full output schema available in .actor/output_schema.json
π Quick Start
1οΈβ£ Get Your Free OpenAQ API Key
Visit OpenAQ Registration and create a free account to get your API key.
2οΈβ£ Run the Actor
Example: Check air quality in London
{"locationName": "London","radiusKm": 10,"maxSensors": 50,"openaqApiKey": "your_api_key_here"}
Example: Use precise coordinates (Tokyo)
{"latitude": 35.6762,"longitude": 139.6503,"radiusKm": 15,"maxSensors": 50,"openaqApiKey": "your_api_key_here"}
3οΈβ£ Get Results in Seconds
AQI calculation with confidence score, health advice, and metadataβready for your application or AI agent.
π‘ Real-World Use Cases
π€ AI Chatbots & Virtual Assistants
User: "Is it safe to run outside in Delhi right now?"Agent: [Queries actor]β "Delhi AQI is 156 (Unhealthy). Running outdoorsnot recommended. Confidence: 92%"
π Fitness & Health Apps
- Real-time workout safety recommendations
- Location-based exercise route planning
- Personalized outdoor activity alerts
- Asthma/allergy trigger warnings
π Smart Home Automation
- Auto-control air purifiers based on outdoor AQI
- Intelligent window opening/closing systems
- HVAC optimization based on external air quality
- Home ventilation scheduling
π± Location Services & Travel
- Map overlays showing neighborhood-level AQI
- Destination air quality assessments for travelers
- Real estate insights (property + air quality data)
- Event planning (outdoor venues, timing)
π¬ Research & Analytics
- Urban planning and environmental studies
- Public health research and policy-making
- Climate change impact tracking
- Hyperlocal pollution pattern analysis
π₯ Input Configuration
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| locationName | String | No* | β | City or place name (e.g., "Paris", "Mumbai") |
| latitude | Number | No* | β | Latitude coordinate (e.g., 40.7128) |
| longitude | Number | No* | β | Longitude coordinate (e.g., -74.0060) |
| radiusKm | Integer | No | 10 | Search radius in kilometers (1-25) |
| maxSensors | Integer | No | 50 | Max sensors to process (1-500) |
| openaqApiKey | String | Yes | β | Your OpenAQ API key (get one free) |
*Either locationName OR both latitude+longitude must be provided.
π€ Output Explained
AQI Categories (EPA Standard)
| AQI | Category | Health Impact | Use Case |
|---|---|---|---|
| 0-50 | π’ Good | Air quality satisfactory | Safe for all outdoor activities |
| 51-100 | π‘ Moderate | Acceptable for most people | Unusually sensitive people should limit prolonged outdoor exertion |
| 101-150 | π Unhealthy for Sensitive Groups | Sensitive groups may experience health effects | Children, elderly, people with respiratory conditions should reduce outdoor activities |
| 151-200 | π΄ Unhealthy | Everyone may experience health effects | Everyone should reduce prolonged outdoor exertion |
| 201-300 | π£ Very Unhealthy | Health alert: serious effects for everyone | Everyone should avoid outdoor activities |
| 301-500 | π€ Hazardous | Emergency health conditions | Everyone should remain indoors |
Confidence Score Breakdown
The actor calculates confidence based on three factors:
Quantity (40%) β Number of sensors with valid readings
- More sensors = higher confidence
- Minimum 4 sensors recommended
Consensus (40%) β Agreement between sensors (low standard deviation)
- Tight clustering = higher confidence
- High variation suggests localized pollution sources
Quality (20%) β Data retention after outlier removal
- Higher retention rate = better quality
- Low retention suggests sensor issues or extreme variability
π¬ How It Works
Architecture
Input Location β Geocoding β Sensor Discovery β Data Collection β Statistical Cleaning β AQI Calculation β Output
Step-by-Step Process
1. Location Resolution
- City name β OpenStreetMap Nominatim geocoding
- Or use provided latitude/longitude directly
2. Sensor Discovery
- Query OpenAQ API for all PM2.5 sensors within radius
- Filter for sensors with readings <48 hours old
- Limit to
maxSensorsfor performance optimization
3. Concurrent Data Collection
- Fetch latest readings from each sensor (10 parallel requests)
- Built-in retry logic for reliability
- 5-second timeout per sensor
4. Statistical Data Cleaning
Raw values β Filter invalid β Calculate IQR β Remove outliers β Statistics
- Remove null, negative, or >2000 Β΅g/mΒ³ values
- Apply Interquartile Range (IQR) method for outlier detection
- Calculate mean, median, standard deviation
5. AQI Calculation
- Apply EPA AQI breakpoints to cleaned PM2.5 mean
- Map to category (Good β Hazardous)
- Generate health advice
6. Confidence Scoring
confidence = quantity_score(40%) + consensus_score(40%) + quality_score(20%)
π Technical Details
Built With
- Apify SDK 3.2+ β Serverless actor framework
- Crawlee 3.15+ β Concurrent web scraping with retries
- TypeScript β Type-safe development
- OpenAQ API v3 β Global air quality data network
- OpenStreetMap Nominatim β Geocoding service
Data Sources
- PM2.5 Sensors: Ground-level particulate matter monitors
- OpenAQ Network: 10,000+ locations across 200+ countries
- Community-powered: Government agencies, research institutions, citizen scientists
Performance Metrics
- Concurrency: 10 simultaneous requests
- Retry Logic: 2 automatic retries on failures
π° Pricing & Costs
Cost Optimization
- Pre-Filtering: We check sensor "Last Updated" timestamps before fetching detailed data, saving API calls.
- Concurrency Control: Requests are batched to prevent memory spikes.
- Configurable Limits: Use maxSensors to hard-cap execution time.
External API Costs
- OpenAQ API: Free tier available (check current limits)
- Nominatim Geocoding: Free (rate-limited to 1 req/sec)
Cost Optimization Tips:
- Use coordinates instead of city names (saves geocoding call)
- Reduce
maxSensorsfor faster/cheaper execution - Smaller radius when high sensor density exists
π Example Scenarios
Scenario 1: AI Health Assistant
Question: "Can my child with asthma play outside?"
Actor Input:
{"locationName": "San Francisco","radiusKm": 5,"maxSensors": 30,"openaqApiKey": "..."}
Response: AQI 68 (Moderate, 88% confidence) AI Output: "Air quality is acceptable, but sensitive children should limit prolonged outdoor play. Consider indoor activities instead."
Scenario 2: Smart Home Automation
Trigger: Every 30 minutes
Actor Input:
{"latitude": 51.5074,"longitude": -0.1278,"radiusKm": 3,"maxSensors": 20,"openaqApiKey": "..."}
Automation Logic:
if (aqi > 100) {closeWindows();turnOnAirPurifier();sendNotification("Poor air quality detected");}
Scenario 3: Fitness App Route Planning
Use Case: Recommend safest jogging routes
Actor Input: Check multiple neighborhoods
[{"locationName": "Central Park", ...},{"locationName": "Brooklyn Bridge Park", ...},{"locationName": "Prospect Park", ...}]
Output: Rank locations by AQI + confidence score
π οΈ Development & Testing
Local Setup
# Clone repositorygit clone https://github.com/cryptomafiaPB/hyper-local-aqi-actor.gitcd hyper-local-aqi-actor# Install dependenciesnpm install# Build TypeScriptnpm run build# Setup inputmkdir -p storage/key_value_stores/defaultcp INPUT.json storage/key_value_stores/default/# Run locallynpm start
Using Apify CLI
# Install Apify CLI globallynpm install -g apify-cli# Run actor locallyapify run# Deploy to Apify platformapify push
Testing Different Locations
Edit INPUT.json with various test cases:
- Major cities (London, Tokyo, Delhi, New York)
- Rural areas (to test low sensor availability)
- High-pollution areas (to test outlier removal)
- Coastal vs inland (to compare patterns)
β FAQ & Troubleshooting
"No active PM2.5 sensors found in this area"
Causes:
- Remote/rural location with no nearby sensors
- All sensors in area are offline or stale (>48 hours)
Solutions:
- Increase
radiusKmto 20-25km - Check sensor coverage on OpenAQ Map
- Try a nearby major city
"Could not resolve location name"
Causes:
- Misspelled city name
- Ambiguous location (e.g., "Cambridge" without country)
Solutions:
- Add country suffix: "Cambridge, UK" or "Cambridge, USA"
- Use more specific names: "Central London" instead of "London"
- Switch to latitude/longitude for precision
Low Confidence Score (<50%)
Causes:
- Few sensors in area (<10)
- High sensor disagreement (local pollution sources)
- Many outliers removed (sensor malfunctions)
Solutions:
- Increase
radiusKmto include more sensors - Run multiple times and compare trends
- Check if specific sensors are consistently outliers
API Key Errors
Causes:
- Invalid or expired OpenAQ API key
- Rate limit exceeded on free tier
- Incorrect key format
Solutions:
- Generate new key at OpenAQ
- Check API usage dashboard for rate limits
- Ensure no extra spaces/characters in key
What Makes This Actor Special
Solves Real Problems: Addresses critical need for reliable, hyperlocal air quality data in health, automation, and AI applications
Built for AI Agents: Structured output with confidence scores optimized for LLM function calling and decision-making
Scientifically Sound: Uses proven statistical methods (IQR outlier removal, EPA AQI standards)
Global Scale: Works across 200+ countries with OpenAQ network
Production Ready: Comprehensive error handling, retries, timeouts, and validation
Well Documented: Complete README, input/output schemas, examples, and troubleshooting
π Additional Resources
- π OpenAQ Platform β Explore global sensor network
- π EPA AQI Guide β Official AQI documentation
- π WHO Air Quality Guidelines β Health impact research
- π¬ IQR Outlier Detection β Statistical methodology
π€ Support & Feedback
Need Help?
- π§ Open an issue
- π Apify Documentation
Feature Requests? Submit ideas via GitHub issues or reach out directly!
π License
Apache License 2.0
π― Ready to Get Started?
- Get your free OpenAQ API key
- Run this actor with your location
- Integrate the results into your app, AI agent, or automation system
Let's make air quality data accessible to everyone. ππ