List All Units

get https://api.vendloop.com/units

Returns a paginated list of units sorted by id in descending order.

Header

Authorization
String
Set value to Bearer SECRET_KEY
limit
integer
Specify how many records you want to retrieve per page. If not specified we use a default value of 50.
curl -L 'https://api.vendloop.com/units/' \
-H 'Authorization: Bearer SECRET_KEY'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.vendloop.com/units',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer SECRET_KEY'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer SECRET_KEY");

var requestOptions = {
  method: 'GET',
  headers: myHeaders,
  redirect: 'follow'
};

fetch("https://api.vendloop.com/units", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
val client = OkHttpClient()
val request = Request.Builder()
  .url("https://api.vendloop.com/units")
  .addHeader("Authorization", "Bearer SECRET_KEY")
  .build()
val response = client.newCall(request).execute()

Sample Response

{
  "status":true,
  "message":"Unit records found",
  "data":[
    {
      "base_unit":null,
      "code":"carton",
      "id":"9",
      "name":"Carton",
      "operation_value":null,
      "operator":null,
      "sub_units":[
        {
          "id":"3",
          "name":"Bottle",
          "code":"bottle",
          "operator":"/",
          "unit_value":null,
          "operation_value":"12"
        }
      ],
      "unit_value":null
    },
    {
      "base_unit":"9",
      "code":"bottle",
      "id":"3",
      "name":"Bottle",
      "operation_value":"12",
      "operator":"/",
      "sub_units":null,
      "unit_value":null
    }
  ],
  "metadata":{
    "limit":50,
    "start":1,
    "total":2
  }
}
{
    "status": false,
    "message": "Unit records not found"
}

Fetch a Single Unit

get https://api.vendloop.com/units/{id_or_code}

Returns details of a unit with the given ID.

Header

Authorization
String
Set value to Bearer SECRET_KEY
id required
integer
Auto-generated unique ID
code
string
Specify the code for this unit. this is ignored if the id parameter is used
curl -L 'https://api.vendloop.com/units/{id_or_code}' \
-H 'Authorization: Bearer SECRET_KEY'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.vendloop.com/units/{id_or_code}',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer SECRET_KEY'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer SECRET_KEY");

var requestOptions = {
  method: 'GET',
  headers: myHeaders,
  redirect: 'follow'
};

fetch("https://api.vendloop.com/units/{id_or_code}", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
val client = OkHttpClient()
val request = Request.Builder()
  .url("https://api.vendloop.com/units/{id_or_code}")
  .addHeader("Authorization", "Bearer SECRET_KEY")
  .build()
val response = client.newCall(request).execute()

Sample Response

{
  "status":true,
  "message":"Unit record found",
  "data":{
    "base_unit":"9",
    "code":"bottle",
    "id":"3",
    "name":"Bottle",
    "operation_value":"12",
    "operator":"/",
    "sub_units":null,
    "unit_value":null
  }
}
{
    "status": false,
    "message": "Unit record not found"
}

Delete a Single Unit

post https://api.vendloop.com/units/delete

Delete unit with the given ID.

Header

Authorization
String
Set value to Bearer SECRET_KEY
id required
integer
The ID of the unit to be deleted.
curl -L 'http://api.vendloop.com/units/delete' \
-H 'Authorization: Bearer SECRET_KEY' \
-F 'id="{id}"'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.vendloop.com/units/delete',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => array('id' => '{id}'),
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer SECRET_KEY'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer SECRET_KEY");

var formdata = new FormData();
formdata.append("id", "{id}");

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: formdata,
  redirect: 'follow'
};

fetch("https://api.vendloop.com/units/delete", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
val client = OkHttpClient()
val mediaType = "text/plain".toMediaType()
val body = MultipartBody.Builder().setType(MultipartBody.FORM)
  .addFormDataPart("id","{id}")
  .build()
val request = Request.Builder()
  .url("https://api.vendloop.com/units/delete")
  .post(body)
  .addHeader("Authorization", "Bearer SECRET_KEY")
  .build()
val response = client.newCall(request).execute()

Sample Response

{
  "status": true,
  "message": "Unit record deleted"
}
{
    "status": false,
    "message": "Unit record not found"
}