# Get a customer's SKU order stats

URL: https://docs.sparklayer.io/developers/api/purchasing/get-order-stats-for-a-customer
Operation: `GET /api/v1/purchases/stats/order/sku` (operationId `getSKUSalesStats`)
OpenAPI spec: https://docs.sparklayer.io/openapi/purchasing.yaml

Returns how many units of each SKU a customer ordered between `start_date` and `end_date`, grouped by `week`, `month` or `quarter`. Give both dates as RFC 3339 date-times with a time zone offset, or `Z` for UTC. Each period is identified by its start date, returned in UTC.

`GET /api/v1/purchases/stats/order/sku`

**Base URLs:** `https://app.sparklayer.io` (Live), `https://test.app.sparklayer.io` (Test)

**Authentication:** send `Authorization: Bearer <access_token>` and `Site-Id: <site id>` with every request. Get the token from [Get an access token](https://docs.sparklayer.io/developers/api/core/get-an-access-token.md); see [Authentication](https://docs.sparklayer.io/developers/authentication.md).

### Example request

```bash
curl "https://app.sparklayer.io/api/v1/purchases/stats/order/sku?start_date=2020-01-01T00%3A00%3A00%2B02%3A00&end_date=2020-04-30T23%3A59%3A59%2B02%3A00&date_period_type=week" \
  -H "Authorization: Bearer $SPARKLAYER_TOKEN" \
  -H "Site-Id: $SPARKLAYER_SITE_ID"
```

Set `SPARKLAYER_TOKEN` to an access token and `SPARKLAYER_SITE_ID` to your Site ID. For the test environment, use `https://test.app.sparklayer.io`.

### Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `spark_customer_id` | string | Yes | The customer's SparkLayer ID. Length: min 1. |
| `start_date` | string (date-time) | Yes | Starting date-time from which to get stats - include user timezone or Z for UTC (RFC-3339). Example: `2020-01-01T00:00:00+02:00` |
| `end_date` | string (date-time) | Yes | Ending date-time until which to get stats - include user timezone or Z for UTC (RFC-3339). Example: `2020-04-30T23:59:59+02:00` |
| `date_period_type` | "week" \| "month" \| "quarter" | Yes | Date period type to group stats by |

### Header parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `Site-Id` | string | Yes | Your SparkLayer Site ID, from Settings > API in the SparkLayer Dashboard. Length: min 1. Example: `jones-climbing` |

### Responses

#### 200: The units ordered of each SKU, per period.

An array. Each item:

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `[].sku` | string | | |
| `[].periods` | object[] | | |
| `[].periods[].period_start_date` | string (date-time) | | Start date of the period group - always returned as UTC (RFC-3339) |
| `[].periods[].sold_qty` | integer | | |

```json
[
  {
    "sku": "SKU999",
    "periods": [
      {
        "period_start_date": "2020-01-01T00:00:00Z",
        "sold_qty": 8
      },
      {
        "period_start_date": "2020-02-01T00:00:00Z",
        "sold_qty": 2
      }
    ]
  },
  {
    "sku": "SKU888",
    "periods": [
      {
        "period_start_date": "2020-01-01T00:00:00Z",
        "sold_qty": 1
      },
      {
        "period_start_date": "2020-03-01T00:00:00Z",
        "sold_qty": 8
      }
    ]
  }
]
```
