Documentation Index
Fetch the complete documentation index at: https://docs.amps.ai/llms.txt
Use this file to discover all available pages before exploring further.
GET /battery/{deviceId} returns the device’s current state, its capability declaration, and metadata identifying where the data came from. The retrieval path is identical across device types; only the state schema and command set change.
The response envelope
state is the live snapshot. commands and settings are computed from the device’s declared capabilities at read time and merged with live values. See capabilities for the full surface.
Three-tier retrieval
Reads pass through three tiers in order:| Tier | Source | When |
|---|---|---|
| Cache | Cache layer | TTL-valid entry exists. |
| Live | OEM API | Cache miss, or expedited request. |
| Fallback | Last-known stored state | Live call fails with a transient error. |
sync.available: true. Fallback reports sync.available: false so you know the data is not authoritative for the current request. The metadata.source field names the tier explicitly.
Cache modes: normal and expedited
Two cache TTLs exist:| Mode | TTL | When to use |
|---|---|---|
| Normal | 15 minutes | Default. Covers dashboard reads, periodic checks. |
| Expedited | 1 minute | Triggered by ?expedite=true. Forces near-fresh data. |
Transient versus permanent errors
OEM errors are classified:| Class | Codes | Behaviour |
|---|---|---|
| Transient | NETWORK_ERROR, RATE_LIMITED, SERVICE_UNAVAILABLE, TIMEOUT, UNKNOWN_ERROR | Fall back to last-known stored state. |
| Permanent | DEVICE_NOT_FOUND, DEVICE_OFFLINE | Return to caller. No fallback. |
metadata.source: 'fallback' plus sync.available: false make the difference visible.
If no data exists at any tier (empty cache, failing OEM call, no last-known record), the API returns 404 DEVICE_NOT_FOUND.
What is live versus cached
Thestate object is the live or cached device state. The commands and settings objects merge capability declarations with live values: a setting’s bounds come from its declared capabilities, its current value comes from the device. Capability declarations themselves take effect on the next read; there is no separate cache invalidation for capability data.
You see canonical names only; OEM-native identifiers never appear in the response.
Polling cadence and OEM rate limits
Per-OEM rate limits are honoured automatically. A burst of expedited reads against the same device coalesces; the platform enforces a minimum gap. Short cache TTLs paired with high read volumes will not inadvertently DDoS the OEM. For state changes that require sub-minute reaction, prefer webhooks over polling.push.completed and push.failed events deliver to your registered endpoint with retry and signature verification built in. Polling is the right default for dashboard-style displays, where the user accepts the visible cache freshness.
Per-OEM availability
Different OEMs expose different fields. A vehicle reportsbatteryLevel but no chargeRate. A heat pump reports temperature and mode, no SOC. The state schema is per-device-type:
| Device type | Key fields |
|---|---|
| Battery | status, capacity, level, chargeRate, dischargeLimit |
| EV charger | status, isConnected, isCharging, currentPower, maxCurrent |
| HVAC | temperature, active, heatSetpoint, coolSetpoint, mode |
| Solar inverter | power, systemState |
| Vehicle | batteryLevel, chargeState |
Listing devices
GET /{deviceType} returns a paginated list of devices your API key can access in the current environment. Each entry carries its last known state. Filter by userId to scope to one end-user; paginate via limit (1-50, default 10) and offset (default 0). The list view uses cached state; for fresh data on a single device, hit the device-id endpoint with ?expedite=true.
Sandbox versus live
Sandbox runs the same code paths, the same cache rules, and the same response shapes as live. Sandbox simulators return deterministic data with realistic timing. The only divergence is at the OEM-call layer; everything above (auth, access control, cache, response shape) is identical. See auth and environments for environment routing.Frequently asked questions
How fresh is the data returned by GET /battery/?
By default, up to 15 minutes old. The API serves device state from a cache with a 15-minute TTL. On cache hit, the response is served instantly. On miss, the platform calls the OEM live, normalises the response, and warms the cache. For sub-15-minute freshness, append?expedite=true and the cache TTL drops to 1 minute. The metadata.source field on the response names the tier (cache, live, or fallback).
What is the difference between live data and cached data?
Live data is fetched from the OEM API on the request thread; cached data is served from a previous fetch. Both indicatesync.available: true because the data is authoritative. Fallback data, served from the last-known stored state when a live call fails with a transient error, indicates sync.available: false because it is not a fresh fetch. The caller can distinguish all three via metadata.source.
How do I detect when a device is offline?
The platform classifies OEM errors as transient or permanent.DEVICE_OFFLINE is permanent and returns to the caller without falling back to stale data; the response has the standard error envelope and a 4xx-class status. Transient errors (NETWORK_ERROR, RATE_LIMITED, SERVICE_UNAVAILABLE, TIMEOUT) fall back to last-known and set sync.available: false.
Why does a fresh push not invalidate the cache?
Cache invalidation is purely TTL-based. Push completions and state changes do not invalidate the cache. Webhooks deliver state-change notifications without depending on cache freshness; reads see the world via the cache window. After a push completes, do not poll the device immediately expecting fresh state. Subscribe topush.completed instead, or call with ?expedite=true when freshness matters more than the OEM rate limit.
Why does GET /battery (the list endpoint) not show fresh data?
Listing devices returns up to 50 entries paginated; calling the OEM API for each on every list request would multiply per-OEM load by the number of devices. The list view uses cached state. For fresh data on a single device, fetch the device-id endpoint with?expedite=true. The list is shaped for dashboards and inventories; the per-device read is shaped for control loops.
Related concepts
Capabilities
The
commands and settings objects on the response.Webhooks
State-change notifications without polling.
Auth and Environments
Sandbox versus live, environment routing.
Error Envelope
DEVICE_NOT_FOUND, transient versus permanent.