{ "openapi": "3.0.1", "info": { "title": "G-Obs API", "description": "G-obs API as OpenAPI Rest API !", "termsOfService": "", "contact": { "email": "info@3liz.com" }, "license": { "name": "Mozilla Public Licence 2.0", "url": "https://www.mozilla.org/en-US/MPL/2.0/" }, "version": "1.0.0" }, "externalDocs": { "description": "Find out more about G-Obs", "url": "https://docs.3liz.org/lizmap-gobsapi-module/" }, "servers": [ { "url": "https://base.url/gobsapi.php" } ], "security": [ { "bearerAuth": [] } ], "components": { "schemas": { "ApiResponse": { "type": "object", "properties": { "code": { "type": "integer", "format": "int32", "description": "0 for error, 1 for success", "example": 1 }, "type": { "type": "string", "example": "success", "description": "error or success" }, "message": { "type": "string", "description": "Message describing the status", "example": "Operation successfull" } } }, "PointGeometryValue": { "required": [ "x", "y" ], "type": "object", "properties": { "x": { "type": "number", "format": "float", "description": "Longitude of the point", "example": 3.12345678 }, "y": { "type": "number", "format": "float", "description": "Latitude of the point", "example": 43.12345678 } }, "xml": { "name": "PointGeometryValue" } }, "GeometryExtent": { "required": [ "xmin", "ymin", "xmax", "ymax" ], "type": "object", "properties": { "xmin": { "type": "number", "format": "float", "description": "Minimum longitude", "example": 3.12345678 }, "ymin": { "type": "number", "format": "float", "description": "Minimum latitude", "example": 43.12345678 }, "xmax": { "type": "number", "format": "float", "description": "Maximum longitude", "example": 3.23456789 }, "ymax": { "type": "number", "format": "float", "description": "Maximum latitude", "example": 43.23456789 } }, "xml": { "name": "GeometryExtent" } }, "Project": { "type": "object", "properties": { "key": { "type": "string", "description": "unique key of the project", "example": "environment~weather" }, "label": { "type": "string", "description": "Label of the project, to be used as title", "example": "Weather data publication" }, "description": { "type": "string", "description": "Description of the project", "example": "This projects aims to show weather data" }, "media_url": { "type": "string", "description": "URL of the media describing the project" }, "geopackage_url": { "type": "string", "description": "URL of the GeoPackage file containing spatial layers for the project (rasters & vectors)" }, "extent": { "$ref": "#/components/schemas/GeometryExtent" } }, "xml": { "name": "Project" } }, "IndicatorValue": { "type": "object", "properties": { "code": { "type": "string", "description": "Code of the vector dimension", "example": "temperature" }, "name": { "type": "string", "description": "Name of the vector dimension", "example": "Température" }, "type": { "type": "string", "description": "Format of the stored value", "enum": [ "integer", "string", "boolean", "real" ], "example": "real" }, "unit": { "type": "string", "description": "Unit of the stored value", "example": "°C" } }, "xml": { "name": "IndicatorValue" } }, "IndicatorDocument": { "type": "object", "properties": { "id": { "type": "integer", "format": "int64", "example": 1 }, "indicator": { "type": "string", "description": "Code of the indicator", "example": "weather_status" }, "label": { "type": "string", "description": "Label of the document", "example": "Technical guide for using field weather stations" }, "description": { "type": "string", "description": "Full description of the document" }, "type": { "type": "string", "description": "Type of the document", "enum": [ "preview", "image", "video", "document", "other" ], "example": "document" }, "url": { "type": "string", "description": "Url of the document" }, "created_at": { "type": "string", "format": "date-time", "description": "Timestamp of the object creation", "example": "2010-01-15 13:10:19" }, "updated_at": { "type": "string", "format": "date-time", "description": "Timestamp of the last update", "example": "2010-01-15 13:15:38" } }, "xml": { "name": "IndicatorDocument" } }, "Indicator": { "type": "object", "properties": { "id": { "type": "integer", "description": "Unique internal identifier", "format": "int64", "example": 1 }, "code": { "type": "string", "description": "Code of the indicator. Can be used as an unique identifier", "example": "weather_status" }, "label": { "type": "string", "description": "Label of the indicator", "example": "Weather status" }, "description": { "type": "string", "description": "Description of the indicator", "example": "Weather status with measured temperature and hygrometry" }, "category": { "type": "string", "description": "Category of the indicator", "example": "Climate" }, "date_format": { "type": "string", "description": "Date format", "example": "day", "enum": [ "second", "minute", "hour", "day", "month", "year" ] }, "values": { "type": "array", "description": "List of values properties for the indicator", "example": [ { "code": "temperature", "name": "Température", "type": "real", "unit": "°C" }, { "code": "hygrometry", "name": "Hygrometry", "type": "real", "unit": "%" } ], "xml": { "wrapped": true }, "items": { "$ref": "#/components/schemas/IndicatorValue" } }, "documents": { "type": "array", "description": "List of documents for the indicator", "xml": { "wrapped": true }, "items": { "$ref": "#/components/schemas/IndicatorDocument" } }, "preview": { "type": "string", "description": "Url of the image illustrating the indicator" }, "icon": { "type": "string", "description": "Url of the indicator icon image" }, "created_at": { "type": "string", "format": "date-time", "description": "Timestamp of the object creation", "example": "2010-01-15 13:10:19" }, "updated_at": { "type": "string", "format": "date-time", "description": "Timestamp of the last update", "example": "2010-01-15 13:15:38" } }, "xml": { "name": "Indicator" } }, "ObservationSpatialObjectValue": { "required": [ "layer_code", "unique_id" ], "type": "object", "properties": { "layer_code": { "type": "string", "description": "Code of the spatial layer for the given spatial object unique ID", "example": "brittany-cities" }, "unique_id": { "type": "string", "description": "Unique ID of the spatial object to attach the observation to.", "example": "29007" } }, "xml": { "name": "ObservationSpatialObjectValue" } }, "Observation": { "required": [ "uuid", "indicator", "start_timestamp", "wkt", "values" ], "type": "object", "properties": { "id": { "type": "integer", "format": "int64", "description": "Unique internal identifier", "example": 1 }, "indicator": { "type": "string", "description": "Code of the indicator", "example": "weather_status" }, "uuid": { "type": "string", "description": "Unique identifier in format UUID", "example": "e715352e-edb0-553e-2c69-09b6dc768ea7" }, "start_timestamp": { "type": "string", "format": "date-time", "description": "Date and time of the start of the observation", "example": "2020-01-31 20:10:30" }, "end_timestamp": { "type": "string", "format": "date-time", "description": "Date and time of the end of the observation", "example": "2020-01-31 20:10:30" }, "coordinates": { "$ref": "#/components/schemas/PointGeometryValue" }, "spatial_object": { "$ref": "#/components/schemas/ObservationSpatialObjectValue" }, "wkt": { "type": "string", "description": "WKT representation of the observation geometry", "example": "POINT(3.123456 43.123456)" }, "values": { "type": "array", "description": "Values of the observation", "items": { "type": "string", "example": 20 } }, "media_url": { "type": "string", "description": "URL of the observation media" }, "created_at": { "type": "string", "format": "date-time", "description": "Timestamp of the object creation", "example": "2010-01-15 13:10:19" }, "updated_at": { "type": "string", "format": "date-time", "description": "Timestamp of the last update", "example": "2010-01-15 13:15:38" }, "editable": { "type": "boolean", "description": "Is the observation editable by the authenticated user ?", "example": true } }, "xml": { "name": "Observation" } } }, "responses": { "UnauthorizedError": { "description": "Access token is missing or invalid" } }, "securitySchemes": { "bearerAuth": { "type": "http", "scheme": "bearer", "bearerFormat": "JWT" } } }, "tags": [ { "name": "user", "description": "Operations about user" }, { "name": "project", "description": "Project" }, { "name": "indicator", "description": "Indicator" }, { "name": "observation", "description": "Field observation" } ], "paths": { "/user/login": { "get": { "tags": [ "user" ], "summary": "Logs user into the system", "operationId": "logUserIn", "parameters": [ { "name": "username", "in": "query", "description": "The user name for login", "required": true, "schema": { "type": "string" } }, { "name": "password", "in": "query", "description": "The password for login in clear text", "required": true, "schema": { "type": "string", "format": "password" } } ], "security": [], "responses": { "200": { "description": "Successfully authenticated. A token has been returned. You need to include this token in subsequent requests in Authorization header as 'Authorization: Bearer TOKEN'\n", "content": { "application/json": { "schema": { "type": "object", "properties": { "token": { "type": "string", "example": "1mx6L2L7AMdEsyKy5LW9s8gt6mBxdICwosVn5sjhbwykOoQJFUru6752dwsj2THN", "description": "Token" } } } } } }, "400": { "description": "Invalid username/password supplied", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApiResponse" } } } } } } }, "/user/logout": { "get": { "tags": [ "user" ], "summary": "Logs out current logged in user session. Invalidate the token", "operationId": "logUserOut", "responses": { "200": { "description": "successful operation", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApiResponse" } } } }, "401": { "$ref": "#/components/responses/UnauthorizedError" } } } }, "/user/projects": { "get": { "tags": [ "user" ], "summary": "Get projects for the authenticated user", "description": "Projects will be returned for the logged in user.", "operationId": "getUserProjects", "responses": { "200": { "description": "successful operation", "content": { "application/json": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/Project" } } } } }, "400": { "description": "Invalid indicator value", "content": {} }, "401": { "$ref": "#/components/responses/UnauthorizedError" } } } }, "/project/{projectKey}": { "get": { "tags": [ "project" ], "summary": "Get project by key", "description": "Returns a single project", "operationId": "getProjectByKey", "parameters": [ { "name": "projectKey", "in": "path", "description": "Key of the project to return", "example": "environment~weather", "required": true, "schema": { "type": "string" } } ], "responses": { "200": { "description": "successful operation", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Project" } } } }, "400": { "description": "Invalid key supplied", "content": {} }, "401": { "$ref": "#/components/responses/UnauthorizedError" }, "404": { "description": "Project not found", "content": {} } } } }, "/project/{projectKey}/indicators": { "get": { "tags": [ "project" ], "summary": "Get the indicators for a given project", "description": "Project key must be given in the path.", "operationId": "getProjectIndicators", "parameters": [ { "name": "projectKey", "in": "path", "description": "Project key to filter by.", "example": "environment~weather", "required": true, "schema": { "type": "string" } } ], "responses": { "200": { "description": "successful operation", "content": { "application/json": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/Indicator" } } } } }, "400": { "description": "Invalid indicator value", "content": {} }, "401": { "$ref": "#/components/responses/UnauthorizedError" } } } }, "/project/{projectKey}/geopackage": { "get": { "tags": [ "project" ], "summary": "Get the project GeoPackage file if available", "description": "Project key must be given in the path.", "operationId": "getProjectGeopackage", "parameters": [ { "name": "projectKey", "in": "path", "description": "Project key to filter by.", "example": "environment~weather", "required": true, "schema": { "type": "string" } } ], "responses": { "200": { "description": "successful operation", "content": { "application/geopackage+vnd.sqlite3": { "schema": { "type": "string", "format": "binary" } } } }, "400": { "description": "Invalid indicator value", "content": {} }, "401": { "$ref": "#/components/responses/UnauthorizedError" } } } }, "/project/{projectKey}/indicator/{indicatorCode}": { "get": { "tags": [ "indicator" ], "summary": "Get indicator by code", "description": "Returns a single indicator", "operationId": "getIndicatorByCode", "parameters": [ { "name": "projectKey", "in": "path", "description": "Project key to filter by.", "example": "environment~weather", "required": true, "schema": { "type": "string" } }, { "name": "indicatorCode", "in": "path", "description": "Code of indicator to return", "required": true, "schema": { "type": "string" }, "example": "weather_status" } ], "responses": { "200": { "description": "successful operation", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Indicator" } } } }, "400": { "description": "Invalid code supplied", "content": {} }, "401": { "$ref": "#/components/responses/UnauthorizedError" }, "404": { "description": "Indicator not found", "content": {} } } } }, "/project/{projectKey}/indicator/{indicatorCode}/document/{documentUuid}": { "get": { "tags": [ "indicator" ], "summary": "Get an indicator document by its UUID", "description": "Returns a single indicator document", "operationId": "getIndicatorDocumentByUuid", "parameters": [ { "name": "projectKey", "in": "path", "description": "Project key to filter by.", "example": "environment~weather", "required": true, "schema": { "type": "string" } }, { "name": "indicatorCode", "in": "path", "description": "Code of indicator to return", "required": true, "schema": { "type": "string" }, "example": "weather_status" }, { "name": "documentUuid", "in": "path", "description": "UUID of indicator document to return", "required": true, "schema": { "type": "string" }, "example": "1a7f7323-6b18-46ed-a9fe-9efbe1f006a2" } ], "responses": { "200": { "description": "successful operation", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/IndicatorDocument" } } } }, "400": { "description": "Invalid code supplied", "content": {} }, "401": { "$ref": "#/components/responses/UnauthorizedError" }, "404": { "description": "Indicator document not found", "content": {} } } } }, "/project/{projectKey}/indicator/{indicatorCode}/observations": { "get": { "tags": [ "indicator" ], "summary": "Get observations by indicator", "description": "Indicator code must be given in the path. For synchronization purpose, last synchronization timestamp and request timestamp must be passed in header.", "operationId": "getObservationsByIndicator", "parameters": [ { "name": "projectKey", "in": "path", "description": "Project key to filter by.", "example": "environment~weather", "required": true, "schema": { "type": "string" } }, { "name": "indicatorCode", "in": "path", "description": "Indicator code to filter by", "required": true, "schema": { "type": "string", "example": "weather_status" } }, { "name": "lastSyncDate", "in": "header", "description": "Last synchronisation date", "example": "2020-01-31 20:10:30", "required": true, "schema": { "type": "string", "format": "date-type" } }, { "name": "requestSyncDate", "in": "header", "description": "Request synchronisation date", "example": "2020-02-15 10:40:30", "required": true, "schema": { "type": "string", "format": "date-type" } } ], "responses": { "200": { "description": "successful operation", "content": { "application/json": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/Observation" } } } } }, "400": { "description": "Invalid code supplied", "content": {} }, "401": { "$ref": "#/components/responses/UnauthorizedError" }, "404": { "description": "Indicator not found", "content": {} } } } }, "/project/{projectKey}/indicator/{indicatorCode}/deletedObservations": { "get": { "tags": [ "indicator" ], "summary": "Get deleted observations by indicator since last synchronization", "description": "Indicator code must be given in the path. For synchronization purpose, last synchronization timestamp and request timestamp must be passed in header.", "operationId": "getDeletedObservationsByIndicator", "parameters": [ { "name": "projectKey", "in": "path", "description": "Project key to filter by.", "example": "environment~weather", "required": true, "schema": { "type": "string" } }, { "name": "indicatorCode", "in": "path", "description": "Indicator code to filter by", "required": true, "schema": { "type": "string", "example": "weather_status" } }, { "name": "lastSyncDate", "in": "header", "description": "Last synchronisation date", "example": "2020-01-31 20:10:30", "required": true, "schema": { "type": "string", "format": "date-type" } }, { "name": "requestSyncDate", "in": "header", "description": "Request synchronisation date", "example": "2020-02-15 10:40:30", "required": true, "schema": { "type": "string", "format": "date-type" } } ], "responses": { "200": { "description": "successful operation", "content": { "application/json": { "schema": { "type": "array", "description": "Array of UUID of the deleted observation", "items": { "type": "string", "example": "e715352e-edb0-553e-2c69-09b6dc768ea7" } } } } }, "400": { "description": "Invalid code supplied", "content": {} }, "401": { "$ref": "#/components/responses/UnauthorizedError" }, "404": { "description": "Indicator not found", "content": {} } } } }, "/project/{projectKey}/indicator/{indicatorCode}/observation": { "post": { "tags": [ "observation" ], "summary": "Create a new observation", "operationId": "createObservation", "parameters": [ { "name": "projectKey", "in": "path", "description": "Project key to filter by.", "example": "environment~weather", "required": true, "schema": { "type": "string" } }, { "name": "indicatorCode", "in": "path", "description": "Code of indicator to return", "required": true, "schema": { "type": "string" }, "example": "weather_status" }, { "name": "requestSyncDate", "in": "query", "description": "Request synchronisation date", "example": "2020-02-15 10:40:30", "required": true, "schema": { "type": "string", "format": "date-type" } } ], "requestBody": { "description": "Observation object that needs to be added", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Observation" } } }, "required": true }, "responses": { "200": { "description": "created observation", "content": { "application/json": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/Observation" } } } } }, "401": { "$ref": "#/components/responses/UnauthorizedError" }, "405": { "description": "Invalid input", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApiResponse" } } } } }, "x-codegen-request-body-name": "body" }, "put": { "tags": [ "observation" ], "summary": "Update an existing observation", "operationId": "updateObservation", "parameters": [ { "name": "projectKey", "in": "path", "description": "Project key to filter by.", "example": "environment~weather", "required": true, "schema": { "type": "string" } }, { "name": "indicatorCode", "in": "path", "description": "Code of indicator to return", "required": true, "schema": { "type": "string" }, "example": "weather_status" }, { "name": "requestSyncDate", "in": "header", "description": "Request synchronisation date", "example": "2020-02-15 10:40:30", "required": true, "schema": { "type": "string", "format": "date-type" } } ], "requestBody": { "description": "Observation object that needs to be modified", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Observation" } } }, "required": true }, "responses": { "200": { "description": "updated observation", "content": { "application/json": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/Observation" } } } } }, "400": { "description": "Invalid ID supplied", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApiResponse" } } } }, "401": { "$ref": "#/components/responses/UnauthorizedError" }, "404": { "description": "Observation not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApiResponse" } } } }, "405": { "description": "Validation exception", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApiResponse" } } } } }, "x-codegen-request-body-name": "body" } }, "/project/{projectKey}/indicator/{indicatorCode}/observation/{observationId}": { "get": { "tags": [ "observation" ], "summary": "Get an observation by ID", "description": "Returns a single observation", "operationId": "getObservationById", "parameters": [ { "name": "projectKey", "in": "path", "description": "Project key to filter by.", "example": "environment~weather", "required": true, "schema": { "type": "string" } }, { "name": "indicatorCode", "in": "path", "description": "Code of indicator to return", "required": true, "schema": { "type": "string" }, "example": "weather_status" }, { "name": "observationId", "in": "path", "description": "UID of the observation", "required": true, "schema": { "type": "string", "description": "Unique identifier in format UUID", "example": "e715352e-edb0-553e-2c69-09b6dc768ea7" } }, { "name": "lastSyncDate", "in": "header", "description": "Last synchronisation date", "example": "2020-01-31 20:10:30", "required": true, "schema": { "type": "string", "format": "date-type" } }, { "name": "requestSyncDate", "in": "header", "description": "Request synchronisation date", "example": "2020-02-15 10:40:30", "required": true, "schema": { "type": "string", "format": "date-type" } } ], "responses": { "200": { "description": "successful operation", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Observation" } } } }, "400": { "description": "Invalid ID supplied", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApiResponse" } } } }, "401": { "$ref": "#/components/responses/UnauthorizedError" }, "404": { "description": "Observation not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApiResponse" } } } } } }, "delete": { "tags": [ "observation" ], "summary": "Deletes an observation", "operationId": "deleteObservationById", "parameters": [ { "name": "projectKey", "in": "path", "description": "Project key to filter by.", "example": "environment~weather", "required": true, "schema": { "type": "string" } }, { "name": "indicatorCode", "in": "path", "description": "Code of indicator to return", "required": true, "schema": { "type": "string" }, "example": "weather_status" }, { "name": "observationId", "in": "path", "description": "UID of the observation", "required": true, "schema": { "type": "string", "description": "Unique identifier in format UUID", "example": "e715352e-edb0-553e-2c69-09b6dc768ea7" } }, { "name": "requestSyncDate", "in": "header", "description": "Request synchronisation date", "example": "2020-02-15 10:40:30", "required": true, "schema": { "type": "string", "format": "date-type" } } ], "responses": { "200": { "description": "successful operation", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApiResponse" } } } }, "400": { "description": "Invalid ID supplied", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApiResponse" } } } }, "401": { "$ref": "#/components/responses/UnauthorizedError" }, "404": { "description": "Observation not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApiResponse" } } } } } } }, "/project/{projectKey}/indicator/{indicatorCode}/observation/{observationId}/uploadMedia": { "post": { "tags": [ "observation" ], "summary": "uploads a media for the chosen observation", "operationId": "uploadObservationMedia", "parameters": [ { "name": "projectKey", "in": "path", "description": "Project key to filter by.", "example": "environment~weather", "required": true, "schema": { "type": "string" } }, { "name": "indicatorCode", "in": "path", "description": "Code of indicator to return", "required": true, "schema": { "type": "string" }, "example": "weather_status" }, { "name": "observationId", "in": "path", "description": "UID of the observation", "required": true, "schema": { "type": "string", "description": "Unique identifier in format UUID", "example": "e715352e-edb0-553e-2c69-09b6dc768ea7" } }, { "name": "requestSyncDate", "in": "header", "description": "Request synchronisation date", "example": "2020-02-15 10:40:30", "required": true, "schema": { "type": "string", "format": "date-type" } } ], "requestBody": { "content": { "multipart/form-data": { "schema": { "type": "object", "properties": { "mediaFile": { "type": "string", "format": "binary" } } } } } }, "responses": { "200": { "description": "successful operation", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApiResponse" } } } }, "400": { "description": "An error occured while uploading the observation media", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApiResponse" } } } }, "401": { "$ref": "#/components/responses/UnauthorizedError" }, "404": { "description": "Observation not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApiResponse" } } } } } } }, "/project/{projectKey}/indicator/{indicatorCode}/observation/{observationId}/deleteMedia": { "delete": { "tags": [ "observation" ], "summary": "delete the media of the chosen observation", "operationId": "deleteObservationMedia", "parameters": [ { "name": "projectKey", "in": "path", "description": "Project key to filter by.", "example": "environment~weather", "required": true, "schema": { "type": "string" } }, { "name": "indicatorCode", "in": "path", "description": "Code of indicator to return", "required": true, "schema": { "type": "string" }, "example": "weather_status" }, { "name": "observationId", "in": "path", "description": "UID of the observation", "required": true, "schema": { "type": "string", "description": "Unique identifier in format UUID", "example": "e715352e-edb0-553e-2c69-09b6dc768ea7" } }, { "name": "requestSyncDate", "in": "header", "description": "Request synchronisation date", "example": "2020-02-15 10:40:30", "required": true, "schema": { "type": "string", "format": "date-type" } } ], "responses": { "200": { "description": "successful operation", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApiResponse" } } } }, "400": { "description": "An error occured while deleting the observation media", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApiResponse" } } } }, "401": { "$ref": "#/components/responses/UnauthorizedError" }, "404": { "description": "Observation not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ApiResponse" } } } } } } } } }