This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

Swagger UI: Try out the Butler API using the API docs

Assuming Butler is properly configured and running, it’s easy to try out Butler’s API. This page shows some examples of interactions with the Butler API.

Below are some examples of how Butler’s built-in Swagger docs can be used to test-drive the Butler API.

Note: Some of the videos below were created with older Butler versions.
Details may have changed (for example what API parameters are available), the general concepts remain the same though.

OpenAPI documentation built into Butler

The complete documentation for Butler’s REST API is built into Butler itself. This means that its very easy to try out and get familiar with the various API endpoints, without having to create Sense apps for everything you want to try out.

If Butler’s config file contains the settings below, the API will be available at http://192.168.1.168:8080.

...
restServerConfig:
  enable: true
  serverHost: 192.168.1.168
  serverPort: 8080
  backgroundServerPort: 8083
...

In addition to the API endpoints, the API documentation will be available at http://192.168.1.168:8080/documentation.
The beauty of the Swagger docs is that you can also test drive the API itself. If you have Butler running it’s thus super easy to test the various REST API endpoints.

The API doc page looks like this:

Butler ping

This is the most basic API endpoint of them all. Can be used to verify that Butler is actually running and responding as expected.

Looks like this. Note the response we get from Butler’s API.

List all enabled API endpoints

Let’s take a look at which API endpoints are enabled in the restServerEndpointsEnable section of the config file:

Key-value pairs, demo 1

Create and query key-value pairs.

Schedules, demo 1

Create, query, edit and delete task reload schedules using Butler’s scheduling API.

When wathcing the video below, you will notice there are two pre-defined schedules.
One of them fires every 30 seconds and this is also visible in the Butler logs:

Active user sessions

List available Sense apps and extract them as JSON

List existing apps on Sense server, then export one of them to JSON.