Secondary Sales API

List the sales distributors made to their retailers, filtered by distributor and sale day, and read the per-distributor totals under the same filters.

2 endpointsBase URL https://api.spirestock.com/api/v1

Every request needs an API key or a session token. Last updated .

On this page (2)

GEThttps://api.spirestock.com/api/v1/secondary-sales

Sales a distributor made to its retailers, newest sale day first with id as the tie-break.

Access: API key read scope; staff need Orders (8) — list.

Pagedpage and limit (max 100), id as the final sort key. How pagination works

Parameters

distributor_idnumber
One distributor; a value that is not a positive integer is 400
date_fromstring
First sale day, YYYY-MM-DD only
date_tostring
Last sale day (inclusive), YYYY-MM-DD only; a start after the end is 400
pagenumber
Page number; junk or a value below 1 reads as 1 Default 1.
limitnumber
Page size, default 20, max 100 (larger values are clamped)
Example request
curl "https://api.spirestock.com/api/v1/secondary-sales?distributor_id=1201&date_from=2024-06-01&date_to=2024-06-30" \
  -H "X-API-Key: YOUR_API_KEY"
Example response
{
  "response_code": 200,
  "data": [
    {
      "id": 9,
      "organization_id": 6,
      "distributor_id": 1201,
      "distributor_name": "Demo Distributor A",
      "retailer_id": null,
      "retailer_name": "Retailer One",
      "retailer_store": "Store One",
      "product_variant_id": null,
      "product_variant_name": "Toned Milk 500 ml",
      "quantity": 10,
      "rate": 22,
      "amount": 220,
      "sale_date": "2024-06-10",
      "recorded_by": 1001,
      "createdAt": "2024-06-10T05:30:00.000Z",
      "updatedAt": "2024-06-10T05:30:00.000Z"
    }
  ],
  "pagination": {
    "total": 1,
    "page": 1,
    "limit": 20,
    "total_pages": 1
  }
}

GEThttps://api.spirestock.com/api/v1/secondary-sales/summary

Totals per distributor under the same filters as the list: sale_count, total_quantity and total_amount, highest amount first. Not paged. Field staff without the grant see only distributors allocated to their towns, or sales their reporting tree recorded. Cached 30 seconds.

Access: API key read scope; staff need Orders (8) — list (without it, only their own records).

Parameters

distributor_idnumber
One distributor; a value that is not a positive integer is 400
date_fromstring
First sale day, YYYY-MM-DD only
date_tostring
Last sale day (inclusive), YYYY-MM-DD only; a start after the end is 400
Example request
curl "https://api.spirestock.com/api/v1/secondary-sales/summary?date_from=2024-06-01&date_to=2024-06-30" \
  -H "X-API-Key: YOUR_API_KEY"
Example response
{
  "response_code": 200,
  "data": [
    {
      "distributor_id": 1201,
      "distributor_name": "Demo Distributor A",
      "sale_count": 2,
      "total_quantity": 14,
      "total_amount": 360
    },
    {
      "distributor_id": 1202,
      "distributor_name": "Demo Distributor B",
      "sale_count": 1,
      "total_quantity": 6,
      "total_amount": 132
    }
  ]
}