[EN] Query data in public API


To make data queries in the public API, the online documentation that is accessible through the link will be used: https://iot.nazaries.cloud/public_api/v1/apidocs, which is made with swagger http: // swagger. io / so tests can be done from the documentation page itself.

It is very easy to use. It should be taken into account that all actions require a previous login. With this, we get a JWT token (https://jwt.io/). This token will allow us to make the other requests to consult the available stations and their data. The documentation page provides curl examples with all the headers, parameters, etc. which accepts the API, so it should provide quite a bit of information on how to use it.

Let's see step by step how to make the queries:

Step 1: Login..

Step 1.1: We click on sign_in.

Step 1.2: After having clicked on sign_in, a view will have been displayed where we can fill in with our username or email and password.

To do this, we must click on the Try it out.

We fill in the name (or email) and password fields:

Step 1.3: Once we have clicked on execute to execute the credentials, if the login is correct, we copy the access token to be able to do the authorization. To do this, we only copy the text that appears inside the quotation marks.

 


Step 1.4: Once we have the token, we have to authorize the user to be able to use the different options of the Webservice. This process is illustrated in the following steps.

Step 1.4.1: We look for the button with the green border and the text "Authorize" and click on it.

Paso 1.4.2: We fill in the value field with the word Bearer space and the token that we have copied and click on "Authorize".


 If everything is correct, the response will give us a 200 code.

NOTE: You can also get the call in Curl format.

Step 2: Data query. Once the user's authorization has been made, we have the following consultation options available to our users:

   Check devices:

  1. Devices(/Stations). Where we can consult the list with all the devices configured for the authorized user.
  2. Devices(/Stations/ {id} ). We can consult the configuration data of the station associated with the indicated id.


    Let's see an example in the case of stations (which can be generalized to the rest of the queries):



   Check variables:

  1. Variables (/stations/{station_id}/variables). Query of the variables associated with the device indicated in station_id.
  2. Variable ( /stations/{station_id}/variables/{id}). Data of the variable (id) of the device (station_id).

   Check data:

  1. Data (/stations/ {station_id}/data). Query of the data of a device between a period of time. These times must be provided in UNIX format and the query will return the information of the last 24 hours at most. In addition, you must indicate (with the id) all the variables for which you want to consult information
  2. Last data. ( /stations/{station_id}/data/latest). Query of the last data generated by the device (station_id).