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:
Other tools for exploring APIs
If the OpenAPI interface to Butler’s API feels limited, there are lots of tools dedicated to this task.
Two good ones are:
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:
List available Sense apps and extract them as JSON
List existing apps on Sense server, then export one of them to JSON.