Plain Project

Creating the Project

We can create a new Plain project by making use of the following endpoint, a name, as well as a photo is required.

The status field must be set to "active" for the project to be able to host transaction-making sensors. This field can be changed later.

Remember unlike with Hierarchical Projects, with Plain Projects we need to include the commit interval a project creation, as all of the sensors in the project will share the same commit interval.

Creates a new plain project

POST https://api.airtrace.io/v1/plain

Request Body

Name
Type
Description

name*

String

Name of the new project

photo*

String

Project picture url

status*

String

Status of the current project

commit_interval*

String

Commit interval for the project

Keep in mind: The response from this endpoint will contain the id of the newly created project inside the field "id". We will need this value in order to make almost any request related to the project.

Finding the id of the sensors you want to add

Before adding sensors to Spots on our Plain Project, we need to find their ids. We will look for the sensors in the list of supported sensors that the following endpoint returns:

Get a list of all the sensors available

GET https://api.airtrace.io/v1/sensors

For each sensor that we want to add to our Plain Project, we will take note of it's id as shown in the response from the endpoint.

Adding sensors to our Plain Project

Unlike with Hierarchical Projects, with Plain Projects we add the sensors directly to the Plain Project, instead of any intermediary Deployment.

After we have found the ids of all the sensors we want to add to register in our project, we can assign them one by one to our Plain Project via the Sensor Assignment Endpoint.

For example, if we have 3 copies of the sensors with id 41 and 2 sensors with ids 42 and 43 in our Plain Project, then we need to call this endpoint 5 times, each of them with a different value for "id_sensor"

Assigns a Sensor to a Plain Project

POST https://api.airtrace.io/v1/plain/{id_project}/sensors

Path Parameters

Name
Type
Description

id_project*

String

The id of the Plain Project that will contain the Spot

Request Body

Name
Type
Description

id_sensor*

String

The id of the sensor that will be assigned to the Plain Project

Keep in mind: The response from this endpoint will contain the id of the newly created sensor-project pair inside the field "id". We will need this value in order to make almost any request related to the sensor-project..

After we have set up all of the sensors inside our project, we are ready to assign Identities to them, a necessary step for them to be able to upload data to Airtrace.

Creating Identities for our sensors

We need to create an identity for each sensor that we want uploading data to Airtrace, as there can be many of the same kind of sensor in the same project.

In order to solve this problem, we create an Identity for each of the sensors, providing a primary identifier for each one. This primary identifier needs to be unique, so in our case we will user the MAC address of each sensor as it's identifier.

Lastly we need to provide the id of the sensor for each Identity we create.

Keep in mind: The response from this endpoint will contain the id of the newly created Identity inside the field "id". We will need this value in order to make almost any request related to the Identity.

Assigning Identities to our sensors

Once we have all the ids of the identities and sensors ready in our recently created Plain Project, we can assign each identity to each sensor, after assigning the Identities, the sensors will be ready to upload data to Airtrace.

For that we will need the id of our project, the id of each sensor-project pair inside the project, and the id of the identity we are assigning to each sensor.

We must call this endpoint as many times as we have sensors in our project, so that all of them have an identity assigned.

Assigns an identity to a sensor in a plain project

POST https://api.airtrace.io/v1/plain/{id_project}/sensorproject/{id_sensor_project}/identities

Path Parameters

Name
Type
Description

id_project*

String

id of the plain project containing the sensor

id_sensor_project*

String

id of the sensor-project relationship the identity will be assigned to

Request Body

Name
Type
Description

id_identity*

String

id of the previously created identity which will be assigned to the specified sensor

Generating the infrastructure

Only after all of the sensors have been assigned an identity, we can create an infrastructure for our Plain Project, an infrastructure is the set of links through which the sensors will communicate with Airtrace.

Airtrace supports either the restful interface or the mqtt interface, for this example we are choosing to generate a restful infrastructure for our Plain Project.

Creates a new infrastructure for a Plain Project

POST ​/plain​/{id}​/infrastructure​/{interface}

Path Parameters

Name
Type
Description

*

String

The id of the Plain Project for which the user wants to create a new infrastructure

interface*

String

One of the Airtrace supported Plain Project

This endpoint will provide us with the links for each sensor, each link being a string that begins with "/infrastructure/" and is followed by another string of characters.

We can now turn on our sensors and begin uploading each sensor's data to their corresponding link, for that we point the sensors to the URL that begins with http://api.airtrace.io and is directly followed by the link itself, each time a sensor uploads data, it needs to make an authenticated POST request to the previously mentioned URL.

The data uploaded by the sensors will begin to accumulate until the commit interval for our Plain Project is triggered.

Checking data status

Before the commit interval for our Plain Project triggers a Blockchain transaction, it is stored and can be checked via the following endpoint, which will show all of the data sent that has not been traced (included in a transaction) yet:

Returns all data that will be traced in the next commit interval

GET https://api.airtrace.io/v1/infrastructure/transactions/pending

Whenever the commit interval is triggered, it will generate a transaction and the data previously shown by the "pending" endpoint for that Plain Project will no longer be shown.

On the other hand, we can check the newly made transaction to check the data that was traced.

Checking the transaction

We can query the following endpoint to find the transaction that was triggered by the last commit interval in our Plain Project.

Returns all transactions

GET https://api.airtrace.io/v1/infrastructure/transactions

If there are too many transactions to manually find the one that we are looking for, we can query the following endpoint and get just the transactions that were made today:

Returns all traces between two dates and times

GET https://api.airtrace.io/v1/infrastructure/transactions/{date_start}/{date_end}

Path Parameters

Name
Type
Description

date_start*

dd:mm:yyyy_HH:MM:SS

The start of the date range where transactions will be returned

date_start*

dd:mm:yyyy_HH:MM:SS

The start of the date range where transactions will be returned

Last updated