{"openapi":"3.0.3","info":{"title":"Sensor Service API","version":"1.1.0","description":"Read-only API for projects, devices, sensors and measurements.\n\nAuthenticate with an API key made under Instellingen > API-sleutels: a key of the OAuth kind is exchanged for a bearer token at `/api/v1/oauth/token`; a key of the Bearer kind is sent as `Authorization: Bearer ak_...` itself.\n\nA key reads the projects of its workspace, all of them or the ones in its scope.\n\nMeasurements: one request covers at most 366 days and returns at most 100000 rows."},"servers":[{"url":"/"}],"tags":[{"name":"Authentication","description":"Tokens for keys of the OAuth kind."},{"name":"Projects"},{"name":"Devices"},{"name":"Sensors"}],"components":{"securitySchemes":{"oauth2ClientCredentials":{"type":"oauth2","flows":{"clientCredentials":{"tokenUrl":"/api/v1/oauth/token","scopes":{}}}},"bearerApiKey":{"type":"http","scheme":"bearer","description":"Keys of the Bearer kind: `Authorization: Bearer ak_...`"}},"schemas":{"Error":{"type":"object","required":["error"],"properties":{"error":{"type":"string"}}},"Token":{"type":"object","properties":{"access_token":{"type":"string"},"token_type":{"type":"string","enum":["Bearer"]},"expires_in":{"type":"integer","description":"Seconds"},"scope":{"type":"string","description":"Project codes, or `all`"}}},"Project":{"type":"object","properties":{"project_id":{"type":"integer"},"project_code":{"type":"string"},"project_name":{"type":"string"},"description":{"type":"string","nullable":true},"contract_end_date":{"type":"string","format":"date-time","nullable":true},"start_date":{"type":"string","format":"date-time","nullable":true},"end_date":{"type":"string","format":"date-time","nullable":true},"location":{"type":"string","description":"`<lat>, <lon>`","nullable":true},"latitude":{"type":"number","nullable":true},"longitude":{"type":"number","nullable":true},"device_count":{"type":"integer"},"sensor_count":{"type":"integer"}}},"ProjectSetting":{"type":"object","properties":{"setting_id":{"type":"integer"},"project_id":{"type":"integer"},"setting":{"type":"string"},"description":{"type":"string","nullable":true}}},"ProjectLayer":{"type":"object","description":"One layer of the roof build-up, from the top down","properties":{"position":{"type":"integer","description":"0 is the top layer"},"layer_type":{"type":"string","enum":["vegetatie","afstrooi","bovensubstraat","ondersubstraat","filterlaag","drainage_retentie","beschermlaag"]},"material":{"type":"string","nullable":true},"substrate_id":{"type":"integer","description":"Catalogue material, when the layer uses one","nullable":true},"height_cm":{"type":"string","description":"Numeric as text","nullable":true}}},"ProjectLayers":{"type":"object","properties":{"project_id":{"type":"integer"},"project_code":{"type":"string"},"count":{"type":"integer"},"total_height_cm":{"type":"string","description":"Sum of the layer heights, numeric as text"},"layers":{"type":"array","items":{"$ref":"#/components/schemas/ProjectLayer"}}}},"ProjectDetail":{"allOf":[{"$ref":"#/components/schemas/Project"},{"type":"object","properties":{"settings":{"type":"array","items":{"$ref":"#/components/schemas/ProjectSetting"}},"layers":{"type":"array","items":{"$ref":"#/components/schemas/ProjectLayer"}}}}]},"SensorSummary":{"type":"object","properties":{"sensor_id":{"type":"integer"},"parameter_name":{"type":"string"},"unit":{"type":"string"}}},"Device":{"type":"object","properties":{"device_id":{"type":"integer"},"project_id":{"type":"integer"},"device_name":{"type":"string"},"description":{"type":"string","nullable":true},"installation_description":{"type":"string","nullable":true},"brand":{"type":"string","nullable":true},"serial_number":{"type":"string","nullable":true},"installation_settings":{"type":"string","nullable":true},"dev_eui":{"type":"string","nullable":true},"dev_addr":{"type":"string","nullable":true},"administrator":{"type":"string","nullable":true},"start_date":{"type":"string","format":"date-time","nullable":true},"end_date":{"type":"string","format":"date-time","nullable":true},"type":{"type":"integer","description":"Device type id","nullable":true},"public_id":{"type":"string","description":"Id of the public page `/d/{public_id}`"},"latitude":{"type":"number","nullable":true},"longitude":{"type":"number","nullable":true},"project_code":{"type":"string"},"project_name":{"type":"string"},"sensor_count":{"type":"integer"},"sensors":{"type":"array","items":{"$ref":"#/components/schemas/SensorSummary"}}}},"Sensor":{"type":"object","properties":{"sensor_id":{"type":"integer"},"device_id":{"type":"integer"},"project_id":{"type":"integer"},"parameter_id":{"type":"integer"},"description":{"type":"string","nullable":true},"latitude":{"type":"string","description":"Numeric as text","nullable":true},"longitude":{"type":"string","description":"Numeric as text","nullable":true},"start_date":{"type":"string","format":"date-time","nullable":true},"end_date":{"type":"string","format":"date-time","nullable":true},"project_code":{"type":"string"},"project_name":{"type":"string"},"device_name":{"type":"string"},"parameter_name":{"type":"string"},"unit":{"type":"string"},"last_value":{"type":"string","description":"Only with `last_value=true`","nullable":true},"last_measurement_at":{"type":"string","format":"date-time","nullable":true}}},"DeviceDetail":{"allOf":[{"$ref":"#/components/schemas/Device"},{"type":"object","properties":{"sensors":{"type":"object","properties":{"count":{"type":"integer"},"items":{"type":"array","items":{"$ref":"#/components/schemas/Sensor"}}}}}}]},"Measurement":{"type":"object","properties":{"measurement_id":{"type":"integer"},"sensor_id":{"type":"integer"},"device_id":{"type":"integer"},"project_id":{"type":"integer"},"project_code":{"type":"string"},"timestamp":{"type":"string","format":"date-time"},"value":{"type":"string","description":"Numeric as text"},"location":{"type":"string","nullable":true},"cleaned":{"type":"boolean"},"parameter_id":{"type":"integer"},"parameter_name":{"type":"string"},"unit":{"type":"string"}}},"MeasurementExtended":{"type":"object","properties":{"measurement_id":{"type":"integer"},"timestamp":{"type":"string","format":"date-time"},"value":{"type":"string","description":"Numeric as text"},"location":{"type":"string","nullable":true},"sensor_id":{"type":"integer"},"parameter_id":{"type":"integer"},"parameter_name":{"type":"string"},"unit":{"type":"string"},"device_id":{"type":"integer"},"device_name":{"type":"string"},"project_id":{"type":"integer"}}}}},"security":[{"oauth2ClientCredentials":[]},{"bearerApiKey":[]}],"paths":{"/api/v1/oauth/token":{"post":{"tags":["Authentication"],"summary":"Issue a token","description":"OAuth2 client credentials: `client_id` is the key's name, `client_secret` the key. The token is valid for 15 minutes; a revoked key stops its tokens at once.","security":[],"requestBody":{"required":true,"content":{"application/x-www-form-urlencoded":{"schema":{"type":"object","required":["grant_type","client_id","client_secret"],"properties":{"grant_type":{"type":"string","enum":["client_credentials"]},"client_id":{"type":"string","description":"Name of the key"},"client_secret":{"type":"string","description":"The key (`ak_...`)"}}}}}},"responses":{"200":{"description":"Token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Token"}}}},"400":{"description":"Invalid request"},"401":{"description":"Invalid client credentials"}}}},"/api/v1/projects":{"get":{"tags":["Projects"],"summary":"List projects","responses":{"200":{"description":"Projects, by name","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Project"}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/projects/{project_id}":{"get":{"tags":["Projects"],"summary":"Get a project","parameters":[{"name":"project_id","in":"path","required":true,"schema":{"type":"integer"},"description":"Project id"}],"responses":{"200":{"description":"The project with its settings and build-up","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProjectDetail"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/projects/{project_id}/layers":{"get":{"tags":["Projects"],"summary":"Get the build-up (opbouw) of a project","parameters":[{"name":"project_id","in":"path","required":true,"schema":{"type":"integer"},"description":"Project id"}],"responses":{"200":{"description":"The layers from the top down, with the total height","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProjectLayers"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/projects/{project_id}/devices":{"get":{"tags":["Projects"],"summary":"List the devices of a project","parameters":[{"name":"project_id","in":"path","required":true,"schema":{"type":"integer"},"description":"Project id"}],"responses":{"200":{"description":"Devices, by name","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Device"}}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/devices":{"get":{"tags":["Devices"],"summary":"List devices","parameters":[{"name":"serial_number","in":"query","schema":{"type":"string"},"description":"Part of the serial number"},{"name":"brand","in":"query","schema":{"type":"string"},"description":"Part of the brand"}],"responses":{"200":{"description":"Devices, by name","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Device"}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/devices/{device_id}":{"get":{"tags":["Devices"],"summary":"Get a device with its sensors","parameters":[{"name":"device_id","in":"path","required":true,"schema":{"type":"integer"},"description":"Device id"}],"responses":{"200":{"description":"The device","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeviceDetail"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/sensors":{"get":{"tags":["Sensors"],"summary":"List sensors","parameters":[{"name":"device_id","in":"query","schema":{"type":"integer"}},{"name":"parameter_id","in":"query","schema":{"type":"integer"}},{"name":"project_id","in":"query","schema":{"type":"integer"}},{"name":"last_value","in":"query","schema":{"type":"boolean"},"description":"Add the latest value and its time"}],"responses":{"200":{"description":"Sensors, by project, device and id","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Sensor"}}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/sensors/{sensor_id}/measurements":{"get":{"tags":["Sensors"],"summary":"Measurements of a sensor","parameters":[{"name":"sensor_id","in":"path","required":true,"schema":{"type":"integer"},"description":"Sensor id"},{"name":"from","in":"query","schema":{"type":"string","format":"date-time"},"description":"Start of the range; default 24 hours before `to`"},{"name":"to","in":"query","schema":{"type":"string","format":"date-time"},"description":"End of the range; default now"}],"responses":{"200":{"description":"Measurements, oldest first","content":{"application/json":{"schema":{"type":"object","properties":{"range":{"type":"object","properties":{"from":{"type":"string","format":"date-time"},"to":{"type":"string","format":"date-time"}}},"count":{"type":"integer"},"items":{"type":"array","items":{"$ref":"#/components/schemas/Measurement"}}}}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/sensors/{sensor_id}/measurements-extended":{"get":{"tags":["Sensors"],"summary":"Measurements of a sensor, with device and parameter names","parameters":[{"name":"sensor_id","in":"path","required":true,"schema":{"type":"integer"},"description":"Sensor id"},{"name":"from","in":"query","schema":{"type":"string","format":"date-time"},"description":"Start of the range; default 24 hours before `to`"},{"name":"to","in":"query","schema":{"type":"string","format":"date-time"},"description":"End of the range; default now"}],"responses":{"200":{"description":"Measurements, oldest first","content":{"application/json":{"schema":{"type":"object","properties":{"range":{"type":"object","properties":{"from":{"type":"string","format":"date-time"},"to":{"type":"string","format":"date-time"}}},"count":{"type":"integer"},"items":{"type":"array","items":{"$ref":"#/components/schemas/MeasurementExtended"}}}}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}}}