Skip to main content
Easy Digital Downloads Documentation
Documentation, Reference Materials, and Tutorials for Easy Digital Downloads

EDD REST API – Customers

The
EDD REST API provides an endpoint called /customers/. The customers endpoint allows for you to query the database and retrieve a list of customers that have purchased items from your shop. A basic customers query looks like this:

http://yoursite.com/edd-api/customers/?key=c281cf0a95be875d9eeb284fb004c938&token=5f9432f3ffa5945755ebc66179810d70&number=25

For each customer returned, the following information is returned for each customer:

  • id – The WordPress user ID. If the customer purchased as a guest, this will return as -1.
  • username – The WordPress user login name. If the customer purchased as a guest, this will return as nothing.
  • display_name – The WordPress user display name. If the customer purchased as a guest, this will return as nothing.
  • first_name – The customer first name.
  • last_name – The customer last name.
  • email – The customer’s email address.
  • total_purchases – The total number of purchases the customer has made.
  • total_spent – The total amount the customer has spent.
  • total_downloads – The total number of files the customer has downloaded.

Along with the data returned for each customer is a
stats object that shows the total number of customers in the database.

A customers query response looks like this:

{
    "customers": [
        {
            "info": {
                "id": -1,
                "username": "Guest",
                "display_name": "Guest",
                "first_name": "Guest",
                "last_name": "Guest",
                "email": "johnson@test.com"
            },
            "stats": {
                "total_purchases": 2,
                "total_spent": "20",
                "total_downloads": 0
            }
        },
        {
            "info": {
                "id": -1,
                "username": "Guest",
                "display_name": "Guest",
                "first_name": "Guest",
                "last_name": "Guest",
                "email": "asda@test.com"
            },
            "stats": {
                "total_purchases": 0,
                "total_spent": "0",
                "total_downloads": 0
            }
        }
    ]
}

If you wish to retrieve the info for a specific customer, you can add the
&customer={identifier} parameter, like this:

http://yoursite.com/edd-api/customers/?key=c281cf0a95be875d9eeb284fb004c938&token=5f9432f3ffa5945755ebc66179810d70&customer=1

or

http://yoursite.com/edd-api/customers/?key=c281cf0a95be875d9eeb284fb004c938&token=5f9432f3ffa5945755ebc66179810d70&customer=email@domain.com

The response for a single customer will be like this:

{
    "customers": [
        {
            "info": {
                "id": 1,
                "username": "pippin",
                "display_name": "Pippin Williamson",
                "first_name": "Pippin",
                "last_name": "Williamson",
                "email": "pippin@pippinsplugins.com"
            },
            "stats": {
                "total_purchases": 61,
                "total_spent": 1139.68,
                "total_downloads": 31
            }
        }
    ]
}