Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The best way to visualize and interact with the API is through Swagger.

Using Swagger Editor on the web

With Swagger Editor, you can view and edit the OpenAPI document inside your browser, while previewing the documentation in real time.

Visit https://editor-next.swagger.io/ and select File → Import file, or drag-and-drop the openapi.json file into the browser window.

You can then view and make edits to the OpenAPI document in the left panel (in YAML format) and visualize the UI in the right panel, or simply drag the divider all the way to the left if you are only interested in the UI.

Info

Note: This method will allow you to view the documentation in Swagger UI, but you will only be able to interact with the API if it can be accessed from a public URL/IP address. In that case, replace http://localhost:5000/ in the url field with the correct address. Otherwise, you will need to install locally (see below) on the system that is running the Django backend in order to issue API calls through Swagger UI.

Starting with Open API version 3.1.0, a new Swagger Editor was release (this is the linked version above)

Legacy Open API Swagger Editor which supports versions 3.0.X can be accessed by visiting https://editor.swagger.io/

Installing Swagger Editor locally

Swagger Editor can also be installed locally with https://github.com/swagger-api/swagger-editor, or by cloning the repository.

...

Then open index.html and import openapi.json.

You can then make edits to the OpenAPI document in the left panel (in YAML format) and visualize the UI in the right panel.

...

or drag-and-drop into the browser window.

Using Swagger UI standalone

If you do not need to view or edit the OpenAPI document, you can simply also use a standalone version of Swagger UI.

The tool https://github.com/vajahath/open-swagger-ui will allow you to open a local openapi.json file in the Swagger UI.

It requires Node.js >=10 and can be installed via npm:

Code Block
npm i -g open-swagger-ui

Then, change to make sure you are in the directory containing openapi.json (or point the command to where it is located) and run:

Code Block
open-swagger-ui .\openapi.json --open

...

In order to use the API, you will need to provide an authorization token.

When making an API call, use -H 'Authorization: Token 123abc', replacing 123abc with your token.

If you are using Swagger UI, click on the ‘Authorize’ button and use value Token 123abc, replacing 123abc with your token.

You can generate an authentication token from your username and password with a

Status
colourGreen
titlePOST
/accounts/api-token-auth/ call, with the following request body:

Code Block
languagejson
{
  "username": "user123",
  "password": "pw123"
}

If you fail to authenticate, any API calls (except for /accounts/api-token-auth/) will return an error code 401.

When making an API call, use -H 'Authorization: Token 123abc', replacing 123abc with your token.

If you are using Swagger UI, click on the ‘Authorize’ button and use value Token 123abc, replacing 123abc with your token.

If you are using something like Postman, click on Headers and add these, replacing 123abc with your token.

...

Error Codes

The API uses conventional HTTP response codes to indicate the success or failure of an API request.

...

All API calls will generate a response in the format below:

Code Block
languagejson
{
  "requestId": null,
  "result": "",
  "error": null
}
  • requestId contains a unique identifier for each request.

    • You can view the contents of a specific request with

      Status
      colourBlue
      titleGET
      ​/api​/request​/{requestId}​/ .

  • result contains the result of the request.

  • error contains an error code and description if the request failed on the backend. (

    • Note: The API call, itself, will still be successful and return code 200

    )
    • .

Endpoints

All API endpoints are listed below, along with a brief description for each. More detail on usage and expected results can be found in the OpenAPI document or viewed through the Swagger UI.

...

Expand
titleGeneral high-level API calls (api)
  • Status
    colourBlue
    titleGET
    ​/api​/folder​/{folderId}​/tree​/ Return a tree containing all children of the specified folder

  • Status
    colourBlue
    titleGET
    ​/api​/request​/{requestId}​/ Return the contents of the specified request

  • Status
    colourBlue
    titleGET
    /api​/status​/ Report the status of the API backend, including mode

  • Status
    colourBlue
    titleGET
    /api​/tree​/ Return the highest level tree for this install

  • Status
    colourBlue
    titleGET
    ​/api​/{entity}​/allconfig​/ Return a full listing of an entity type (nodes, apps, objects)

  • Status
    colourBlue
    titleGET
    ​/api​/{entity}​/allconfig​fromtypes/ Return a full listing of an entity type (nodes, apps, objects)

  • Status
    colourBlue
    titleGET
    ​/api​/{schemaId}​/schema​/ Return the schema file for the specified schema ID

  • Status
    colourBlue
    titleGET
    ​/api​/itemTypes Return list of schema item types

  • Status
    colourBlue
    titleGET
    ​/api​​/schema​/ Return the schema files for the specified schema IDs

  • Status
    colourGreen
    titlePOST
    /api​/{category}/{itemId}/move/ Move node or folder to new location

  • Status
    colourGreen
    titlePOST
    /api​/folder/add/ Add new folder

  • Status
    colourBlue
    titleGET
    ​/api​/folder/{folderId}/view/ Get folder properties

  • Status
    colourGreen
    titlePOST
    /api​/folder/{folderId}/delete/Delete folder

  • Status
    colourBlue
    titleGET
    ​/api​/folder/{folderId}/config/ Get folder configurations

  • Status
    colourGreen
    titlePOST
    /api​/folder/{folderId}/config/Adjust the settings of the specified node

Expand
titleOperations on a specified node (api_node)
  • Status
    colourBlue
    titleGET
    ​/api​/{nodeId}​/apps​/ Return a list of all apps under the specified node

  • Status
    colourGreen
    titlePOST
    /api​/{nodeId}​/command​/ Send a command to the specified node

  • Status
    colourBlue
    titleGET
    ​/api​/{nodeId}​/config​/ Return the settings for the specified node

  • Status
    colourGreen
    titlePOST
    ​/api​/{nodeId}​/config​/ Adjust the settings for the specified node

  • Status
    colourGreen
    titlePOST
    ​/api​/{nodeId}​/delete​/ Delete the specified node from the remote manager database

  • Status
    colourBlue
    titleGET
    /api​/{nodeId}​/export​/ Full recursive export for the specified node

  • Status
    colourGreen
    titlePOST
    /api​/{nodeId}​/import​/ Full recursive import for the specified node

  • Status
    colourGreen
    titlePOST
    /api​/{nodeId}​/sync​/ Sync the specified node to the remote manager

  • Status
    colourBlue
    titleGET
    /api​/{nodeId}​/tree​/ Return the highest level tree for the specified node

  • Status
    colourBlue
    titleGET
    /api​/{nodeId}​/view​/ Return the schema and settings for the specified node

  • Status
    colourBlue
    titleGET
    /api​/{nodeId}​/defaults​/ Return node defaults configurations

Expand
titleOperations on a specified app (api_app)
  • Status
    colourGreen
    titlePOST
    ​/api​/{nodeId}​/{appId}​/command​/ Send a command to the specified app

  • Status
    colourBlue
    titleGET
    /api​/{nodeId}​/{appId}​/config​/ Return the settings for the specified app

  • Status
    colourGreen
    titlePOST
    /api​/{nodeId}​/{appId}​/config​/ Adjust the settings for the specified app

  • Status
    colourBlue
    titleGET
    /api​/{nodeId}​/{appId}​/export​/ Full recursive export for the specified app

  • Status
    colourGreen
    titlePOST
    /api​/{nodeId}​/{appId}​/import​/ Full recursive import for the specified app

  • Status
    colourGreen
    titlePOST
    /api​/{nodeId}​/{appId}​/license​/ Set the license for the specified app

  • Status
    colourGreen
    titlePOST
    /api​/{nodeId}​/{appId}​/licenserequest​/ Request a license for the specified app

  • Status
    colourBlue
    titleGET
    ​/api​/{nodeId}​/{appId}​/models​/ List all models that can be added in the specified app

  • Status
    colourBlue
    titleGET
    ​/api​/{nodeId}​/{appId}​/tree​/ Return the highest level tree for the specified app

  • Status
    colourBlue
    titleGET
    ​/api​/{nodeId}​/{appId}​/view​/ Return the schema and settings for the specified app

  • Status
    colourBlue
    titleGET
    ​/api​/{appId}​/{schemaId}​/get_metadata​/ Return metadata properties associated with the schema for the specified app

  • Status
    colourBlue
    titleGET
    ​​/api​/{appId}​/{schemaId}​/metadata_schema​/ Return schema injected with the properties for the specified app

Expand
titleOperations on a specified object (api_object)
  • Status
    colourBlue
    titleGET
    /api​/{nodeId}​/{appId}​/{objectId}​/children​/ List the direct children of the specified object

  • Status
    colourGreen
    titlePOST
    /api​/{nodeId}​/{appId}​/{objectId}​/command​/ Send a command to the specified object

  • Status
    colourBlue
    titleGET
    /api​/{nodeId}​/{appId}​/{objectId}​/config​/ Return the settings for the specified object

  • Status
    colourGreen
    titlePOST
    ​/api​/{nodeId}​/{appId}​/{objectId}​/config​/ Adjust the settings for the specified object

  • Status
    colourGreen
    titlePOST
    ​/api​/{nodeId}​/{appId}​/{objectId}​/copy​/ Create a recursive copy of the specified object

  • Status
    colourGreen
    titlePOST
    ​/api​/{nodeId}​/{appId}​/{objectId}​/delete​/ Delete the specified object

  • Status
    colourBlue
    titleGET
    ​/api​/{nodeId}​/{appId}​/{objectId}​/export​/ Full recursive export for the specified object

  • Status
    colourGreen
    titlePOST
    /api​/{nodeId}​/{appId}​/{objectId}​/import​/ Full recursive import for the specified object

  • Status
    colourBlue
    titleGET
    /api​/{nodeId}​/{appId}​/{objectId}​/tree​/ Return the highest level tree for the specified object

  • Status
    colourBlue
    titleGET
    ​/api​/{nodeId}​/{appId}​/{objectId}​/view​/ Return the schema and settings for the specified object

  • Status
    colourBlue
    titleGET
    /api​/{nodeId}​/{appId}​/{objectId}​/{objectType}​/children​/ List all children of the specified object that are of the specified type

...

Expand
titleLog file handling (log)
  • Status
    colourGreen
    titlePOST
    /log​/delete​/{applabel}​/ Delete all logs under the specified app label

  • Status
    colourGreen
    titlePOST
    /log​/delete​/{applabel}​/{filename}​/ Delete the specified log file

  • Status
    colourBlue
    titleGET
    /log​/download​/{applabel}​/{filename}​/ Return the contents of the specified log file

  • Status
    colourBlue
    titleGET
    ​/log​/getlogs​/ List all available logs

  • Status
    colourBlue
    titleGET
    /log​/zip​/ Create a zip file containing all logs

  • Status
    colourBlue
    titleGET
    /log​/gettextlogs​/Get list of all logs

  • Status
    colourBlue
    titleGET
    /log​/query​/{applabel}/{filename}/{count}/ Return the contents of the specified log file

Expand
titleGeneral system information (system)
  • Status
    colourBlue
    titleGET
    /system​/systemDateTime​/ Return the current date and time for the system (in Unix Epoch time)

  • Status
    colourBlue
    titleGET
    ​/system​/systemInfo​/ Return information about the system

Expand
titleOperations involving package management (packagemanager)
  • Status
    colourBlue
    titleGET
    /packagemanager​/info/{installId}/ Return installed package details

  • Status
    colourBlue
    titleGET
    /packagemanager​/tree/ Return list of installed packages

  • Status
    colourBlue
    titleGET
    /packagemanager​/available/ Return list of packages that can be installed

  • Status
    colourBlue
    titleGET
    /packagemanager​/history/Return list of packages that were installed

  • Status
    colourGreen
    titlePOST
    /packagemanager/uploadModule/ Upload package for installation

  • Status
    colourGreen
    titlePOST
    /packagemanager/{nodeId}/delete/{packageId}/ Delete imported package

  • Status
    colourGreen
    titlePOST
    /packagemanager/{nodeId}/install/ Install package

  • Status
    colourGreen
    titlePOST
    /packagemanager/{nodeId}/uninstall/Uninstall package

  • Status
    colourGreen
    titlePOST
    /packagemanager/{nodeId}/remoteUpload/Remote upload packages

Expand
titleDashboard operations (dashboard)
  • Status
    colourBlue
    titleGET
    /dashboard/ Return list of nodes

Expand
titleOperations involving mqtt (mqtt)
  • Status
    colourBlue
    titleGET
    /mqtt/{nodeId}/{action}/ Get node information

  • Status
    colourGreen
    titlePOST
    /mqtt/{nodeId}/{action}/ Perform action on node