Home Sign up
Docs API

API

Make sure you have added a thing as explained in the section: Adding thing and creating the required settings.

Generality

This part concerns the use of the API in the thing code.

The base url that is used by the different API routes is: YoupiLab IoT. You can store it in a global variable for example in Arduino:

Arduino / C++
const String BASE_URL = "https://iot.youpilab.com/api";

You needed your APP_ID and your APP_KEY who serves as unique identifier and thing identification key respectively. You can also store them in global variables, for example in Arduino:

Arduino / C++
const String APP_ID  = "<Votre_APP_ID>";
const String APP_KEY = "<Votre_APP_KEY>";

Retrieve information

You can have the information about your thing by entering the following url:

URL
https://iot.youpilab.com/api/data/ping?APP_ID=<Votre_APP_ID>&APP_KEY=<Votre_APP_KEY>

And you will receive a json which provides information on the creation date of the thing, the owner, the credentials, the last login:

JSON Response
{
    "status": "success",
    "message": "Thing connected",
    "user": {
        "id": <id>,
        "unique_id": "<unique_id>",
        "name": "<nom_utilisateur>",
        "email": "<votre_mail>",
        "role": "user",
        "subscription_unique_id": "b267bc81351c3315e8d6c867551b9fc6",
        "created_at": "2021-06-14 12:48:53",
        "updated_at": "2021-07-27 05:19:02",
        "last_sign_in": "2021-07-27 05:19:02"
    }
}

Send data

Assuming you had parameters, the url to use is:

URL
https://iot.youpilab.com/api/data/send?APP_ID=<APP_ID>&APP_KEY=<APP_KEY>&<param_1>=<value_1>&<param_2>=<value_2>...

If the sending of the data was successful you will have the following json return:

JSON Response — 200 OK
{
    "status": "success",
    "message": "Data successfully saved"
}

Example

Here is an example in Arduino of sending data on our platform where we had created two settings: nom and age.

Arduino / C++
const String BASE_URL = "https://iot.youpilab.com/api";
const String APP_ID   = "id_equipement_ajoute";
const String APP_KEY  = "1a2b3c4d5e";

String post_url = BASE_URL + "/data/send?" +
                  "APP_ID="  + APP_ID  +
                  "&APP_KEY=" + APP_KEY +
                  "&nom="    + "YoupiLab" +
                  "&age="    + 10;

Types of data

We have 5 Types:

  • Integer
  • Boolean
  • String
  • Double
  • Any

So when adding a parameter you should specify its type. The Any type is reserved for subscribers who have existing projects.

If sending typed data contains an error here is the following json token:

JSON Response — 500
{
    "status": "Parameter type not respected",
    "message": "Parameter type not respected integer type is required"
}

Count the number of data

URL
https://iot.youpilab.com/api/data/count?APP_ID=<APP_ID>&APP_KEY=<APP_KEY>

Retrieve data

URL
https://iot.youpilab.com/api/data/pull?APP_ID=<APP_ID>&APP_KEY=<APP_KEY>&start=<start>&end=<end>
JSON Response
{
    "status": "success",
    "message": "Data has been successfully recovered.",
    "parameters_count": 2,
    "parameters": ["nom", "age"],
    "data_count": 2,
    "data": [
        [{ "id": 3509, "value": "YoupiLab", "unit": "n\/a", "created_at": "2021-07-26 17:26:38" }],
        [{ "id": 3510, "value": "10",        "unit": "n\/a", "created_at": "2021-07-26 17:26:38" }]
    ]
}

Execute an action

You can then retrieve pending actions or tasks to perform using this url:

URL
https://iot.youpilab.com/api/controls/get?APP_ID=<APP_ID>&APP_KEY=<APP_KEY>

Send a feedback

Once an action is executed you can also send feedback to confirm its execution:

URL
https://iot.youpilab.com/api/controls/executed?APP_ID=<APP_ID>&APP_KEY=<APP_KEY>

Execute terminal task

URL
https://iot.youpilab.com/api/terminal/?TERM=<TERMINAL_ID>
JSON Response
{
    "success": true,
    "TERMINAL": "id_of_terminal",
    "TASK_ID": "id_task_executed"
}
URL
https://iot.youpilab.com/api/terminal/response/?TERM=<TERMINAL_ID>&TASK_ID=<TASK_ID>&RESP=<RESPONSE>