{ "openapi": "3.1.0", "info": { "version": "1.0.0", "title": "Navixy IoT Logic API", "summary": "API calls for Flow and Node management", "description": "This is an API reference for calls for Flow and Node management\n\n> **BETA Version!** \n> Now the early access of IoT Logic's API is implemented, which means possible changes in the near future. Feel free to try the functionality, however, you may need to introduce changes in your applications reflecting the API functionality updates. Stay tuned!", "contact": { "name": "Navixy support", "email": "support@navixy.com", "url": "https://www.navixy.com/contact/" }, "license": { "name": "Apache 2.0", "identifier": "Apache-2.0" } }, "servers": [ { "url": "https://api.eu.navixy.com/v2", "description": "Navixy production server on European platform" }, { "url": "https://api.us.navixy.com/v2", "description": "Navixy production server on American platform" } ], "tags": [ { "name": "Flow", "description": "Operations for managing data flows" }, { "name": "Node", "description": "Operations for managing flow nodes (endpoints)" } ], "paths": { "/iot/logic/flow/create": { "post": { "tags": ["Flow"], "summary": "flowCreate", "description": "Create a new data flow.", "operationId": "flowCreate", "requestBody": { "content": { "application/json": { "schema": { "type": "object", "properties": { "flow": { "$ref": "#/components/schemas/FlowDraft" } } } } } }, "responses": { "200": { "$ref": "#/components/responses/EntityCreatedResponse" }, "default": { "$ref": "#/components/responses/ResponseError" } }, "security": [ { "api_key": [] } ] } }, "/iot/logic/flow/read": { "get": { "tags": ["Flow"], "summary": "flowRead", "description": "Read an existing flow details.", "operationId": "flowRead", "parameters": [ { "name": "flow_id", "in": "query", "required": true, "schema": { "type": "integer", "description": "Flow ID", "example": 12 } } ], "responses": { "200": { "description": "Successful response to read a flow", "content": { "application/json": { "schema": { "type": "object", "properties": { "success": { "type": "boolean", "description": "`true` if request finished successfully.", "readOnly": true, "example": true }, "value": { "$ref": "#/components/schemas/Flow" } } } } } }, "default": { "$ref": "#/components/responses/ResponseError" } }, "security": [ { "api_key": [] } ] } }, "/iot/logic/flow/update": { "post": { "tags": ["Flow"], "summary": "flowUpdate", "description": "Update details of an existing flow.", "operationId": "flowUpdate", "requestBody": { "content": { "application/json": { "schema": { "type": "object", "properties": { "flow": { "$ref": "#/components/schemas/Flow" } }, "required": [ "flow" ] } } } }, "responses": { "200": { "$ref": "#/components/responses/OK" }, "default": { "$ref": "#/components/responses/ResponseError" } }, "security": [ { "api_key": [] } ] } }, "/iot/logic/flow/delete": { "post": { "tags": ["Flow"], "summary": "flowDelete", "description": "Delete a flow.", "operationId": "flowDelete", "requestBody": { "content": { "application/json": { "schema": { "type": "object", "properties": { "flow_id": { "type": "integer", "description": "Flow ID", "example": 12 } }, "required": [ "flow_id" ] } } } }, "responses": { "200": { "description": "Successful response to delete a flow", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Success" } } } }, "default": { "$ref": "#/components/responses/ResponseError" } }, "security": [ { "api_key": [] } ] } }, "/iot/logic/flow/list": { "get": { "tags": ["Flow"], "summary": "flowList", "description": "Get list of flows existing in a user account.", "operationId": "flowList", "responses": { "200": { "description": "Successful response to read a list of flows", "content": { "application/json": { "schema": { "type": "object", "properties": { "success": { "type": "boolean", "description": "`true` if request finished successfully", "readOnly": true, "example": true }, "list": { "type": "array", "description": "List of user's flows", "readOnly": true, "items": { "type": "object", "properties": { "id": { "type": "integer", "description": "Flow ID", "readOnly": true, "example": 1234 }, "title": { "type": "string", "description": "Flow name", "readOnly": true, "example": "Super flow" } }, "readOnly": true } } } } } } }, "default": { "$ref": "#/components/responses/ResponseError" } }, "security": [ { "api_key": [] } ] } }, "/iot/logic/flow/endpoint/create": { "post": { "tags": ["Node"], "summary": "endpointCreate", "description": "Create a new node.\n\nAll node types are created through this endpoint, the type is defined in the request body.", "operationId": "endpointCreate", "requestBody": { "content": { "application/json": { "schema": { "type": "object", "properties": { "endpoint": { "$ref": "#/components/schemas/IotEndpointDraft" } }, "required": [ "endpoint" ] } } } }, "responses": { "200": { "$ref": "#/components/responses/EntityCreatedResponse" }, "default": { "$ref": "#/components/responses/ResponseError" } }, "security": [ { "api_key": [] } ] } }, "/iot/logic/flow/endpoint/read": { "post": { "tags": ["Node"], "summary": "endpointRead", "description": "Read an existing node details.", "operationId": "endpointRead", "requestBody": { "content": { "application/json": { "schema": { "type": "object", "properties": { "endpoint_id": { "type": "integer", "description": "Endpoint ID in database", "example": 1723 } }, "required": [ "endpoint_id" ] } } } }, "responses": { "200": { "description": "Successful response to read endpoint", "content": { "application/json": { "schema": { "type": "object", "properties": { "success": { "type": "boolean", "description": "`true` if request finished successfully", "readOnly": true, "example": true }, "value": { "$ref": "#/components/schemas/IotEndpoint" } } } } } }, "default": { "$ref": "#/components/responses/ResponseError" } }, "security": [ { "api_key": [] } ] } }, "/iot/logic/flow/endpoint/update": { "post": { "tags": ["Node"], "summary": "endpointUpdate", "description": "Update an existing node details.", "operationId": "endpointUpdate", "requestBody": { "content": { "application/json": { "schema": { "type": "object", "properties": { "endpoint": { "$ref": "#/components/schemas/IotEndpoint" } }, "required": [ "endpoint" ] } } } }, "responses": { "200": { "$ref": "#/components/responses/OK" }, "default": { "$ref": "#/components/responses/ResponseError" } }, "security": [ { "api_key": [] } ] } }, "/iot/logic/flow/endpoint/delete": { "post": { "tags": ["Node"], "summary": "endpointDelete", "description": "Delete a node.", "operationId": "endpointDelete", "requestBody": { "content": { "application/json": { "schema": { "type": "object", "properties": { "endpoint_id": { "type": "integer", "description": "Endpoint ID in database", "example": 1723 } }, "required": [ "endpoint_id" ] } } } }, "responses": { "200": { "$ref": "#/components/responses/OK" }, "default": { "$ref": "#/components/responses/ResponseError" } }, "security": [ { "api_key": [] } ] } }, "/iot/logic/flow/endpoint/list": { "post": { "tags": ["Node"], "summary": "endpointList", "description": "Get list of nodes existing in a user account.", "operationId": "endpointList", "requestBody": { "content": { "application/json": { "schema": { "type": "object" } } } }, "responses": { "200": { "description": "Successful response to read a list of endpoints", "content": { "application/json": { "schema": { "type": "object", "properties": { "success": { "type": "boolean", "description": "`true` if request finished successfully", "readOnly": true, "example": true }, "list": { "type": "array", "description": "List of user's endpoints", "readOnly": true, "items": { "$ref": "#/components/schemas/IotEndpoint" } } } } } } }, "default": { "$ref": "#/components/responses/ResponseError" } }, "security": [ { "api_key": [] } ] } } }, "externalDocs": { "url": "https://developers.navixy.com/", "description": "Find more info here" }, "components": { "securitySchemes": { "api_key": { "type": "apiKey", "description": "Enter an API key with the \"NVX: \" prefix, e.g. \"NVX 123456abcdefg\"", "name": "Authorization", "in": "header" } }, "responses": { "OK": { "description": "Successful response", "content": { "application/json": { "schema": { "type": "object", "properties": { "success": { "type": "boolean", "description": "`true` if request finished successfully.", "readOnly": true, "example": true } } } } } }, "EntityCreatedResponse": { "description": "Successful creation response", "content": { "application/json": { "schema": { "type": "object", "properties": { "success": { "type": "boolean", "description": "`true` if request finished successfully", "readOnly": true, "example": true }, "id": { "type": "integer", "description": "ID of the created entity", "readOnly": true, "example": 1723 } } } } } }, "ResponseError": { "description": "Error response object", "content": { "application/json": { "schema": { "type": "object", "properties": { "success": { "type": "boolean", "description": "Always false.", "example": false }, "status": { "type": "object", "description": "Error status. It only presence when an error occurred.", "properties": { "code": { "type": "integer", "description": "An error code in this API (not a HTTP code)", "example": 1 }, "description": { "type": "string", "description": "An error description", "example": "Database error" } } } } } } } } }, "schemas": { "Success": { "type": "object", "properties": { "success": { "type": "boolean", "description": "`true` if request finished successfully, otherwise `false`", "readOnly": true, "example": true } } }, "FlowId": { "type": "object", "required": [ "id" ], "properties": { "id": { "type": "integer", "description": "Flow ID", "example": 543, "readOnly": true } } }, "FlowDraft": { "type": "object", "description": "Flowchart object without ID", "properties": { "title": { "type": "string", "description": "Flow name", "example": "Super flow" }, "description": { "type": ["string", "null"], "description": "Flow description (optional)", "readOnly": true, "example": null }, "enabled": { "type": "boolean", "description": "Enable/disable flag", "example": true }, "default_flow": { "type": "boolean", "description": "Whether this is the default flow", "readOnly": true, "example": false }, "nodes": { "type": "array", "items": { "$ref": "#/components/schemas/Node" } }, "edges": { "type": "array", "items": { "$ref": "#/components/schemas/Edge" } } }, "required": [ "title" ] }, "Flow": { "type": "object", "description": "Flowchart object", "allOf": [ { "$ref": "#/components/schemas/FlowId" }, { "$ref": "#/components/schemas/FlowDraft" } ] }, "Edge": { "type": "object", "description": "Edge between two Nodes", "properties": { "from": { "type": "integer", "example": 1 }, "to": { "type": "integer", "example": 2 }, "type": { "description": "Edge type, optional, if not specified it is `simple_edge`", "$ref": "#/components/schemas/EdgeType" } }, "required": [ "from", "to" ] }, "EdgeType": { "type": "string", "enum": ["simple_edge", "then_edge", "else_edge"], "example": "simple_edge" }, "Node": { "type": "object", "description": "Flowchart Node", "oneOf": [ { "$ref": "#/components/schemas/NodeDataSource" }, { "$ref": "#/components/schemas/NodeInitiateAttributes" }, { "$ref": "#/components/schemas/NodeLogic" }, { "$ref": "#/components/schemas/NodeAction" }, { "$ref": "#/components/schemas/NodeOutputEndpoint" } ] }, "NodeID": { "type": "integer", "description": "Node ID inside current flow", "example": 1 }, "NodeView": { "type": "object", "description": "Flowchart Node view properties", "properties": { "position": { "type": "object", "description": "Position of the left top corner", "properties": { "x": { "type": "integer", "example": 25 }, "y": { "type": "integer", "example": 25 } } } } }, "NodeDataSource": { "type": "object", "description": "Node: Data Source", "properties": { "id": { "$ref": "#/components/schemas/NodeID" }, "type": { "type": "string", "description": "Node type. Always \"data_source\".", "example": "data_source" }, "data": { "type": "object", "properties": { "title": { "type": "string", "example": "Standard Data Source" }, "source_ids": { "type": ["array", "null"], "items": { "type": "integer", "description": "Source ID", "example": 123458 }, "description": "Array of device/source IDs. Use null or empty array [] for all sources. Note: API normalizes null to empty array [] in responses.", "example": [123458, 123459] } } }, "view": { "$ref": "#/components/schemas/NodeView" } }, "required": [ "type", "data" ] }, "NodeInitiateAttributes": { "type": "object", "description": "Node: initiate attributes", "properties": { "id": { "$ref": "#/components/schemas/NodeID" }, "type": { "type": "string", "description": "Node type. Always \"initiate_attributes\".", "example": "initiate_attributes" }, "data": { "type": "object", "properties": { "title": { "type": "string", "example": "Add/modify attributes" }, "items": { "type": "array", "items": { "type": "object", "properties": { "name": { "type": "string", "description": "Attribute name", "example": "fuel_tank_2" }, "value": { "type": "string", "description": "Expression to calculate the attribute value", "example": "(analog_1 + 100)/2" }, "generation_time": { "type": ["string", "null"], "description": "Expression for generation timestamp, or null for default (now())", "example": "genTime(\"temperature\", 0, \"valid\")" }, "server_time": { "type": ["string", "null"], "description": "Expression for server timestamp, or null for default (now())", "example": "now()" } }, "required": ["name", "value"] } } } }, "view": { "$ref": "#/components/schemas/NodeView" } }, "required": [ "type", "data" ] }, "NodeLogic": { "type": "object", "description": "Node: logic", "properties": { "id": { "$ref": "#/components/schemas/NodeID" }, "type": { "type": "string", "description": "Node type. Always \"logic\".", "example": "logic" }, "data": { "type": "object", "properties": { "title": { "type": "string", "example": "New logic node" }, "name": { "type": "string", "description": "Internal identifier for the logic node", "example": "logic_1" }, "condition": { "type": "string", "description": "Boolean expression to evaluate", "example": "!driver_identified && (vibration_active || speed > 3)" } }, "required": [ "title", "name", "condition" ] }, "view": { "$ref": "#/components/schemas/NodeView" } }, "required": [ "type", "data" ] }, "NodeAction": { "description": "Node: Action", "type": "object", "required": [ "type", "data" ], "properties": { "id": { "$ref": "#/components/schemas/NodeID" }, "type": { "type": "string", "description": "Node type. Always \"action\".", "example": "action" }, "data": { "type": "object", "properties": { "title": { "type": "string", "example": "Actions" }, "actions": { "type": ["array", "null"], "items": { "oneOf": [ { "$ref": "#/components/schemas/SetOutput" }, { "$ref": "#/components/schemas/SendCommand" } ] }, "maxItems": 10, "uniqueItems": true } } }, "view": { "$ref": "#/components/schemas/NodeView" } } }, "SetOutput": { "type": "object", "required": ["type", "number", "value"], "properties": { "type": { "type": "string", "enum": ["set_output"], "description": "Action type. Must be 'set_output'." }, "number": { "type": "integer", "minimum": 1, "maximum": 8, "description": "Output number as seen in UI." }, "value": { "type": "boolean", "description": "The state to set to." } } }, "SendCommand": { "type": "object", "required": ["type", "command"], "properties": { "type": { "type": "string", "enum": ["send_gprs_command"], "description": "Action type. Must be 'send_gprs_command'." }, "command": { "type": "string", "minLength": 1, "maxLength": 512, "description": "A custom command to send to the device. Consult its documentation for details." }, "reliable": { "type": ["boolean", "null"], "default": true, "description": "Reliable commands will be retried in case if a tracker is not online at the moment." } } }, "NodeOutputEndpoint": { "type": "object", "description": "Node: output endpoint. This is the terminating node for any flow. It determines where the messages will be sent.", "properties": { "id": { "$ref": "#/components/schemas/NodeID" }, "type": { "type": "string", "description": "Node type. Always \"output_endpoint\".", "example": "output_endpoint" }, "data": { "type": "object", "oneOf": [ { "$ref": "#/components/schemas/NodeOutputEndpointDataDefault" }, { "$ref": "#/components/schemas/NodeOutputEndpointDataStoredEndpoint" } ] }, "view": { "$ref": "#/components/schemas/NodeView" } }, "required": [ "type", "data" ] }, "NodeOutputEndpointDataDefault": { "type": "object", "description": "Data of default output endpoint (Navixy platform)", "properties": { "title": { "type": "string", "example": "Navixy output endpoint" }, "output_endpoint_type": { "type": "string", "description": "Type of endpoint. Always 'output_default' for Navixy platform.", "example": "output_default" } }, "required": [ "title", "output_endpoint_type" ] }, "NodeOutputEndpointDataStoredEndpoint": { "type": "object", "description": "Data of MQTT output endpoint", "properties": { "title": { "type": "string", "example": "MQTT output endpoint" }, "output_endpoint_type": { "type": "string", "description": "Type of endpoint. Always 'output_mqtt_client'.", "example": "output_mqtt_client" }, "output_endpoint_id": { "type": "integer", "description": "Output Endpoint identifier within the user account. It is required for only some types of node (e.g. output_mqtt_client) which has specific properties.", "example": 44551 } }, "required": [ "title", "output_endpoint_type", "output_endpoint_id" ] }, "IotEndpoint": { "type": "object", "description": "Input or output endpoint", "allOf": [ { "type": "object", "properties": { "id": { "type": "integer", "description": "Endpoint ID inside user account", "example": 12345, "readOnly": true } }, "required": [ "id" ] }, { "$ref": "#/components/schemas/IotEndpointDraft" } ] }, "IotEndpointDraft": { "type": "object", "description": "Input or output endpoint draft (for creation)", "properties": { "user_id": { "type": "integer", "description": "Master user ID", "example": 8 }, "type": { "type": "string", "description": "Endpoint type. One of: 'input_navixy', 'output_navixy', 'output_mqtt_client'.", "example": "output_mqtt_client" }, "title": { "type": "string", "example": "MQTT Endpoint Client Properties" }, "status": { "type": "string", "description": "Endpoint status. One of: 'active', 'suspend', 'disabled'." }, "properties": { "type": "object", "oneOf": [ { "$ref": "#/components/schemas/IotEndpointMqttClientProperties" }, { "type": "object", "description": "Navixy endpoint - empty object (no properties)", "properties": {} } ] } }, "required": [ "type", "title", "status" ] }, "IotEndpointMqttClientProperties": { "type": "object", "description": "MQTT client endpoint", "properties": { "protocol": { "type": "string", "description": "Protocol of messages: \"NGP\" (Navixy Generic Protocol)", "example": "NGP" }, "domain": { "type": "string", "description": "MQTT domain or IP address", "example": "127.0.0.1" }, "port": { "type": "integer", "description": "MQTT port", "example": 1883 }, "client_id": { "type": "string", "description": "MQTT client ID", "example": "Navixy (panel #123)" }, "qos": { "type": "integer", "description": "MQTT QoS: 0 or 1 (2 is unsupported at the moment)", "example": 1 }, "topics": { "type": "array", "items": { "type": "string", "description": "MQTT topic name", "example": "iot/navixy" } }, "version": { "type": "string", "description": "MQTT version: \"3.1.1\" or \"5.0\"", "example": "5.0" }, "use_ssl": { "type": "boolean", "description": "Use or not SSL encryption for MQTT connection", "example": false }, "mqtt_auth": { "type": "boolean", "description": "Use or not MQTT authentication", "example": true }, "user_name": { "type": "string", "description": "MQTT user name", "example": "navixy" }, "user_password": { "type": "string", "description": "MQTT password", "example": "your_super_strong_password" } }, "required": [ "protocol", "domain", "port", "client_id", "qos", "topics", "version", "use_ssl", "mqtt_auth" ] } } }, "security": [ { "api_key": [] } ] }