Purple Air API

Free to Use Varies (check documentation)

Overview

Purple Air gives you access to real-time air quality data from a global network of community-owned sensors. You can query sensor readings, location data, and historical air quality metrics without any authentication. It is a great starting point for environmental monitoring projects or building local air quality dashboards.

💡

Beginner Tip

PurpleAir sensors report PM2.5 particulate matter — query by sensor ID or bounding box to get readings for a specific area. Note that the newer API v1 (api.purpleair.com) now requires an API key, so check which version you are targeting.

Available Data

Purple Air data via REST API
JSON-formatted response data
Freely accessible without authentication

Example Response

JSON Response
{
  "status": "success",
  "data": {
    "result": "Data from Purple Air",
    "description": "Real Time Air Quality Monitoring",
    "timestamp": "2025-01-15T10:00:00Z"
  }
}

Field Reference

sensor_index Unique identifier for each PurpleAir sensor.
name Human-readable label given to the sensor by its owner.
pm2.5_atm PM2.5 particulate matter reading in micrograms per cubic meter, corrected for atmospheric pressure.
latitude Latitude coordinate of the sensor location.
longitude Longitude coordinate of the sensor location.
last_seen Unix timestamp of the most recent data upload from this sensor.

Implementation Example

const url = "https://www2.purpleair.com/";
const response = await fetch(url);
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
const data = await response.json();
console.log(data);

What Can You Build?

Note: These code examples are AI-generated and unverified. Always refer to the official API documentation for accurate usage.

Common Errors & Troubleshooting

403 Forbidden The newer PurpleAir API v1 requires an API key passed as the X-API-Key header.
Register at develop.purpleair.com to obtain a free API key and include it in every request header.
Empty or null sensor readings Some sensors go offline or report null values when they malfunction or lose connectivity.
Filter out entries where pm2.5_atm is null before processing; add a freshness check using the last_seen timestamp.
Rate limit exceeded Polling too frequently against the API exceeds the allowed request rate.
Cache sensor data locally and poll no more than once per minute per sensor to stay within rate limits.

Matrix Score Breakdown

🌐 Reachability 30/30
⚡ Speed 15/20
🔒 Security 15/15
🛠 Developer XP 15/20
✓ Reliability 7/15
Response Time 231ms

Fully tested on Apr 5, 2026

Technical Specifications

Auth No Auth
HTTPS REQUIRED
CORS UNKNOWN
Category Science & Math
Difficulty Beginner
Verified: 2026-04-04

Similar APIs

View All →