services
PurpleAir
Examples

PurpleAir Examples

Practical examples for using PurpleAir tools.

MCP Protocol Tester

Protocol Flow

Example: Get Sensor Data

curl -X POST \
  -H "x-api-key: dev-key-12345" \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "tools/call",
    "params": {
      "name": "purpleair.get_sensor_data",
      "arguments": {
        "sensor_index": "12345",
        "data_format": "cleaned"
      }
    }
  }' \
  http://localhost:3001/api/v1/services/purpleair/mcp

Example: Get Sensor Info

curl -X POST \
  -H "x-api-key: dev-key-12345" \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 2,
    "method": "tools/call",
    "params": {
      "name": "purpleair.get_sensor_info",
      "arguments": {
        "sensor_index": "12345"
      }
    }
  }' \
  http://localhost:3001/api/v1/services/purpleair/mcp

Example: Get Sensors Near Location

curl -X POST \
  -H "x-api-key: dev-key-12345" \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 3,
    "method": "tools/call",
    "params": {
      "name": "purpleair.get_sensors_near",
      "arguments": {
        "latitude": 37.7749,
        "longitude": -122.4194,
        "radius_km": 5.0,
        "data_format": "cleaned"
      }
    }
  }' \
  http://localhost:3001/api/v1/services/purpleair/mcp

Example: Get Historical Data (from DB)

curl -X POST \
  -H "x-api-key: dev-key-12345" \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 4,
    "method": "tools/call",
    "params": {
      "name": "purpleair.get_historical_data",
      "arguments": {
        "sensor_index": "12345",
        "start_time": "2026-01-20T00:00:00Z",
        "end_time": "2026-01-24T23:59:59Z",
        "data_format": "cleaned",
        "limit": 100
      }
    }
  }' \
  http://localhost:3001/api/v1/services/purpleair/mcp

Note: Historical data is only returned when observations have been ingested into the database. The PurpleAir API does not provide historical endpoints.