How to create an AutoApi

Step-by-Step Guide

Step 1: Go to the screen to create the AutoAPI.

Navigate to the AutoAPI section in your Orchestrator toolbar.


Step 2: Create the AutoAPI.

You will be directed to a new window displaying all the AutoAPI you have created. To create a new AutoAPI, click the + button.


Step 3: Fill the Create AutoAPI Endpoint Form

Add the necessary information for your AutoAPI and select a method (Endpoint)


Step 4: Edit the AutoAPI settings

Select EDIt on your AutoAPI to access the settings.


Step 5 GET AutoAPI

Enter settings in the case of making a GET AutoAPI

  • Select one or more tables or a cube (KUBE) to provide and update information.
  • Select your columns to share in your AutoAPI

Save the changes to use your AutoAPI!

Step 6: POST AutoAPI


Enter settings in the case of making a POST AutoAPI. Follow these steps:

  • Once the first POST load is done, events will be enabled.
  • These events are responsible for modeling the information according to your POST request.
  • After selecting your event, you can use two load models (Single / Multiple Rows) depending on the user's needs. (Single) allows you to load data individually, and (Multiple Rows) can load multiple data massively and efficiently thanks to AutoAPI.
  • Then select which property will be added in the columns of your table.
  • Save your changes.

Endpoint

GET is used to retrieve data from a table or cube (Kube). When you make a GET request, you are asking the server to return a specific resource or information, either individually or massively.

GET URL

The URL is divided into three parts:

BASE: It is the main part of the URL that indicates the base address of the server to which the request will be made.
<https://cloud.arpia.ai/api/>

TOKEN: It is a parameter in the URL that represents a unique access token and is used to authenticate and authorize the request.
?token=65c6dac0e7-f9eeffc386

SHARED TOKEN: It is another parameter in the URL that represents a shared token, which can be used to share access or perform specific actions.
&shared_token=1a46488e82eaddio219430742e6246a9562b2a7c

AUTOAPI: Unified URL and parameters:
<https://cloud.arpia.ai/api/?token=65c6dac0e7-f9eeffc386&shared_token=1a46488e82eaddio219430742e6246a9562b2a7c>

Consultas GET URL

FieldDescriptionDefault ValueRequired
tokenAuthorization token created from Security / Api Tokens.X
shared_tokenToken of the Kube resource, either Reports or Kube Store Tables.X
resultsNumber of records to retrieve.Empty equals 100.
groupbyGroup by one or more fields in columns.Empty without grouping.
pagePage you want to retrieve according to the requested results, for example, with results=100 page=2, it will show from the 100th to the 200th record.Empty equals 1.
filtersJSON array with the filters to apply in the case of the Payload model or an array of GET URL variables in the case of direct integration.

To be able to use filters the API Endpoint needs to be a Kube Resource (Knowledge Node)

Available filter "type" are "=" and "IN"
Empty without filters.
orderbyJSON array with an object of the field to sort in ascending and descending order, for example
{ "field": "ID", "type": "ASC" }
Empty without sorting, and only valid fields and sorting of type ASC or DESC are accepted.
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://cloud.arpia.ai/api/?token=<Your Api Token>&shared_token=<Your Shared Token>',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_POSTFIELDS =>'{
    "results": 100,
    "groupby": {
        "cols": [
            "ProductId",
            "ProductName"
        ]
    },
    "orderby": [
        {
            "field": "ProductName",
            "type": "ASC"
        }
    ],
    "filters": [
        {
            "field": "CustomerId",
            "type": "=", //or "type": = "IN"
            "value": "C0088"
        }
    ],
    "report_type": "groupby"
}',
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer 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',
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;


$.get('https://cloud.arpia.ai/api/?token=<Your Api Token>&shared_token=<Your Shared Token>', {
  results: 100,
  groupby: {
    cols: ['ProductId', 'ProductName']
  },
  orderby: [
    {
      field: 'ProductName',
      type: 'ASC'
    }
  ],
  filters: [
    {
      field: 'IdCustomer',
      type: '=', //or type: = 'IN'
      value: 'C0088'
    }
  ],
  report_type: 'groupby'
})
.done(function(response) {
  console.log(response);
})
.fail(function(xhr, status, error) {
  console.log('Error:', error);
});

{
   /* respuesta de servidor */
  "result": "OK",
  "data": [
  {
    "CustomerName": "user 1",
    "CustomerId": "C0548",
    "ProductId": "PS0000020",
    "ProductName": "NESPRESSO CATUAI 10 CAPSULES",
    "ItemNumber": "8055732940904",
    "Count": "1"
  },
  {
    "CustomerName": "user 1",
    "CustomerId": "C0548",
    "ProductId": "PS0000021",
    "ProductName": "COFFEE HAT GROUND 250G 100% jmj",
    "ItemNumber": "8050508250349",
    "Count": "1"
  },
  {
    "CustomerName": "user 1",
    "CustomerId": "C0548",
    "ProductId": "PS0000109",
    "ProductName": "CONFETTI ALMOND FONDANT 285 GRAMS",
    "ItemNumber": "8050538250721",
    "Count": "1"
  }
],

  /* pagination object */
  "total_rows": {
    "count": "16266",
    "pages": 163
  }
}

POST

It is used to send data to the server to create a new resource or perform a specific action in the database. When making a POST request, you are sending data in the request body for the server to process.

$data = array(
  array("name" => "Example 1", "age" => 25),
  array("name" => "Example 2", "age" => 30),
  array("name" => "Example 3", "age" => 35)
);

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://cloud.arpia.ai/api/?token=65c6dac0e7-f5749cb628/",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_POST => true,
  CURLOPT_POSTFIELDS => json_encode($data),
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json"
  )
));

$response = curl_exec($curl);
$error = curl_error($curl);

curl_close($curl);

if ($error) {
  echo "Error in the request: " . $error;
} else {
  echo "Server response: " . $response;
}
/* POST request */
var data = [
  { "name": "Example 1", "age": 25 },
  { "name": "Example 2", "age": 30 },
  { "name": "Example 3", "age": 35 }
];

$.post("https://cloud.arpia.ai/api/?token=65c6dac0e7-f5749cb628/",JSON.stringify(data), function(response) {
  console.log("Server response:", response);
}).fail(function(error) {
  console.error("Error in the request:", error);
});


{
   /* server response */
  "result": "OK",
}

Points to consider:

❗️

Errors in Field Names

Fields must be sent in the format they are created in the table in the repository. If a field is not named correctly or does not exist, it will result in an error in the API.

🚧

Primary Keys

If the destination table in the repository has a primary key and data is sent to the API, it will replace the data of that unique record.

πŸ“˜

Records with Incomplete Fields!

If you send a data record where not all fields or columns are included in the payload sent to the API, they will be filled with predefined values, null, or empty according to how it has been configured in the table.

βœ”οΈ

Array of objects in JSON format

Remember to use the JSON format when using the AutoAPI