{"openapi":"3.0.0","servers":[{"url":"http://52.33.199.81:8088/"},{"url":"http://ec2-34-215-113-54.us-west-2.compute.amazonaws.com:30300"},{"url":"http://127.0.0.1:8088/"}],"info":{"description":"420bits API integration documentation","version":"0.0.1-oas3","title":"420bits Open API","contact":{"email":"bits420bits@gmail.com"},"license":{"name":"Apache 2.0","url":"http://www.apache.org/licenses/LICENSE-2.0.html"}},"paths":{"/user/{user_id}":{"get":{"tags":["Users"],"summary":"Get a user information","description":"Users only can fetch their own information, or data of users that consented to share their data.","parameters":[{"$ref":"#/components/parameters/Jwt"},{"$ref":"#/components/parameters/UserIDPath"}],"responses":{"200":{"description":"User information","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserResponse"}}}},"400":{"description":"Invalid data","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DefaultErrorResponse"}}}}}}},"/user":{"post":{"tags":["Users"],"summary":"Creates a new user","description":"Adds a user to the system","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateUserRequest"}}},"description":"User to be created","required":true},"responses":{"201":{"description":"Success - Create and Authenticate user, and return the credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthResponse"}}}},"400":{"description":"Invalid data","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DefaultErrorResponse"}}}}}},"put":{"tags":["Users"],"summary":"Update user information","description":"Update username and or password of the logged in user","parameters":[{"$ref":"#/components/parameters/Jwt"},{"$ref":"#/components/parameters/UserIDPath"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateUserRequest"}}},"description":"The user information you want to update","required":true},"responses":{"200":{"description":"User information successfully updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserResponse"}}}},"400":{"description":"Invalid data","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DefaultErrorResponse"}}}}}},"delete":{"tags":["Users"],"summary":"Delete a user","description":"Only the current logged in user can delete itself","parameters":[{"$ref":"#/components/parameters/Jwt"},{"$ref":"#/components/parameters/UserIDPath"}],"responses":{"200":{"description":"User successfully deleted and session closed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StandardDeletedResponse"}}}},"400":{"description":"Invalid data","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DefaultErrorResponse"}}}}}}},"/auth":{"post":{"tags":["Auth"],"summary":"Authentication","description":"Creates an authentication session","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthRequest"}}},"description":"User to be authenticated","required":true},"responses":{"200":{"description":"Credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthResponse"}}}},"404":{"description":"Username or password incorrect","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DefaultErrorResponse"}}}}}}},"/place":{"post":{"tags":["Places"],"summary":"Create or update a place","description":"Create or update a new place information.","parameters":[{"$ref":"#/components/parameters/Jwt"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreatePlaceRequest"}}},"description":"The information of the place to be created","required":true},"responses":{"201":{"description":"Success","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlaceResponse"}}}},"400":{"description":"Invalid data","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DefaultErrorResponse"}}}}}},"get":{"tags":["Places"],"summary":"Places list endpoint","description":"Returns the list of places the user has access to","parameters":[{"$ref":"#/components/parameters/Jwt"}],"responses":{"200":{"description":"Return list of places","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetPlacesResponse"}}}},"400":{"description":"Invalid data","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DefaultErrorResponse"}}}}}},"put":{"tags":["Places"],"summary":"Update the place information","description":"For now we only support updating the place name","parameters":[{"$ref":"#/components/parameters/Jwt"},{"$ref":"#/components/parameters/PlaceIDPath"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/EditPlaceRequest"}}},"description":"The information of the place to be updated.","required":true},"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlaceResponse"}}}},"400":{"description":"Invalid data","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DefaultErrorResponse"}}}}}},"delete":{"tags":["Places"],"summary":"Delete a place","description":"Delete a place that the user has access to","parameters":[{"$ref":"#/components/parameters/Jwt"},{"$ref":"#/components/parameters/PlaceIDPath"}],"responses":{"200":{"description":"Place successfully deleted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StandardDeletedResponse"}}}},"400":{"description":"Invalid data","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DefaultErrorResponse"}}}}}}},"/room":{"post":{"tags":["Rooms"],"summary":"Create or update a room information","description":"Create or update a room information","parameters":[{"$ref":"#/components/parameters/Jwt"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateRoomRequest"}}},"description":"The information of the room that will be created.","required":true},"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateRoomResponse"}}}},"400":{"description":"Invalid data","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DefaultErrorResponse"}}}}}},"get":{"tags":["Rooms"],"summary":"Get a list of rooms","description":"Returns all the rooms of a specific place","parameters":[{"$ref":"#/components/parameters/PlaceIDQuery"},{"$ref":"#/components/parameters/Jwt"}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetRoomsResponse"}}}},"400":{"description":"Invalid data","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DefaultErrorResponse"}}}}}},"delete":{"tags":["Rooms"],"summary":"Delete a room","description":"Delete a room the user has access to","parameters":[{"$ref":"#/components/parameters/Jwt"},{"$ref":"#/components/parameters/RoomIDPath"}],"responses":{"200":{"description":"Room successfully deleted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StandardDeletedResponse"}}}},"400":{"description":"Invalid data","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DefaultErrorResponse"}}}}}},"put":{"tags":["Rooms"],"summary":"Update the room information","description":"For now we only support updating the room name and place","parameters":[{"$ref":"#/components/parameters/Jwt"},{"$ref":"#/components/parameters/RoomIDPath"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/EditRoomRequest"}}},"description":"The information of the room that will be updated. For now user can only update the place_id and/or the name.","required":true},"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateRoomResponse"}}}},"400":{"description":"Invalid data","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DefaultErrorResponse"}}}}}}},"/accessory_setup_session":{"post":{"tags":["Accessory setup session"],"summary":"Creates a session to setup a new acccessory","description":"In order to create a new accessory, a session toke is requried","parameters":[{"$ref":"#/components/parameters/Jwt"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccessorySetupSessionRequest"}}},"description":"The id of the room the user will add an accessory to.","required":true},"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccessorySetupSessionResponse"}}}},"400":{"description":"Invalid data","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DefaultErrorResponse"}}}}}}},"/accessories_template":{"get":{"tags":["Accessories Template"],"summary":"Accessories template endpoint","description":"Returns the list of accessories the user can add manually","parameters":[{"$ref":"#/components/parameters/Jwt"}],"responses":{"200":{"description":"Return list of accessories the user can add manually","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetAccessoryTemplateResponse"}}}},"400":{"description":"Invalid data","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DefaultErrorResponse"}}}}}}},"/accessories":{"post":{"tags":["Accessories"],"summary":"Create accessories","description":"Acceepts an array of accessories and a setup session id.","parameters":[{"$ref":"#/components/parameters/Jwt"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateAccessoryRequest"}}},"description":"The information of the accessories will be created.","required":true},"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateAccessoryResponse"}}}},"400":{"description":"Invalid data","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DefaultErrorResponse"}}}}}}},"/accessory":{"delete":{"tags":["Accessory"],"summary":"Delete an accessory","description":"Delete an accessory that the user has access to","parameters":[{"$ref":"#/components/parameters/Jwt"},{"$ref":"#/components/parameters/AccessoryIDPath"}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StandardDeletedResponse"}}}},"400":{"description":"Invalid data","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DefaultErrorResponse"}}}}}},"put":{"tags":["Accessory"],"summary":"Update the accessory information","description":"For now we only support updating the alias of the accessory","parameters":[{"$ref":"#/components/parameters/Jwt"},{"$ref":"#/components/parameters/AccessoryIDPath"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateAccessoryRequest"}}},"description":"The information of the room that will be updated. For now user can only update the place_id and/or the name.","required":true},"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccessoryResponse"}}}},"400":{"description":"Invalid data","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DefaultErrorResponse"}}}}}}},"/place_dashboard":{"get":{"tags":["Dashboard"],"summary":"The Dashboard of a place","description":"The dashboard of a place is the list of rooms it has. If the room_id query parameter is passed, the response will include its accessories, otherwise it will include the accessories of the first place.","parameters":[{"$ref":"#/components/parameters/Jwt"},{"$ref":"#/components/parameters/PlaceIDPath"},{"$ref":"#/components/parameters/RoomIDQuery"}],"responses":{"200":{"description":"The place information, and the list of rooms. Only the room that matches with the room_id query parameter will bring in the accessories.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlaceDashboardResponse"}}}},"400":{"description":"Invalid data","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DefaultErrorResponse"}}}}}}},"/accessories_logs":{"post":{"tags":["Accessories logs"],"summary":"Create a log.","responses":{"400":{"description":"Invalid data","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DefaultErrorResponse"}}}}}},"delete":{"tags":["Accessories logs"],"summary":"Delete a log.","responses":{"400":{"description":"Invalid data","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DefaultErrorResponse"}}}}}},"put":{"tags":["Accessories logs"],"summary":"Update a log.","responses":{"400":{"description":"Invalid data","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DefaultErrorResponse"}}}}}},"get":{"tags":["Accessories logs"],"summary":"Return a list of accessories data log.","description":"Return a list of accessories data log. Mostly used to plot data on charts.","parameters":[{"$ref":"#/components/parameters/Jwt"},{"$ref":"#/components/parameters/LimitQuery"},{"$ref":"#/components/parameters/AccessoryIDQuery"},{"$ref":"#/components/parameters/FromDateQuery"},{"$ref":"#/components/parameters/ToDateQuery"}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccessoriesLogsResponse"}}}},"401":{"description":"Invalid data","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DefaultErrorResponse"}}}}}}}},"components":{"schemas":{"DashboardRoom":{"type":"object","required":["_id","name","accessories"],"properties":{"_id":{"type":"string","example":"5985270044ed65484b7085a8"},"name":{"type":"string","example":"My room"},"accessories":{"type":"array","items":{"$ref":"#/components/schemas/AccessoryObject"}}}},"DashboardPlace":{"type":"object","required":["_id","name","owner_user","rooms"],"properties":{"_id":{"type":"string","example":"59851f1f44ed65484b708375"},"name":{"type":"string","example":"My new place"},"owner_user":{"$ref":"#/components/schemas/UserObject"},"rooms":{"type":"array","items":{"$ref":"#/components/schemas/DashboardRoom"}}}},"AccessoryLog":{"type":"object","required":["creation_date","accessory"],"properties":{"_id":{"type":"string","example":"59853a1544ed65484b708b1c"},"creation_date":{"type":"number","example":"1506122645.79601"},"accessory":{"$ref":"#/components/schemas/AccessoryObject"}}},"GetAccessoryTemplateResponse":{"type":"object","required":["accessories_templates"],"properties":{"accessories_templates":{"type":"array","items":{"$ref":"#/components/schemas/AccessoryObject"}}}},"AccessoriesLogsResponse":{"type":"object","required":["logs"],"properties":{"logs":{"type":"array","items":{"$ref":"#/components/schemas/AccessoryLog"}}}},"PlaceDashboardResponse":{"type":"object","required":["place"],"properties":{"place":{"$ref":"#/components/schemas/DashboardPlace"}}},"AccessorySetupSession":{"type":"object","required":["user_id","_id","jwt"],"properties":{"room_id":{"type":"string","example":"5985270044ed65484b7085a8"},"user_id":{"type":"string","example":"59851d5d44ed65484b7082e9"},"_id":{"type":"string","example":"59853a1544ed65484b708b1c"},"jwt":{"type":"string","example":"1501896038.92-59851d5d44ed65484b7082e9"}}},"AccessorySetupSessionRequest":{"type":"object","required":["room_id"],"properties":{"room_id":{"type":"string","example":"5985270044ed65484b7085a8"}}},"AccessorySetupSessionResponse":{"type":"object","required":["accessory_setup_session"],"properties":{"accessory_setup_session":{"$ref":"#/components/schemas/AccessorySetupSession"}}},"CreateAccessoryResponse":{"type":"object","required":["accessories"],"properties":{"accessories":{"type":"array","items":{"$ref":"#/components/schemas/AccessoryObject"}}}},"AccessoryResponse":{"type":"object","required":["accessory"],"properties":{"accessory":{"$ref":"#/components/schemas/AccessoryObject"}}},"CreateAccessoryRequest":{"type":"object","required":["setup_session_id","accessories"],"properties":{"setup_session_id":{"type":"string","example":"5985270044ed65484b7085a8"},"accessories":{"type":"array","items":{"$ref":"#/components/schemas/AccessoryObject"}}}},"UpdateAccessoryRequest":{"type":"object","required":["alias"],"properties":{"alias":{"type":"string","example":"New alias of the accessory"}}},"AccessoryObject":{"type":"object","required":["local_id","mac_id","layout_type","accessory_type"],"properties":{"_id":{"type":"string","example":"do not send id when creating, it will be ignored"},"accessory_type":{"type":"string","example":"1"},"layout_type":{"type":"string","example":"1"},"name":{"type":"string","example":"Default accessory name"},"alias":{"type":"string","example":"Room's light"},"mac_id":{"type":"string","example":"a0:20:a6:1b:5e:97"},"local_id":{"type":"string","example":"a0:20:a6:1b:5e:97"},"is_online":{"type":"boolean","example":true},"last_contact_timestamp":{"type":"number","example":1.501893040761755E9},"current_value":{"type":"string","example":"10"},"value_type":{"type":"string","example":"string"},"values_allowed":{"type":"array","items":{"type":"string"},"example":["100","10","22"]},"update_topic":{"type":"string","example":"accessory/update/a0:20:a6:1b:5e:97/1"},"allow_edit":{"type":"boolean","example":true},"measurement_unit":{"type":"string","example":"ppm"},"features":{"type":"array","items":{"type":"string"},"example":["timer"]},"owner_user_id":{"type":"string","example":"592386d9ece9e403a2544657"},"room_id":{"type":"string","example":"5985270044ed65484b7085a8"}}},"GetRoomsResponse":{"type":"object","required":["rooms"],"properties":{"rooms":{"type":"array","items":{"$ref":"#/components/schemas/RoomObject"}}}},"RoomObject":{"type":"object","required":["_id","place","name"],"properties":{"_id":{"type":"string","example":"5985270044ed65484b7085a8"},"name":{"type":"string","example":"My room"},"place":{"$ref":"#/components/schemas/PlaceWithOwner"}}},"CreateRoomResponse":{"type":"object","required":["room"],"properties":{"room":{"$ref":"#/components/schemas/RoomObject"}}},"CreateRoomRequest":{"type":"object","required":["name","place_id"],"properties":{"name":{"type":"string","example":"My first room"},"place_id":{"type":"string","example":"598526b844ed65484b708596"}}},"EditRoomRequest":{"type":"object","required":["name","place_id"],"properties":{"name":{"type":"string","example":"My first room"},"place_id":{"type":"string","example":"598526b844ed65484b708596"}}},"GetPlacesResponse":{"type":"object","required":["places"],"properties":{"places":{"type":"array","items":{"$ref":"#/components/schemas/PlaceWithOwner"}}}},"PlaceWithOwner":{"type":"object","required":["_id","name","owner_user"],"properties":{"_id":{"type":"string","example":"59851f1f44ed65484b708375"},"name":{"type":"string","example":"My new place"},"owner_user":{"$ref":"#/components/schemas/UserObject"}}},"PlaceObject":{"type":"object","required":["_id","name","owner_user"],"properties":{"owner_user":{"$ref":"#/components/schemas/UserObject"},"_id":{"type":"string","example":"59851f1f44ed65484b708375"},"name":{"type":"string","example":"My new place"}}},"PlaceResponse":{"type":"object","required":["place"],"properties":{"place":{"$ref":"#/components/schemas/PlaceObject"}}},"CreatePlaceRequest":{"type":"object","required":["name"],"properties":{"name":{"type":"string","example":"My first place"}}},"EditPlaceRequest":{"type":"object","required":["name"],"properties":{"name":{"type":"string","example":"My first place"}}},"StandardDeletedResponse":{"type":"object","required":["deleted"],"properties":{"deleted":{"type":"string","example":"592386d9ece9e403a2544657"}}},"AuthResponse":{"type":"object","required":["user","auth"],"properties":{"user":{"$ref":"#/components/schemas/UserObject"},"auth":{"$ref":"#/components/schemas/AuthObject"}}},"AuthObject":{"type":"object","required":["user_id","jwt","creation_date"],"properties":{"user_id":{"type":"string","example":"592386d9ece9e403a2544657"},"jwt":{"type":"string","example":"1501892164.01-592386d9ece9e403a2544657"},"creation_date":{"example":1.501893040761755E9,"type":"number"}}},"UserObject":{"type":"object","required":["name","username","_id"],"properties":{"username":{"type":"string","example":"admin"},"_id":{"type":"string","example":"592386d9ece9e403a2544657"},"name":{"type":"string","example":"William hass"}}},"AuthRequest":{"type":"object","required":["username","password"],"properties":{"username":{"type":"string","example":"admin"},"password":{"type":"string","example":"admin"}}},"CreateUserRequest":{"type":"object","required":["name","password","username"],"properties":{"name":{"type":"string","example":"William hass"},"password":{"type":"string","example":"admin"},"username":{"type":"string","example":"admin"}}},"UpdateUserRequest":{"type":"object","required":["name","password"],"properties":{"name":{"type":"string","example":"William hass"},"password":{"type":"string","example":"admin"}}},"UserResponse":{"type":"object","required":["user"],"properties":{"user":{"$ref":"#/components/schemas/UserObject"}}},"DefaultError":{"type":"object","required":["message"],"properties":{"message":{"type":"string","example":"Field not sent"}}},"DefaultErrorResponse":{"type":"object","properties":{"success":{"type":"integer","default":0},"messages":{"type":"array","items":{"$ref":"#/components/schemas/DefaultError"}}}}},"parameters":{"accessory_id":{"name":"_id","in":"query","description":"The id of an accessory","required":false,"schema":{"type":"string","default":"59c591d2c23bab5fcc993d7a"}},"update_topic":{"name":"update_topic","in":"query","description":"The update topic of an accessory","required":false,"schema":{"type":"string","default":"60:01:94:29:96:9d"}},"mac_id":{"name":"mac_id","in":"query","description":"The mac id of the hardware","required":false,"schema":{"type":"string","default":"60:01:94:29:96:9d"}},"local_id":{"name":"local_id","in":"query","description":"The local id of the hardware","required":false,"schema":{"type":"string","default":"any34"}},"PlaceIDQuery":{"name":"place_id","in":"query","description":"The id of a place","required":true,"schema":{"type":"string","default":"59851ef344ed65484b708363"}},"setup_session_id":{"name":"setup_session_id","in":"query","description":"The id of the session to create a new accessory","required":true,"schema":{"type":"string","default":"59853a1544ed65484b708b1c"}},"RoomIDQuery":{"name":"room_id","in":"query","description":"The id of a room","required":false,"schema":{"type":"string","default":"5985270044ed65484b7085a8"}},"FromDateQuery":{"name":"from_date","in":"query","description":"Date timestamp in seconds","required":true,"schema":{"type":"string","default":123345345}},"ToDateQuery":{"name":"to_date","in":"query","description":"Date timestamp in seconds","required":true,"schema":{"type":"string","default":123345345}},"Jwt":{"name":"Jwt","in":"header","description":"Authetication JWT","required":true,"schema":{"type":"string","default":"1506351020.83-59c5878fc23bab5fcc993d72"}},"RoomIDPath":{"name":"room_id","in":"path","description":"ID of the usemr","required":true,"schema":{"type":"string"}},"UserIDPath":{"name":"user_id","in":"path","description":"ID of the user","required":true,"schema":{"type":"string"}},"PlaceIDPath":{"name":"place_id","in":"path","description":"ID of the Place","required":true,"schema":{"type":"string"}},"AccessoryIDPath":{"name":"accessory_id","in":"path","description":"ID of the Accessory","required":true,"schema":{"type":"string"}},"AccessoryIDQuery":{"name":"accessory_id","in":"query","description":"ID of the Accessory","required":true,"schema":{"type":"string"}},"LimitQuery":{"name":"limit","in":"query","description":"Limit of results","required":false,"schema":{"type":"integer"}}}}}