{"openapi":"3.1.0","info":{"title":"TNP Data API","description":"Daily aggregate study metrics for TNP partners.\n\nAuthenticate with `Authorization: Bearer pk_live_...`.\nUse `List Studies` to discover the studies and metric columns available to the API key, then use `Get Study Metrics` to pull daily rows for a single study.","version":"0.2.0"},"paths":{"/v1/studies":{"get":{"tags":["Studies"],"summary":"List Studies","description":"Returns the studies the authenticated API key can access.\n\nUse this endpoint first to discover valid `study_id` values and the exact metric columns that will be returned by `Get Study Metrics`. Each study also exposes its configured reporting window when one is defined.","operationId":"list_studies_v1_studies_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StudiesResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"security":[{"HTTPBearer":[]}]}},"/v1/studies/{study_id}/metrics":{"get":{"tags":["Studies"],"summary":"Get Study Metrics","description":"Returns one daily aggregate row per date for a single study.\n\nThe response includes the caller's requested range, the range after applying study-window constraints, the range actually returned, and whether the returned rows fully cover the applied range.\n\nIf `date` is provided it takes precedence over `start_date` and `end_date`. If `start_date` is provided without `end_date`, `end_date` defaults to today. If no date filters are provided, the full history for the study is returned.","operationId":"get_study_metrics_v1_studies__study_id__metrics_get","security":[{"HTTPBearer":[]}],"parameters":[{"name":"study_id","in":"path","required":true,"schema":{"type":"string","title":"Study Id"}},{"name":"date","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Single-day query in YYYY-MM-DD format.","title":"Date"},"description":"Single-day query in YYYY-MM-DD format."},{"name":"start_date","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Inclusive range start in YYYY-MM-DD format.","title":"Start Date"},"description":"Inclusive range start in YYYY-MM-DD format."},{"name":"end_date","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Inclusive range end in YYYY-MM-DD format.","title":"End Date"},"description":"Inclusive range end in YYYY-MM-DD format."}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MetricsResponse"}}}},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}},"description":"Bad Request"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}},"description":"Unauthorized"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}},"description":"Forbidden"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}},"description":"Not Found"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}},"components":{"schemas":{"DateRangeResponse":{"properties":{"start":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Start"},"end":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"End"}},"additionalProperties":false,"type":"object","required":["start","end"],"title":"DateRangeResponse"},"ErrorResponse":{"properties":{"error":{"type":"string","title":"Error"},"message":{"type":"string","title":"Message"}},"additionalProperties":false,"type":"object","required":["error","message"],"title":"ErrorResponse"},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"MetricsResponse":{"properties":{"study_id":{"type":"string","title":"Study Id"},"requested_range":{"$ref":"#/components/schemas/DateRangeResponse"},"applied_range":{"$ref":"#/components/schemas/DateRangeResponse"},"available_range":{"$ref":"#/components/schemas/DateRangeResponse"},"study_window":{"$ref":"#/components/schemas/DateRangeResponse"},"is_complete_for_applied_range":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Is Complete For Applied Range"},"data":{"items":{"additionalProperties":true,"type":"object"},"type":"array","title":"Data"}},"additionalProperties":false,"type":"object","required":["study_id","requested_range","applied_range","available_range","study_window","is_complete_for_applied_range","data"],"title":"MetricsResponse"},"StudiesResponse":{"properties":{"studies":{"items":{"$ref":"#/components/schemas/StudySummary"},"type":"array","title":"Studies"}},"additionalProperties":false,"type":"object","required":["studies"],"title":"StudiesResponse"},"StudySummary":{"properties":{"study_id":{"type":"string","title":"Study Id"},"display_name":{"type":"string","title":"Display Name"},"metrics":{"items":{"type":"string"},"type":"array","title":"Metrics"},"study_window":{"$ref":"#/components/schemas/DateRangeResponse"}},"additionalProperties":false,"type":"object","required":["study_id","display_name","metrics","study_window"],"title":"StudySummary"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"},"input":{"title":"Input"},"ctx":{"type":"object","title":"Context"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}},"securitySchemes":{"HTTPBearer":{"type":"http","scheme":"bearer"}}},"tags":[{"name":"Studies","description":"Authenticated endpoints for discovering available studies and pulling daily aggregate metrics."}]}