Paupiette
Paupiette

Reputation: 47

How to create multiple devices automatically in Thingsboard and post telemetry data using HTTP Api

I'm using ThingsBoard to publish some data and I want to create multiple devices automatically using thingsBoard Rest client API and send JSON data (stored in a JSON file) to each one of them, I’m also writing a JAVA program to so but I was using only one device to send the data by copying the Access Token of the device so it can receive the data, however I don’t know how to do that if I have many devices to get the Access token automatically from each device. I’ve been trying for a while to look for a simple method to do so but I’m a bit lost here.

Does anyone have an idea how can I do that.

Upvotes: 0

Views: 958

Answers (2)

Francisco Parrilla
Francisco Parrilla

Reputation: 513

What you can do is use GET /api/tenant/assets?type=telemetry&pageSize=10000&page=0

This will get all the devices of type telemetry, and then you can fetch the part where the token is. That request will return a list.

Upvotes: 1

Delapouite
Delapouite

Reputation: 10167

Have a look at the ThingsBoard administration API described in this swagger https://cloud.thingsboard.io/swagger-ui.html

A few end-points will help you achieve what you need:

  • for devices already created manually, you can retrieve their credentials using
GET /api/device/{deviceId}/credentials
  • for devices without credentials, you can create some using
POST /api/device/credentials

Since you're working in the context of a Java application, I assume you already have a REST client with authentication to perform these calls.

Upvotes: 1

Related Questions