Guide

Build an environment-aware agent

Combine regional context and public alert data so an agent can reason about conditions without pretending to be an official authority.

1. Read context

Context helps the agent decide when environmental conditions should influence recommendations.

curl

curl https://smartapis.net/v1/agent/context/seattle

JavaScript

const response = await fetch('https://smartapis.net/v1/agent/context/seattle');
console.log(await response.json());

2. Query alerts

Use a client key with `environment:read` to pull reviewed alert references.

curl

curl -H "X-API-Key: $SMARTAPIS_API_KEY" \
  "https://smartapis.net/v1/environment/alerts?region_id=seattle-metro&q=air&limit=5"

Python

import os, urllib.parse, urllib.request

params = urllib.parse.urlencode({"region_id": "seattle-metro", "q": "air", "limit": 5})
request = urllib.request.Request(
    f"https://smartapis.net/v1/environment/alerts?{params}",
    headers={"X-API-Key": os.environ["SMARTAPIS_API_KEY"]},
)
with urllib.request.urlopen(request, timeout=30) as resp:
    print(resp.read().decode("utf-8"))