DEV Community

Cover image for Building Health-Conscious Apps With Air Quality Data
APIVerve
APIVerve

Posted on • Originally published at blog.apiverve.com

Building Health-Conscious Apps With Air Quality Data

Every summer, wildfire smoke turns the sky orange across North America. Every winter, temperature inversions trap pollution in valleys. Every day, urban commuters breathe air that varies dramatically in quality from block to block.

Air quality has gone from niche environmental data to mainstream health information. People check air quality before running outdoors. Schools check it before holding recess. Cities issue alerts that change behavior for millions of residents.

If your app involves outdoor activities, health tracking, or location-based recommendations, air quality data adds genuine value to your users' lives. Here's how to integrate it meaningfully.

Understanding AQI

The Air Quality Index (AQI) takes complex pollution measurements and condenses them into a single number that humans can understand and act on.

AQI Level What It Means
0-50 Good Air quality is satisfactory. Normal activities.
51-100 Moderate Acceptable, but sensitive groups may have mild symptoms.
101-150 Unhealthy for Sensitive Groups Children, elderly, people with respiratory conditions should limit outdoor exertion.
151-200 Unhealthy Everyone may begin to experience effects. Limit prolonged outdoor exertion.
201-300 Very Unhealthy Health alert. Everyone should reduce outdoor activity.
301+ Hazardous Emergency conditions. Stay indoors with windows closed.

This scale is intuitive: green is good, red is bad, purple is emergency. The categories translate directly to advice: "Good" means do what you want; "Unhealthy" means reconsider outdoor plans.

Different countries use slightly different scales. The US EPA AQI is the most common globally, but the UK, EU, China, and India have their own systems. Make sure you know which scale your data uses and communicate it clearly to users.

What's Being Measured

AQI is calculated from multiple pollutants. The one with the highest individual AQI becomes the overall AQI. Understanding the pollutants helps you provide better guidance:

PM2.5 (Fine Particulate Matter) — Particles smaller than 2.5 micrometers. The biggest health concern for most people. Penetrates deep into lungs, enters bloodstream. Main component of wildfire smoke and vehicle exhaust.

PM10 (Coarse Particulate Matter) — Larger particles (2.5-10 micrometers). Dust, pollen, mold spores. Less dangerous than PM2.5 but still impacts respiratory health.

Ozone (O3) — Ground-level ozone forms when sunlight hits vehicle and industrial emissions. Peaks on hot, sunny afternoons in urban areas. Major asthma trigger.

Nitrogen Dioxide (NO2) — From vehicle exhaust and power plants. Aggravates respiratory conditions. Typically highest near busy roads.

Sulfur Dioxide (SO2) — From industrial processes and power plants. Causes acid rain. Less common in most urban areas than it used to be.

Carbon Monoxide (CO) — From incomplete combustion. Usually only elevated near heavy traffic or enclosed spaces with combustion.

When providing health guidance, consider which pollutant is elevated. High ozone calls for avoiding afternoon exertion. High PM2.5 from smoke suggests staying indoors regardless of time of day.

Where Air Quality Data Adds Value

Fitness and running apps. Outdoor exercise amplifies exposure — you breathe more deeply, taking in more pollutants. Serious runners already check air quality; casual users would benefit from the prompt.

An app that says "AQI is 142 today — consider an indoor workout or shorter outdoor session" provides genuine health value. Bonus points for suggesting alternatives: "The air is cleaner at 6 AM tomorrow."

Allergy and asthma tracking apps. Air quality is a major trigger for respiratory symptoms. Combining pollen counts with air quality gives a complete picture. Users can correlate their symptoms with environmental conditions.

Health apps with outdoor activity tracking. If you're tracking workouts or steps, you're already measuring outdoor activity. Adding air quality context lets users understand their exposure over time.

Travel and tourism apps. Air quality varies enormously by location. Beijing's notorious pollution, LA's smog days, and the smoke-filled summers in mountain west towns are all worth warning travelers about.

Real estate and location apps. Air quality varies within cities — blocks near highways differ from blocks near parks. For people choosing where to live, historical air quality data matters.

Smart home and HVAC integration. When outdoor air quality is bad, it's time to close windows and run air purifiers. Smart home systems can automate this based on real-time data.

Integrating Air Quality Data

Getting air quality for a location is straightforward:

async function getAirQuality(city) {
  const response = await fetch(
    `https://api.apiverve.com/v1/airquality?city=${encodeURIComponent(city)}`,
    { headers: { 'x-api-key': API_KEY } }
  );
  const { data } = await response.json();

  return {
    pm25: data.pm2_5,
    pm10: data.pm10,
    epaIndex: data.usEpaIndex,
    advice: data.recommendation
  };
}
Enter fullscreen mode Exit fullscreen mode

The interesting work is in how you present and act on this data.

Making Data Actionable

A number alone — "AQI: 127" — isn't helpful to most users. They don't know if that's good or bad or what to do about it.

Translate numbers to meaning. "AQI 127" becomes "Moderate - OK for most people, sensitive groups should limit outdoor time."

Use color coding. The AQI color scale (green/yellow/orange/red/purple/maroon) is widely recognized. Visual indication is faster than reading text.

Provide specific advice. Don't just say "unhealthy." Say "Consider running indoors today" or "Good day for outdoor activities."

Add relative context. "Worse than yesterday" or "Better than the weekly average" helps users calibrate. Is 75 typical for this area or unusual?

Be prescriptive, not just descriptive. Users want to know what to do, not just what the situation is. "Should I run outside?" is the question they're really asking.

Sensitivity and Personalization

A healthy adult and a person with COPD experience the same air quality very differently. AQI 100 might be fine for one and miserable for the other.

If your app has user profiles, consider sensitivity settings:

  • Normal: Default thresholds
  • Sensitive: Lower thresholds for children, elderly, or those with mild respiratory issues
  • Respiratory condition: Significantly lower thresholds for asthma, COPD, etc.

Personalized thresholds change everything:

AQI Normal user Sensitive user Respiratory condition
50 All clear All clear All clear
75 All clear Consider limiting exertion Caution advised
100 Moderate Limit prolonged outdoor activity Stay indoors if possible
125 Limit prolonged outdoor activity Avoid outdoor exertion Stay indoors

Users with conditions will appreciate an app that understands their specific needs rather than giving generic advice.

Combining Air Quality With Weather

Air quality doesn't exist in isolation. Temperature, humidity, and weather patterns all affect both air quality and outdoor activity decisions.

Hot weather + poor air quality = especially dangerous. Heat increases ozone formation and stresses the body. Running in heat on a high-ozone day is worse than either factor alone.

Rain often improves air quality — it scrubs particles from the air. After a rain, air quality may be significantly better even if the morning was bad.

Wind patterns determine whether pollution disperses or accumulates. Knowing "air quality will improve this afternoon as winds shift" is valuable.

Consider combining data sources:

async function getOutdoorActivityAdvice(city) {
  const [aq, weather] = await Promise.all([
    getAirQuality(city),
    getWeather(city)
  ]);

  const concerns = [];

  // EPA index 1-2 is good, 3+ warrants caution
  if (aq.epaIndex > 2) {
    concerns.push(`Air quality concern: ${aq.advice}`);
  }

  if (weather.temp > 95) {
    concerns.push('High heat risk');
  }

  if (weather.uvIndex > 8) {
    concerns.push('Very high UV exposure');
  }

  if (concerns.length === 0) {
    return { recommendation: 'Great conditions for outdoor activity!', concerns: [] };
  }

  return {
    recommendation: 'Consider indoor alternatives or take precautions',
    concerns: concerns
  };
}
Enter fullscreen mode Exit fullscreen mode

Forecasting and Trends

Current conditions are useful. Forecasts are even better — they let users plan ahead.

"AQI will be 150 tomorrow afternoon" lets someone schedule their run for the morning. "Air quality will be poor all week due to wildfire smoke" lets someone plan indoor alternatives or consider traveling to cleaner air.

Trend information helps too:

  • "Improving — should be good by noon"
  • "Worsening — consider outdoor activities this morning"
  • "Stable — no significant change expected"

Where forecast data is available, surface it. Users can't control air quality, but they can plan around it.

Alerts and Notifications

For apps where air quality is critical (health tracking, smart home), consider proactive alerts:

Threshold alerts: "AQI has exceeded 150 in your area." Users might not be checking; push notifications ensure they know.

Improvement alerts: "Air quality has improved — now at Good level." Let people know when it's safe to resume outdoor activities.

Forecast alerts: "Tomorrow's air quality expected to be Unhealthy. Consider adjusting plans."

Be careful with notification frequency. Air quality changes throughout the day; you don't want to send 10 notifications. Consider:

  • Alert when crossing category boundaries (Good → Moderate → Unhealthy)
  • No more than one alert per day unless conditions change dramatically
  • User control over alert thresholds

The Geographic Dimension

Air quality varies significantly by location — not just between cities, but within them.

Locations near highways have worse air quality than parks a mile away. Downtown often differs from suburbs. Valleys trap pollution differently than hilltops.

If your app has location granularity, use it. Don't just show "New York City AQI." Show the AQI for the user's actual neighborhood, or even their current GPS location.

Historical air quality data by location can reveal patterns:

  • Which neighborhoods consistently have better air
  • Seasonal patterns (summer ozone, winter inversions)
  • Time-of-day patterns (morning rush hour pollution)

For real estate or relocation apps, long-term air quality averages matter more than today's reading.

Privacy Considerations

Air quality data requires location. Be thoughtful about privacy:

  • Request location only when needed for air quality features
  • Offer city-level or ZIP code precision as an option (less accurate but more private)
  • Be clear about what location data you're collecting and why
  • Don't store location history unnecessarily

Users may be willing to share location for air quality alerts but uncomfortable with location tracking. Let them choose.

Accuracy and Limitations

Air quality data has limitations users should understand:

Sensor coverage varies. Urban areas have good coverage; rural areas may rely on distant sensors or satellite estimates.

Readings are snapshots. Air quality changes throughout the day. A 9 AM reading doesn't fully represent noon conditions.

Hyperlocal variation. The nearest sensor might be miles away. Conditions at the user's exact location could be different.

Indoor vs outdoor. AQI measures outdoor air. Indoor air quality depends on building ventilation, filtration, and activities inside.

Be honest about these limitations. "Air quality at nearest sensor (2.3 miles away)" is more transparent than implying you know conditions at their front door.

The Bigger Picture

Air quality awareness is growing. Wildfires are increasing. Urban populations are rising. Climate change is affecting atmospheric patterns. These trends suggest air quality data will become more valuable, not less.

Apps that meaningfully integrate air quality data help users:

  • Make healthier decisions about outdoor activities
  • Understand their environmental exposure
  • Take protective action when needed

This isn't just a feature — it's a contribution to public health.


Get real-time air quality with the Air Quality API. Combine with weather data from the Weather API for complete environmental context. Help your users breathe easier.


Originally published at APIVerve Blog

Top comments (0)