List All Purchases

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

Returns a paginated list of purchases sorted by date in descending order.

Header

Authorization
String
Set value to Bearer SECRET_KEY
supplier_id
integer
Specify an ID for the supplier whose purchases you want to retrieve
product_id
integer
Specify an ID to retrieve purchases for the selected product only
variant_id
integer
Specify an ID to retrieve purchases for the selected product variant only
user_id
integer
Specify an ID to retrieve purchases made by the selected employee only
start_date
datetime
A timestamp from which to start listing purchases. see date & time formats section
end_date
datetime
A timestamp from which to stop listing purchases. see date & time formats section
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/purchases/' \
-H 'Authorization: Bearer SECRET_KEY'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.vendloop.com/purchases',
  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/purchases", 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/purchases")
  .addHeader("Authorization", "Bearer SECRET_KEY")
  .build()
val response = client.newCall(request).execute()

Sample Response

{
  "status":true,
  "message":"Purchase records found",
  "data":[
    {
      "id":"16",
      "date":"2023-05-23 08:17:00",
      "due_date":"2023-05-23",
      "business_id":"1",
      "store_id":"1",
      "supplier_id":"3",
      "user_id":"2",
      "reference_no":"PUR/178018695962",
      "note":"",
      "order_tax":"0.0000",
      "paid":"0.0000",
      "payment_status":"pending",
      "purchase_status":"received",
      "shipping":"0.0000",
      "total":"600.0000",
      "total_discount":"0.0000",
      "total_tax":"0.0000",
      "updated_at":null,
      "updated_by":null,
      "items":[
        {
          "item_cost":"50.0000",
          "item_discount":"0.0000",
          "item_id":"26",
          "item_name":"Apple",
          "item_tax":"0.0000",
          "item_type":"standard",
          "quantity":"12.0000",
          "sku":"16132561",
          "tax":null,
          "tax_method":"subtraction",
          "unit_code":"ball",
          "unit_id":"1"
        }
      ],
      "payments":false,
      "tax":null
    }
  ],
  "metadata":{
    "limit":50,
    "start":1,
    "total":12
  }
}
{
    "status": false,
    "message": "Purchase records not found"
}

Fetch a Single Purchase

get https://api.vendloop.com/purchases/{id}

Returns details of a purchase with the given ID.

Header

Authorization
String
Set value to Bearer SECRET_KEY
id required
integer
Auto-generated unique ID
reference
string
Specify the reference number for this purchase. this is ignored if the id parameter is used
supplier_id
integer
Specify an ID for the supplier whose purchase you want to retrieve
product_id
integer
Specify an ID to retrieve purchases for the selected product only
variant_id
integer
Specify an ID to retrieve purchases for the selected product variant only
user_id
integer
Specify an ID to retrieve purchases made by the selected employee only
start_date
datetime
A timestamp from which to start listing purchases. see date & time formats section
end_date
datetime
A timestamp from which to stop listing purchases. see date & time formats section
curl -L 'https://api.vendloop.com/purchases/{id}' \
-H 'Authorization: Bearer SECRET_KEY'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.vendloop.com/purchases/{id}',
  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/purchases/{id}", 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/purchases/{id}")
  .addHeader("Authorization", "Bearer SECRET_KEY")
  .build()
val response = client.newCall(request).execute()

Sample Response

{
  "status":true,
  "message":"Purchase record found",
  "data":{
    "id":"16",
    "date":"2023-05-23 08:17:00",
    "due_date":"2023-05-23",
    "business_id":"1",
    "store_id":"1",
    "supplier_id":"3",
    "user_id":"2",
    "reference_no":"PUR/178018695962",
    "note":"",
    "order_tax":"0.0000",
    "paid":"0.0000",
    "payment_status":"pending",
    "status":"received",
    "shipping":"0.0000",
    "total":"600.0000",
    "total_discount":"0.0000",
    "total_tax":"0.0000",
    "updated_at":null,
    "updated_by":null,
    "items":[
      {
        "item_cost":"50.0000",
        "item_discount":"0.0000",
        "item_id":"26",
        "item_name":"Apple",
        "item_tax":"0.0000",
        "item_type":"standard",
        "quantity":"12.0000",
        "sku":"16132561",
        "tax":null,
        "tax_method":"subtraction",
        "unit_code":"ball",
        "unit_id":"1"
      }
    ],
    "payments":false,
    "tax":null
  }
}
{
    "status": false,
    "message": "Purchase record not found"
}

Delete a Single Purchase

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

Delete purchase with the given ID.

Header

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

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.vendloop.com/purchases/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/purchases/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/purchases/delete")
  .post(body)
  .addHeader("Authorization", "Bearer SECRET_KEY")
  .build()
val response = client.newCall(request).execute()

Sample Response

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