How to send readings
This guide will help you to start sending readings from your registers in the Switch platform using the Switch API.
Last updated
Was this helpful?
This guide will help you to start sending readings from your registers in the Switch platform using the Switch API.
Last updated
Was this helpful?
Many features supported by the Switch platform require readings to be sent to the platform on regular basis or when it is needed.
First of all, you'll need to be set up and accustomed to working with the . Next you need to create an and note the client ID and secret since you will need them further on.
In order to be able to send your readings you first need a valid access token that will be used to authorize your request to the Switch API.
To accomplish this you will need the previously noted client ID and client secret and use them to retrieve valid access token by following the client credentials flow as described in page. Please note the endpoint for retriving the token as stated in page depending on which environment you want to send readings.
When you have your access token ready, proceed with the next step.
The API endpoint used for sending readings is called and can be seen in the page under API Reference.
As described in the page, the Switch platform has defined hierarchy where on top we have the meter
, then the meter can contain one or multiple registers
and each register can have one or multiple readings
.
Therefore, the request payload model for sending readings is defined as follows:
The attributes in the payload model above map to the following attributes for the meter, register and reading:
meters -> meter -> id
Meter External ID
meters -> registers
Collection of registers defined under the given meter
registers -> register -> id
Register External ID
register -> values
Register readings (measurements)
If the saving of the readings was success, you will receive a 204 Not Content
response.
This same model can be seen under the as well. It supports sending readings from multiple meters and registers at once.
There is an additional restricition when sending readings to the Switch API, beside the limitations which states that the maximum number of readings allowed to be sent in one request, from all defined meters and registers in the sent request payload, can't be more than 5000.
To make the send readings request, you send an authenticated request to the endpoint.