REST API

On this page

REST API

Swagger UI

IoT Hub REST API may be explored using Swagger UI. You can explore REST API of the live-demo server using this Swagger UI link.

To explore REST API provided by IoT Hub please use the following Swagger UI link.

Once you will install IoT Hub server you can open UI using the following URL:

1
http://YOUR_HOST:PORT/swagger-ui.html

REST API Auth

IoT Hub uses JWT for request auth. You will need to populate “X-Authorization” header using “Authorize” button in the top-right corner of the Swagger UI.

image

In order to get the JWT token, you need to execute the following request:

In case of local installation:

  • replace $THINGSBOARD_URL with 127.0.0.1:8080

In case of live-demo server:

  • replace $THINGSBOARD_URL with iothub.magenta.at
  • replace tenant@thingsboard.org with your live-demo username (email)
  • replace tenant password with your live-demo password

The easiest way to get your account is to use IoT Hub server.

1
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{"username":"tenant@thingsboard.org", "password":"tenant"}' 'http://THINGSBOARD_URL/api/auth/login'
1
{"token":"$YOUR_JWT_TOKEN", "refreshToken":"$YOUR_JWT_REFRESH_TOKEN"}
  • Now, you should set ‘X-Authorization’ to “Bearer $YOUR_JWT_TOKEN”

Java REST API Client

IoT Hub team provides client library written in Java to simplify consumption of the REST API. Please see Java REST API Client documentation page for more details.