Skip to content
campaiDeveloper
campai.com

Sales · Statistics

GET/{organizationId}/{mandateId}/sales/statistics/productSalesReads only

Get product sales

Returns what the invoices of a period sold of products, without the invoices of shop orders: the amount in the period and in the period of the same length right before it, the amount per product category with the four largest by name and the rest as other, the amount per month and category, and the five products that brought the most with their category and quantity. A variant counts for its product. Each position gets its share of the invoice total, so the amounts are gross after discounts, credit notes count against them, and all are in cents

Permissions

Send an API key of the organization in the path, using the X-API-Key header.

Permission checks in detail
Required permissions
  • mandate.read
  • receipt.read
  • product.read

Request

Path parameters

  • organizationIdidrequired
  • mandateIdidrequired

Query parameters

  • fromDatestringrequired
  • toDatestringrequired
Request
curl --fail-with-body --silent --show-error --max-time 30 --globoff \
  --request GET 'https://cloud.campai.com/api/YOUR_ORGANIZATION_ID/YOUR_MANDATE_ID/sales/statistics/productSales' \
  --header 'X-API-Key: YOUR_API_KEY'

Response

200 Successful response

Content-Type: application/json

  • soldAmountnumber

    at least 0

  • previousSoldAmountnumber

    at least 0

  • categoriesobject[]
    3 properties
    • keystring
    • namestringnullable
    • amountnumber

      at least 0

  • monthsobject[]
    3 properties
    • datestring
    • amountsobject of number
    • totalAmountnumber

      at least 0

  • topProductsobject[]
    5 properties
    • productIdid
    • namestring
    • categoryNamestringnullable
    • soldQuantitynumber

      at least 0

    • soldAmountnumber

      at least 0

Response200
{
  "soldAmount": 0,
  "previousSoldAmount": 0,
  "categories": [
    {
      "key": "string",
      "name": "string",
      "amount": 0
    }
  ],
  "months": [
    {
      "date": "string",
      "amounts": {
        "key": 0
      },
      "totalAmount": 0
    }
  ],
  "topProducts": [
    {
      "productId": "000000000000000000000001",
      "name": "string",
      "categoryName": "string",
      "soldQuantity": 0,
      "soldAmount": 0
    }
  ]
}

Errors

No errors of its own are known for this endpoint.

Errors nearly every request can meet are listed under Errors.