Skip to content

Get a customer's purchase insights

GET
/stores/{storeRef}/customers/{customerId}/insights
curl --request GET \
--url https://apibase.ecomweb.app/api/v1/stores/example/customers/1/insights \
--header 'x-api-key: <x-api-key>'

Returns what the customer’s orders say about their buying: the products they bought most, the payment methods they used, the promotions they redeemed and the average days between orders. Cancelled and refunded orders are left out of the money figures.

Required scopes: read:customers

customerId
required
integer

The customer ID.

storeRef
required
string

The store’s ref, as returned by GET /stores.

Media typeapplication/json
object
top_products
required

The products bought most. Cancelled and refunded orders are left out.

Array<object>
object
product_id
required

Product ID.

number
product_name
required

Product name.

string
quantity
required

Units bought.

number
revenue
required

Revenue from those units.

number
payment_methods
required

Payment methods used, with the number of orders for each.

Array<object>
object
payment_method
required

Payment method.

string
order_count
required

Orders paid with it.

number
promotions_redeemed
required

Promotions the customer redeemed.

Array<object>
object
promotion_id
required

Promotion ID.

number
times_used
required

How many times the customer redeemed it.

number
avg_days_between_orders
required

Average days between two orders, or null for a customer with fewer than two orders.

number
nullable

Example generated

{
"top_products": [
{
"product_id": 1,
"product_name": "example",
"quantity": 1,
"revenue": 1
}
],
"payment_methods": [
{
"payment_method": "example",
"order_count": 1
}
],
"promotions_redeemed": [
{
"promotion_id": 1,
"times_used": 1
}
],
"avg_days_between_orders": 1
}

The key is missing, invalid, revoked or expired.

Media typeapplication/json
One of:
object
statusCode
required

The HTTP status code.

number
message
required

What went wrong; validation failures list one message per problem.

One of:
string
error

The HTTP status text, such as Bad Request.

string

Example generated

{
"statusCode": 1,
"message": [
"example"
],
"error": "example"
}

The key may not do this: a missing scope, a readonly key, a publishable key on a Store API route, or a disallowed origin.

Media typeapplication/json
One of:
object
statusCode
required

The HTTP status code.

number
message
required

What went wrong; validation failures list one message per problem.

One of:
string
error

The HTTP status text, such as Bad Request.

string

Example generated

{
"statusCode": 1,
"message": [
"example"
],
"error": "example"
}

The resource does not exist in this store.

Media typeapplication/json
One of:
object
statusCode
required

The HTTP status code.

number
message
required

What went wrong; validation failures list one message per problem.

One of:
string
error

The HTTP status text, such as Bad Request.

string

Example generated

{
"statusCode": 1,
"message": [
"example"
],
"error": "example"
}