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

EDD REST API V2 – Customers

This document relates specifically to Version 2 of the EDD API.
Documentation for Version 1 is here.

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/v2/customers/?key=c281cf0a95be875d9eeb284fb004c938&token=5f9432f3ffa5945755ebc66179810d70&number=25

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

  • customer_id – The unique ID of the customer. Matches id in this API result.
  • user_id – The WordPress user ID. If the customer purchased as a guest, this will return as nothing.
  • 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.
  • date_created – The date this customer was created in EDD.
  • 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.
  • date – The date to retrieve cutomers for. This has three accepted values:
    • today – Will retrieve customers created on the current day.
    • yesterday – Will retrieve customers created on the previous day.
    • range – Will retrieve customers created within a date range.
      • startdate – Format: YYYYMMDD. Example: 20120224 = 2012/02/24
      • enddate – Format: YYYYMMDD. Example: 20120531 = 2012/02/24

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": "3",
                "user_id": "",
                "username": "",
                "display_name": "",
                "customer_id": "3",
                "first_name": "Matthew",
                "last_name": "Dixon",
                "email": "[email protected]",
		"additional_emails": [],
                "date_created": "2016-05-28 00:09:40"
            },
            "stats": {
                "total_purchases": "1",
                "total_spent": "20.000000",
                "total_downloads": 0
            }
        },
        {
            "info": {
                "id": "2",
                "user_id": "2",
                "username": "bob",
                "display_name": "bob",
                "customer_id": "2",
                "first_name": "",
                "last_name": "",
                "email": "[email protected]",
                "additional_emails": [
                    "[email protected]"
                ],
                "date_created": "2016-05-17 14:17:15"
            },
            "stats": {
                "total_purchases": "1",
                "total_spent": "0.000000",
                "total_downloads": 0
            }
        },
        {
            "info": {
                "id": "1",
                "user_id": "1",
                "username": "jose",
                "display_name": "Jose",
                "customer_id": "1",
                "first_name": "Jose",
                "last_name": "Espinoza",
                "email": "[email protected]",
		"additional_emails": [],
                "date_created": "2016-05-17 14:08:57"
            },
            "stats": {
                "total_purchases": "6",
                "total_spent": "70.000000",
                "total_downloads": 2
            }
        }
    ],
    "request_speed": 0.0081720352172852
}

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/v2/customers/?key=c281cf0a95be875d9eeb284fb004c938&token=5f9432f3ffa5945755ebc66179810d70&customer=1

or

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

The response for a single customer will be like this:

{
    "customers": [
        {
            "info": {
                "id": "1",
                "user_id": "1",
                "username": "jose",
                "display_name": "Jose",
                "customer_id": "1",
                "first_name": "Jose",
                "last_name": "Espinoza",
                "email": "[email protected]",
		"additional_emails": [],
                "date_created": "2016-05-17 14:08:57"
            },
            "stats": {
                "total_purchases": "6",
                "total_spent": "70.000000",
                "total_downloads": 2
            }
        }
    ]
}

A query looking for customers created today would look like this:

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

A date range would look like this:

http://yoursite.com/edd-api/customers/?key=c281cf0a95be875d9eeb284fb004c938&token=5f9432f3ffa5945755ebc66179810d70&date=range&startdate=20130201&enddate=20130210