{"openapi":"3.1.0","info":{"title":"FastAPI","version":"0.1.0"},"paths":{"/auth/register":{"post":{"tags":["auth"],"summary":"Register","operationId":"register_auth_register_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RegisterRequest"}}},"required":true},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Token"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/auth/login":{"post":{"tags":["auth"],"summary":"Login","operationId":"login_auth_login_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LoginRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Token"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/auth/me":{"get":{"tags":["auth"],"summary":"Read Me","operationId":"read_me_auth_me_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/User"}}}}},"security":[{"HTTPBearer":[]}]},"delete":{"tags":["auth"],"summary":"Delete Me","operationId":"delete_me_auth_me_delete","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccountDelete"}}},"required":true},"responses":{"204":{"description":"Successful Response"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"HTTPBearer":[]}]},"patch":{"tags":["auth"],"summary":"Update Me","operationId":"update_me_auth_me_patch","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProfileUpdate"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/User"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"HTTPBearer":[]}]}},"/auth/change-password":{"post":{"tags":["auth"],"summary":"Change Password","operationId":"change_password_auth_change_password_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PasswordChange"}}},"required":true},"responses":{"204":{"description":"Successful Response"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"HTTPBearer":[]}]}},"/pairing/codes":{"post":{"tags":["pairing"],"summary":"Create Code","operationId":"create_code_pairing_codes_post","responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PairingCode"}}}}},"security":[{"HTTPBearer":[]}]}},"/pairing/codes/{code}":{"get":{"tags":["pairing"],"summary":"Read Code","description":"Has the device used this code yet? Polled by the dashboard's pairing page.","operationId":"read_code_pairing_codes__code__get","security":[{"HTTPBearer":[]}],"parameters":[{"name":"code","in":"path","required":true,"schema":{"type":"string","title":"Code"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PairingStatus"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/pairing/redeem":{"post":{"tags":["pairing"],"summary":"Redeem Code","description":"Called by the device: swap a pairing code for this device's API key.\n\nNo bin is assigned here. The device has a key straight away, but its\nreadings are only accepted once the user sets it up in the dashboard.","operationId":"redeem_code_pairing_redeem_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RedeemRequest"}}},"required":true},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RedeemResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/devices":{"get":{"tags":["devices"],"summary":"List Devices","operationId":"list_devices_devices_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"items":{"$ref":"#/components/schemas/Device"},"type":"array","title":"Response List Devices Devices Get"}}}}},"security":[{"HTTPBearer":[]}]}},"/devices/{device_id}":{"get":{"tags":["devices"],"summary":"Read Device","operationId":"read_device_devices__device_id__get","security":[{"HTTPBearer":[]}],"parameters":[{"name":"device_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Device Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Device"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"delete":{"tags":["devices"],"summary":"Unpair Device","description":"Unpair: the key stops working at once and the device can be paired again.","operationId":"unpair_device_devices__device_id__delete","security":[{"HTTPBearer":[]}],"parameters":[{"name":"device_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Device Id"}}],"responses":{"204":{"description":"Successful Response"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"patch":{"tags":["devices"],"summary":"Update Device","description":"Device settings: rename it and/or move it to another of the user's bins.","operationId":"update_device_devices__device_id__patch","security":[{"HTTPBearer":[]}],"parameters":[{"name":"device_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Device Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeviceChange"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Device"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/devices/{device_id}/setup":{"post":{"tags":["devices"],"summary":"Set Up Device","description":"Confirm the registration: name the device and put it in one of the user's bins.","operationId":"set_up_device_devices__device_id__setup_post","security":[{"HTTPBearer":[]}],"parameters":[{"name":"device_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Device Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeviceSetup"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Device"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/devices/{device_id}/records":{"get":{"tags":["devices"],"summary":"Get Device Records","operationId":"get_device_records_devices__device_id__records_get","security":[{"HTTPBearer":[]}],"parameters":[{"name":"device_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Device Id"}},{"name":"hours","in":"query","required":false,"schema":{"type":"integer","maximum":168,"minimum":1,"default":24,"title":"Hours"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Reading"},"title":"Response Get Device Records Devices  Device Id  Records Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/bins":{"get":{"tags":["bins"],"summary":"List Bins","operationId":"list_bins_bins_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"items":{"$ref":"#/components/schemas/Bin"},"type":"array","title":"Response List Bins Bins Get"}}}}},"security":[{"HTTPBearer":[]}]},"post":{"tags":["bins"],"summary":"Create Bin","operationId":"create_bin_bins_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BinCreate"}}},"required":true},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Bin"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"HTTPBearer":[]}]}},"/bins/{bin_id}":{"get":{"tags":["bins"],"summary":"Get Specific Bin","operationId":"get_specific_bin_bins__bin_id__get","security":[{"HTTPBearer":[]}],"parameters":[{"name":"bin_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Bin Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Bin"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"patch":{"tags":["bins"],"summary":"Change Bin","operationId":"change_bin_bins__bin_id__patch","security":[{"HTTPBearer":[]}],"parameters":[{"name":"bin_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Bin Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BinChange"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Bin"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"delete":{"tags":["bins"],"summary":"Delete Bin","operationId":"delete_bin_bins__bin_id__delete","security":[{"HTTPBearer":[]}],"parameters":[{"name":"bin_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Bin Id"}}],"responses":{"204":{"description":"Successful Response"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/bins/{bin_id}/records":{"get":{"tags":["bins"],"summary":"Get Bin Records","operationId":"get_bin_records_bins__bin_id__records_get","security":[{"HTTPBearer":[]}],"parameters":[{"name":"bin_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Bin Id"}},{"name":"hours","in":"query","required":false,"schema":{"type":"integer","maximum":168,"minimum":1,"default":24,"title":"Hours"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Reading"},"title":"Response Get Bin Records Bins  Bin Id  Records Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/bins/{bin_id}/history":{"get":{"tags":["bins"],"summary":"Get Bin History","operationId":"get_bin_history_bins__bin_id__history_get","security":[{"HTTPBearer":[]}],"parameters":[{"name":"bin_id","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Bin Id"}},{"name":"days","in":"query","required":false,"schema":{"type":"integer","maximum":365,"minimum":1,"default":30,"title":"Days"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/DailyReading"},"title":"Response Get Bin History Bins  Bin Id  History Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/alerts":{"get":{"tags":["alerts"],"summary":"List Alerts","description":"The user's alerts, newest first: open ones, or the history with include_resolved.","operationId":"list_alerts_alerts_get","security":[{"HTTPBearer":[]}],"parameters":[{"name":"bin_id","in":"query","required":false,"schema":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Bin Id"}},{"name":"include_resolved","in":"query","required":false,"schema":{"type":"boolean","default":false,"title":"Include Resolved"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Alert"},"title":"Response List Alerts Alerts Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/":{"get":{"summary":"Root","operationId":"root__get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/records":{"post":{"summary":"Send Records","operationId":"send_records_records_post","requestBody":{"content":{"application/json":{"schema":{"items":{"$ref":"#/components/schemas/Record"},"type":"array","title":"Readings"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"APIKeyHeader":[]}]}}},"components":{"schemas":{"AccountDelete":{"properties":{"password":{"type":"string","title":"Password"}},"type":"object","required":["password"],"title":"AccountDelete"},"Alert":{"properties":{"id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Id"},"bin_id":{"type":"string","format":"uuid","title":"Bin Id"},"bin_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Bin Name"},"type":{"type":"string","title":"Type"},"severity":{"type":"string","title":"Severity"},"triggered_at":{"type":"string","format":"date-time","title":"Triggered At"},"resolved_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Resolved At"},"device_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Device Id"},"device_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Device Name"}},"type":"object","required":["id","bin_id","bin_name","type","severity","triggered_at","resolved_at"],"title":"Alert"},"Bin":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Name"},"location":{"type":"string","title":"Location"},"country_code":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Country Code"}},"type":"object","required":["id","name","location","country_code"],"title":"Bin"},"BinChange":{"properties":{"name":{"anyOf":[{"type":"string","maxLength":80,"minLength":1},{"type":"null"}],"title":"Name"},"location":{"anyOf":[{"type":"string","maxLength":120},{"type":"null"}],"title":"Location"},"country_code":{"anyOf":[{"type":"string","pattern":"^[A-Za-z]{2}$"},{"type":"null"}],"title":"Country Code"}},"type":"object","title":"BinChange"},"BinCreate":{"properties":{"name":{"type":"string","maxLength":80,"minLength":1,"title":"Name"},"location":{"type":"string","maxLength":120,"title":"Location","default":""},"country_code":{"type":"string","pattern":"^[A-Za-z]{2}$","title":"Country Code"}},"type":"object","required":["name","country_code"],"title":"BinCreate"},"BinRef":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Name"}},"type":"object","required":["id","name"],"title":"BinRef"},"DailyReading":{"properties":{"day":{"type":"string","format":"date","title":"Day"},"avg_temp":{"type":"number","title":"Avg Temp"},"max_temp":{"type":"number","title":"Max Temp"}},"type":"object","required":["day","avg_temp","max_temp"],"title":"DailyReading"},"Device":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"hardware_id":{"type":"string","title":"Hardware Id"},"name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Name"},"model":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Model"},"firmware_version":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Firmware Version"},"paired_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Paired At"},"last_seen_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Last Seen At"},"bin":{"anyOf":[{"$ref":"#/components/schemas/BinRef"},{"type":"null"}]},"set_up":{"type":"boolean","title":"Set Up"}},"type":"object","required":["id","hardware_id","name","model","firmware_version","paired_at","last_seen_at","bin","set_up"],"title":"Device"},"DeviceChange":{"properties":{"name":{"anyOf":[{"type":"string","maxLength":80,"minLength":1},{"type":"null"}],"title":"Name"},"bin_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Bin Id"}},"type":"object","title":"DeviceChange"},"DeviceSetup":{"properties":{"name":{"type":"string","maxLength":80,"minLength":1,"title":"Name"},"bin_id":{"type":"string","format":"uuid","title":"Bin Id"}},"type":"object","required":["name","bin_id"],"title":"DeviceSetup"},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"LoginRequest":{"properties":{"email":{"type":"string","title":"Email"},"password":{"type":"string","title":"Password"}},"type":"object","required":["email","password"],"title":"LoginRequest"},"PairingCode":{"properties":{"code":{"type":"string","title":"Code"},"expires_at":{"type":"string","format":"date-time","title":"Expires At"}},"type":"object","required":["code","expires_at"],"title":"PairingCode"},"PairingStatus":{"properties":{"code":{"type":"string","title":"Code"},"status":{"type":"string","enum":["pending","redeemed","expired"],"title":"Status"},"expires_at":{"type":"string","format":"date-time","title":"Expires At"},"device":{"anyOf":[{"$ref":"#/components/schemas/Device"},{"type":"null"}]}},"type":"object","required":["code","status","expires_at"],"title":"PairingStatus"},"PasswordChange":{"properties":{"current_password":{"type":"string","title":"Current Password"},"new_password":{"type":"string","maxLength":128,"minLength":8,"title":"New Password"}},"type":"object","required":["current_password","new_password"],"title":"PasswordChange"},"ProfileUpdate":{"properties":{"display_name":{"anyOf":[{"type":"string","maxLength":80},{"type":"null"}],"title":"Display Name"}},"type":"object","required":["display_name"],"title":"ProfileUpdate"},"Reading":{"properties":{"timestamp":{"type":"string","format":"date-time","title":"Timestamp"},"temperature":{"type":"number","title":"Temperature"},"moisture_percent":{"type":"number","title":"Moisture Percent"},"o2_percent":{"type":"number","title":"O2 Percent"},"co2_percent":{"type":"number","title":"Co2 Percent"},"nh3_ratio":{"type":"number","title":"Nh3 Ratio"},"device_id":{"type":"string","format":"uuid","title":"Device Id"}},"type":"object","required":["timestamp","temperature","moisture_percent","o2_percent","co2_percent","nh3_ratio","device_id"],"title":"Reading"},"Record":{"properties":{"timestamp":{"type":"string","format":"date-time","title":"Timestamp"},"temperature":{"type":"number","title":"Temperature"},"moisture_percent":{"type":"number","title":"Moisture Percent"},"o2_percent":{"type":"number","title":"O2 Percent"},"co2_percent":{"type":"number","title":"Co2 Percent"},"nh3_ratio":{"type":"number","title":"Nh3 Ratio"}},"type":"object","required":["timestamp","temperature","moisture_percent","o2_percent","co2_percent","nh3_ratio"],"title":"Record"},"RedeemRequest":{"properties":{"code":{"type":"string","title":"Code"},"device_uid":{"type":"string","title":"Device Uid"},"model":{"anyOf":[{"type":"string"},{"type":"null"}],"maxLength":80,"title":"Model"},"firmware_version":{"anyOf":[{"type":"string"},{"type":"null"}],"maxLength":80,"title":"Firmware Version"}},"type":"object","required":["code","device_uid"],"title":"RedeemRequest"},"RedeemResponse":{"properties":{"device_id":{"type":"string","format":"uuid","title":"Device Id"},"api_key":{"type":"string","title":"Api Key"}},"type":"object","required":["device_id","api_key"],"title":"RedeemResponse"},"RegisterRequest":{"properties":{"email":{"type":"string","format":"email","title":"Email"},"password":{"type":"string","maxLength":128,"minLength":8,"title":"Password"},"display_name":{"anyOf":[{"type":"string","maxLength":80},{"type":"null"}],"title":"Display Name"}},"type":"object","required":["email","password"],"title":"RegisterRequest"},"Token":{"properties":{"access_token":{"type":"string","title":"Access Token"},"token_type":{"type":"string","title":"Token Type","default":"bearer"},"expires_at":{"type":"string","format":"date-time","title":"Expires At"},"user":{"$ref":"#/components/schemas/User"}},"type":"object","required":["access_token","expires_at","user"],"title":"Token"},"User":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"email":{"type":"string","title":"Email"},"display_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Display Name"}},"type":"object","required":["id","email","display_name"],"title":"User"},"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"},"APIKeyHeader":{"type":"apiKey","in":"header","name":"x-key"}}}}