# EDD REST API V2 - Customers

 This document relates specifically to Version 2 of the EDD API. [Documentation for Version 1 is here](https://easydigitaldownloads.com/docs/edd-rest-api-customers/).

 The [EDD REST API](https://easydigitaldownloads.com/docs/edd-rest-api-introduction/) 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:

```

https://yoursite.com/edd-api/v2/customers/?key=c281cf0a95be875d9eeb284fb004c938&amp;token=5f9432f3ffa5945755ebc66179810d70&amp;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&#039;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:

```

{
    &quot;customers&quot;: [
        {
            &quot;info&quot;: {
                &quot;id&quot;: &quot;3&quot;,
                &quot;user_id&quot;: &quot;&quot;,
                &quot;username&quot;: &quot;&quot;,
                &quot;display_name&quot;: &quot;&quot;,
                &quot;customer_id&quot;: &quot;3&quot;,
                &quot;first_name&quot;: &quot;Matthew&quot;,
                &quot;last_name&quot;: &quot;Dixon&quot;,
                &quot;email&quot;: &quot;matthew@example.com&quot;,
		&quot;additional_emails&quot;: [],
                &quot;date_created&quot;: &quot;2016-05-28 00:09:40&quot;
            },
            &quot;stats&quot;: {
                &quot;total_purchases&quot;: &quot;1&quot;,
                &quot;total_spent&quot;: &quot;20.000000&quot;,
                &quot;total_downloads&quot;: 0
            }
        },
        {
            &quot;info&quot;: {
                &quot;id&quot;: &quot;2&quot;,
                &quot;user_id&quot;: &quot;2&quot;,
                &quot;username&quot;: &quot;bob&quot;,
                &quot;display_name&quot;: &quot;bob&quot;,
                &quot;customer_id&quot;: &quot;2&quot;,
                &quot;first_name&quot;: &quot;&quot;,
                &quot;last_name&quot;: &quot;&quot;,
                &quot;email&quot;: &quot;bob@example.com&quot;,
                &quot;additional_emails&quot;: [
                    &quot;robert.joiner@example.com&quot;
                ],
                &quot;date_created&quot;: &quot;2016-05-17 14:17:15&quot;
            },
            &quot;stats&quot;: {
                &quot;total_purchases&quot;: &quot;1&quot;,
                &quot;total_spent&quot;: &quot;0.000000&quot;,
                &quot;total_downloads&quot;: 0
            }
        },
        {
            &quot;info&quot;: {
                &quot;id&quot;: &quot;1&quot;,
                &quot;user_id&quot;: &quot;1&quot;,
                &quot;username&quot;: &quot;jose&quot;,
                &quot;display_name&quot;: &quot;Jose&quot;,
                &quot;customer_id&quot;: &quot;1&quot;,
                &quot;first_name&quot;: &quot;Jose&quot;,
                &quot;last_name&quot;: &quot;Espinoza&quot;,
                &quot;email&quot;: &quot;jose@example.com&quot;,
		&quot;additional_emails&quot;: [],
                &quot;date_created&quot;: &quot;2016-05-17 14:08:57&quot;
            },
            &quot;stats&quot;: {
                &quot;total_purchases&quot;: &quot;6&quot;,
                &quot;total_spent&quot;: &quot;70.000000&quot;,
                &quot;total_downloads&quot;: 2
            }
        }
    ],
    &quot;request_speed&quot;: 0.0081720352172852
}
```

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

```

https://yoursite.com/edd-api/v2/customers/?key=c281cf0a95be875d9eeb284fb004c938&amp;token=5f9432f3ffa5945755ebc66179810d70&amp;customer=1
```

 or

```

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

 The response for a single customer will be like this:

```

{
    &quot;customers&quot;: [
        {
            &quot;info&quot;: {
                &quot;id&quot;: &quot;1&quot;,
                &quot;user_id&quot;: &quot;1&quot;,
                &quot;username&quot;: &quot;jose&quot;,
                &quot;display_name&quot;: &quot;Jose&quot;,
                &quot;customer_id&quot;: &quot;1&quot;,
                &quot;first_name&quot;: &quot;Jose&quot;,
                &quot;last_name&quot;: &quot;Espinoza&quot;,
                &quot;email&quot;: &quot;jose@example.com&quot;,
		&quot;additional_emails&quot;: [],
                &quot;date_created&quot;: &quot;2016-05-17 14:08:57&quot;
            },
            &quot;stats&quot;: {
                &quot;total_purchases&quot;: &quot;6&quot;,
                &quot;total_spent&quot;: &quot;70.000000&quot;,
                &quot;total_downloads&quot;: 2
            }
        }
    ]
}
```

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

```

https://yoursite.com/edd-api/customers/?key=c281cf0a95be875d9eeb284fb004c938&amp;token=5f9432f3ffa5945755ebc66179810d70&amp;date=today
```

 A date range would look like this:

```

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