{"openapi":"3.0.0","info":{"title":"alice.claims API","version":"0.2.0","description":"Public EMF sensor API backed by Home Assistant, edge-cached on Cloudflare, and designed for polling, graphing, and entropy experiments."},"servers":[{"url":"https://alice.claims"}],"components":{"schemas":{"Health":{"type":"object","properties":{"status":{"type":"string","enum":["ok"]},"version":{"type":"string"},"timestamp":{"type":"string"}},"required":["status","version","timestamp"]},"GhostEmfMeta":{"type":"object","properties":{"entityId":{"type":"string"},"publicName":{"type":"string"},"source":{"type":"string","enum":["home-assistant"]},"historyMode":{"type":"string","enum":["d1","home-assistant"]},"earliestKnownAt":{"type":"string"},"docsUrl":{"type":"string"},"openApiUrl":{"type":"string"},"polling":{"type":"object","properties":{"recommendedIntervalMs":{"type":"number"},"currentCacheTtlSeconds":{"type":"number"},"historyCacheTtlSeconds":{"type":"number"},"entropyCacheTtlSeconds":{"type":"number"}},"required":["recommendedIntervalMs","currentCacheTtlSeconds","historyCacheTtlSeconds","entropyCacheTtlSeconds"]}},"required":["entityId","publicName","source","historyMode","earliestKnownAt","docsUrl","openApiUrl","polling"]},"GhostEmfCurrent":{"type":"object","properties":{"entityId":{"type":"string"},"friendlyName":{"type":"string"},"state":{"type":"string"},"numericValue":{"type":"number"},"unit":{"type":"string","nullable":true},"lastChanged":{"type":"string"},"lastUpdated":{"type":"string"},"source":{"type":"string","enum":["home-assistant"]},"sampledAt":{"type":"string"},"stale":{"type":"boolean"},"staleSince":{"type":"string","nullable":true},"cache":{"type":"object","properties":{"maxAgeSeconds":{"type":"number"},"staleWhileRevalidateSeconds":{"type":"number"},"strategy":{"type":"string","enum":["cloudflare-cache-api"]}},"required":["maxAgeSeconds","staleWhileRevalidateSeconds","strategy"]}},"required":["entityId","friendlyName","state","numericValue","unit","lastChanged","lastUpdated","source","sampledAt","cache"]},"ApiError":{"type":"object","properties":{"error":{"type":"string"},"code":{"type":"string"},"details":{"nullable":true},"requestId":{"type":"string"}},"required":["error","code","requestId"]},"AllSensorReadings":{"type":"object","properties":{"emf":{"allOf":[{"$ref":"#/components/schemas/GhostEmfCurrent"},{"nullable":true}]},"ef":{"allOf":[{"$ref":"#/components/schemas/GhostEmfCurrent"},{"nullable":true}]},"rf":{"allOf":[{"$ref":"#/components/schemas/GhostEmfCurrent"},{"nullable":true}]},"sampledAt":{"type":"string"},"stale":{"type":"boolean"}},"required":["emf","ef","rf","sampledAt"]},"GhostEmfHistoryPoint":{"type":"object","properties":{"timestamp":{"type":"string"},"value":{"type":"number"}},"required":["timestamp","value"]},"GhostEmfHistory":{"type":"object","properties":{"entityId":{"type":"string"},"points":{"type":"array","items":{"$ref":"#/components/schemas/GhostEmfHistoryPoint"}},"start":{"type":"string"},"end":{"type":"string"},"rawPointCount":{"type":"number"},"displayPointCount":{"type":"number"},"targetPoints":{"type":"number"},"generatedAt":{"type":"string"}},"required":["entityId","points","start","end","rawPointCount","displayPointCount","targetPoints","generatedAt"]},"GhostEmfEntropy":{"type":"object","properties":{"entropyBits":{"type":"number"},"sampleCount":{"type":"number"},"windowMinutes":{"type":"number"},"bins":{"type":"number"},"min":{"type":"number"},"max":{"type":"number"},"mean":{"type":"number"},"updatedAt":{"type":"string"}},"required":["entropyBits","sampleCount","windowMinutes","bins","min","max","mean","updatedAt"]},"GhostEmfSnapshotRecord":{"type":"object","properties":{"entityId":{"type":"string"},"state":{"type":"string"},"numericValue":{"type":"number"},"unit":{"type":"string","nullable":true},"lastChanged":{"type":"string"},"lastUpdated":{"type":"string"},"sampledAt":{"type":"string"},"source":{"type":"string"}},"required":["entityId","state","numericValue","unit","lastChanged","lastUpdated","sampledAt","source"]},"GhostEmfSnapshot":{"type":"object","properties":{"entityId":{"type":"string"},"start":{"type":"string"},"end":{"type":"string"},"sampleCount":{"type":"number"},"generatedAt":{"type":"string"},"storage":{"type":"string","enum":["d1"]},"points":{"type":"array","items":{"$ref":"#/components/schemas/GhostEmfSnapshotRecord"}}},"required":["entityId","start","end","sampleCount","generatedAt","storage","points"]},"GhostEmfGoogleSheets":{"type":"object","properties":{"entityId":{"type":"string"},"start":{"type":"string"},"end":{"type":"string"},"csvUrl":{"type":"string"},"importDataFormula":{"type":"string"}},"required":["entityId","start","end","csvUrl","importDataFormula"]},"GhostEmfRandom":{"type":"object","properties":{"entityId":{"type":"string"},"start":{"type":"string"},"end":{"type":"string"},"sampleCount":{"type":"number"},"digits":{"type":"number"},"randomNumber":{"type":"string"},"randomUint32":{"type":"number"},"randomHex":{"type":"string"},"seedHash":{"type":"string"},"derivedAt":{"type":"string"}},"required":["entityId","start","end","sampleCount","digits","randomNumber","randomUint32","randomHex","seedHash","derivedAt"]},"TimelineAnnotation":{"type":"object","properties":{"id":{"type":"string"},"date":{"type":"string"},"title":{"type":"string"},"subtitle":{"type":"string"},"kind":{"type":"string","enum":["technical","narrative"]}},"required":["id","date","title","subtitle","kind"]},"StoryMilestone":{"type":"object","properties":{"id":{"type":"string"},"eraLabel":{"type":"string"},"title":{"type":"string"},"subtitle":{"type":"string"},"body":{"type":"string"}},"required":["id","eraLabel","title","subtitle","body"]},"TimelineEvent":{"type":"object","properties":{"id":{"type":"string"},"date":{"type":"string"},"title":{"type":"string"},"body":{"type":"string"},"category":{"type":"string"},"severity":{"type":"number"},"image":{"type":"string"},"imageAlt":{"type":"string"},"imageCaption":{"type":"string"}},"required":["id","date","title","body","category"]},"TimelineCategory":{"type":"object","properties":{"label":{"type":"string"},"color":{"type":"string"}},"required":["label","color"]},"GhostEmfTimeline":{"type":"object","properties":{"entityId":{"type":"string"},"earliestKnownAt":{"type":"string"},"latestKnownAt":{"type":"string"},"annotations":{"type":"array","items":{"$ref":"#/components/schemas/TimelineAnnotation"}},"milestones":{"type":"array","items":{"$ref":"#/components/schemas/StoryMilestone"}},"events":{"type":"array","items":{"$ref":"#/components/schemas/TimelineEvent"}},"categories":{"type":"object","additionalProperties":{"$ref":"#/components/schemas/TimelineCategory"}},"safetyNote":{"type":"string"}},"required":["entityId","earliestKnownAt","latestKnownAt","annotations","milestones","events","categories","safetyNote"]}},"parameters":{}},"paths":{"/health":{"get":{"summary":"Health check","tags":["System"],"responses":{"200":{"description":"Worker health","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Health"}}}}}}},"/api/v1/ghost-emf/meta":{"get":{"summary":"Public metadata for the exposed EMF sensor","tags":["Ghost EMF"],"responses":{"200":{"description":"Sensor metadata","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GhostEmfMeta"}}}}}}},"/api/v1/ghost-emf/current":{"get":{"summary":"Get the current normalized EMF reading","tags":["Ghost EMF"],"responses":{"200":{"description":"Current EMF reading","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GhostEmfCurrent"}}}},"503":{"description":"Sensor unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/api/v1/sensors":{"get":{"summary":"Get all GQ EMF-390 sensor readings (EMF, EF, RF)","tags":["Ghost EMF"],"responses":{"200":{"description":"All available sensor readings","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AllSensorReadings"}}}}}}},"/api/v1/ghost-emf/history":{"get":{"summary":"Get EMF history for a recent window or explicit date range","tags":["Ghost EMF"],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":1440,"default":60},"required":false,"name":"minutes","in":"query"},{"schema":{"type":"string"},"required":false,"name":"start","in":"query"},{"schema":{"type":"string"},"required":false,"name":"end","in":"query"},{"schema":{"type":"integer","minimum":32,"maximum":4000,"default":720},"required":false,"name":"targetPoints","in":"query"}],"responses":{"200":{"description":"Recent EMF points","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GhostEmfHistory"}}}}}}},"/api/v1/ghost-emf/entropy":{"get":{"summary":"Compute Shannon entropy over a recent window or explicit date range","tags":["Ghost EMF"],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":1440,"default":60},"required":false,"name":"minutes","in":"query"},{"schema":{"type":"string"},"required":false,"name":"start","in":"query"},{"schema":{"type":"string"},"required":false,"name":"end","in":"query"},{"schema":{"type":"integer","minimum":2,"maximum":128,"default":16},"required":false,"name":"bins","in":"query"},{"schema":{"type":"integer","minimum":32,"maximum":4000,"default":720},"required":false,"name":"targetPoints","in":"query"}],"responses":{"200":{"description":"Entropy summary","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GhostEmfEntropy"}}}}}}},"/api/v1/ghost-emf/snapshot":{"get":{"summary":"Get the raw D1 snapshot rows for a recent window or explicit date range","tags":["Ghost EMF"],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":1440,"default":60},"required":false,"name":"minutes","in":"query"},{"schema":{"type":"string"},"required":false,"name":"start","in":"query"},{"schema":{"type":"string"},"required":false,"name":"end","in":"query"}],"responses":{"200":{"description":"Raw serverless snapshot rows","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GhostEmfSnapshot"}}}}}}},"/api/v1/ghost-emf/export":{"get":{"summary":"Export raw D1 snapshots as CSV or an Excel-compatible workbook","tags":["Ghost EMF"],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":1440,"default":60},"required":false,"name":"minutes","in":"query"},{"schema":{"type":"string"},"required":false,"name":"start","in":"query"},{"schema":{"type":"string"},"required":false,"name":"end","in":"query"},{"schema":{"type":"string","enum":["csv","excel"],"default":"csv"},"required":false,"name":"format","in":"query"}],"responses":{"200":{"description":"Snapshot export file","content":{"text/csv":{"schema":{"type":"string"}},"application/vnd.ms-excel":{"schema":{"type":"string"}}}}}}},"/api/v1/ghost-emf/google-sheets":{"get":{"summary":"Get a Google Sheets IMPORTDATA formula for the selected snapshot range","tags":["Ghost EMF"],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":1440,"default":60},"required":false,"name":"minutes","in":"query"},{"schema":{"type":"string"},"required":false,"name":"start","in":"query"},{"schema":{"type":"string"},"required":false,"name":"end","in":"query"}],"responses":{"200":{"description":"Google Sheets formula","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GhostEmfGoogleSheets"}}}}}}},"/api/v1/ghost-emf/random":{"get":{"summary":"Derive a reproducible random number from the selected D1 snapshot range","tags":["Ghost EMF"],"parameters":[{"schema":{"type":"integer","minimum":1,"maximum":1440,"default":60},"required":false,"name":"minutes","in":"query"},{"schema":{"type":"string"},"required":false,"name":"start","in":"query"},{"schema":{"type":"string"},"required":false,"name":"end","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":18,"default":10},"required":false,"name":"digits","in":"query"}],"responses":{"200":{"description":"Random number derived from snapshot rows","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GhostEmfRandom"}}}}}}},"/api/v1/ghost-emf/timeline":{"get":{"summary":"Get timeline metadata, technical annotations, and story milestones","tags":["Ghost EMF"],"responses":{"200":{"description":"Timeline metadata","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GhostEmfTimeline"}}}}}}}}}