Get a customer's purchase insights
const url = 'https://apibase.ecomweb.app/api/v1/stores/example/customers/1/insights';const options = {method: 'GET', headers: {'x-api-key': '<x-api-key>'}};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}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
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The customer ID.
The store’s ref, as returned by GET /stores.
Responses
Section titled “Responses”object
The products bought most. Cancelled and refunded orders are left out.
object
Product ID.
Product name.
Units bought.
Revenue from those units.
Payment methods used, with the number of orders for each.
object
Payment method.
Orders paid with it.
Promotions the customer redeemed.
object
Promotion ID.
How many times the customer redeemed it.
Average days between two orders, or null for a customer with fewer than two orders.
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.
object
The HTTP status code.
What went wrong; validation failures list one message per problem.
The HTTP status text, such as Bad Request.
object
A stable, machine-readable error code.
A human-readable explanation.
Extra context about the error, when there is any.
object
When the error happened, as an ISO 8601 timestamp.
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.
object
The HTTP status code.
What went wrong; validation failures list one message per problem.
The HTTP status text, such as Bad Request.
object
A stable, machine-readable error code.
A human-readable explanation.
Extra context about the error, when there is any.
object
When the error happened, as an ISO 8601 timestamp.
Example generated
{ "statusCode": 1, "message": [ "example" ], "error": "example"}The resource does not exist in this store.
object
The HTTP status code.
What went wrong; validation failures list one message per problem.
The HTTP status text, such as Bad Request.
object
A stable, machine-readable error code.
A human-readable explanation.
Extra context about the error, when there is any.
object
When the error happened, as an ISO 8601 timestamp.
Example generated
{ "statusCode": 1, "message": [ "example" ], "error": "example"}