# EDD REST API - Sales

 The [EDD REST API](https://easydigitaldownloads.com/docs/edd-rest-api-introduction/) provides access to sales data via the `/sales/` endpoint. The sales endpoint allows for you to query the database and retrieve information for recent sales. A basic sales query looks like this:

```
https://example.com/edd-api/sales/?key=c281cf0a95be875d9eeb284fb004c938&amp;token=5f9432f3ffa5945755ebc66179810d70
```

 Requests to the `/sales/` endpoint accept the following parameters:

- `key` - The API key to authenticate the request (required).
- `token` - The API token to authenticate the request (required).
- `number` - The number of records to return (optional).
- `email` - A search parameter to return only payments that match the given email (optional).
- `id` - The ID number of a specific payment record (optional).
- `purchasekey` - The purchase key for a specific payment record (optional).

 For each sale returned, the following information will be available:

- **ID** - The sale ID number.
- **key** -The sale purchase key.
- **subtotal** - The sale subtotal.
- **tax** - The sales tax amount.
- **fees** - Any arbitrary fees that were added to the sale.
- **total** - The total sale amount.
- **gateway** - The payment method, such as stripe or paypal, used to make the purchase.
- **email** - The email address associated with the sale.
- **date** - The date the sale was made.
- **discounts** - List of discount codes used.
- **products** - A list of products purchased. For each product: 
    - **id** - The Product ID.
    - **quantity** - The cart quantity for the item.
    - **name** - The name of the product.
    - **price** - The price of the product (after any discounts).
    - **price\_name** - The price option name that was purchased (if the product has variable prices).

 An example sales query response looks like this:

```
{
    &quot;sales&quot;: [
        {
            &quot;ID&quot;: 123,
            &quot;mode&quot;: &quot;&quot;,
            &quot;status&quot;: &quot;publish&quot;,
            &quot;transaction_id&quot;: 12323461261234,
            &quot;key&quot;: &quot;ca2aaaa2a9e9e5369b8280403431b6fd&quot;,
            &quot;subtotal&quot;: 89,
            &quot;tax&quot;: &quot;0&quot;,
            &quot;fees&quot;: null,
            &quot;total&quot;: &quot;8.009&quot;,
            &quot;gateway&quot;: &quot;manual&quot;,
            &quot;customer_id&quot;: &quot;2&quot;,
            &quot;user_id&quot;: &quot;0&quot;,
            &quot;email&quot;: &quot;jdoe@example.org&quot;,
            &quot;date&quot;: &quot;2021-09-29 13:47:41&quot;,
            &quot;discounts&quot;: null,
            &quot;products&quot;: [
                {
                    &quot;id&quot;: 167,
                    &quot;quantity&quot;: 1,
                    &quot;name&quot;: &quot;Stripe Pro Payment Gateway&quot;,
                    &quot;price&quot;: 89,
                    &quot;price_name&quot;: &quot;Single Site&quot;
                }
            ],
        },
        {
            &quot;ID&quot;: 122,
            &quot;mode&quot;: &quot;&quot;,
            &quot;status&quot;: &quot;publish&quot;,
            &quot;transaction_id&quot;: 12324621266234,
            &quot;key&quot;: &quot;7608c3f1b8f5e00b7f21add193ab7ced&quot;,
            &quot;subtotal&quot;: 199,
            &quot;tax&quot;: &quot;0&quot;,
            &quot;fees&quot;: null,
            &quot;total&quot;: &quot;199.00&quot;,
            &quot;gateway&quot;: &quot;manual&quot;,
            &quot;customer_id&quot;: &quot;2&quot;,
            &quot;user_id&quot;: &quot;0&quot;,
            &quot;email&quot;: &quot;jdoe@example.org&quot;,
            &quot;date&quot;: &quot;2021-09-29 13:30:59&quot;,
            &quot;discounts&quot;: null,
            &quot;products&quot;: [
                {
                    &quot;id&quot;: 1245716,
                    &quot;quantity&quot;: 1,
                    &quot;name&quot;: &quot;Extended Pass&quot;,
                    &quot;price&quot;: 199,
                    &quot;price_name&quot;: &quot;&quot;
                }
        }
    ]
}
```

 You can narrow the results down by email by adding &quot;&amp;email=test@test.com&quot;. Replace &quot;test@test.com&quot; with the actual user&#039;s email address for whom you want to show sales.

```
https://example.com/edd-api/sales/?key=c281cf0a95be875d9eeb284fb004c938&amp;token=5f9432f3ffa5945755ebc66179810d70&amp;email=test@test.com
```

### Retrieving Specific Sale Records

 To retrieve a specific sale record, you can include either the `id` or the `purchasekey` parameter in the request.

 For example, to retrieve a sale by the purchase key, the request looks like this:

```
https://example.com/edd-api/sales/?key=&lt;api key=&quot;&quot;&gt;&amp;token=&lt;api token=&quot;&quot;&gt;&amp;purchasekey=&lt;purchase key=&quot;&quot;&gt;
&lt;/purchase&gt;&lt;/api&gt;&lt;/api&gt;
```

 To retrieve a sale by the ID, the request looks like this:

```
https://example.com/edd-api/sales/?key=&lt;api key=&quot;&quot;&gt;&amp;token=&lt;api token=&quot;&quot;&gt;&amp;id=&lt;purchase key=&quot;&quot;&gt;
&lt;/purchase&gt;&lt;/api&gt;&lt;/api&gt;
```

### Searching Sale Records

 Passing the `email` parameter will result in the API returning all sale records that match the given email address.

```
https://example.com/edd-api/sales/?key=&lt;api key=&quot;&quot;&gt;&amp;token=&lt;api token=&quot;&quot;&gt;&amp;email=&lt;email address=&quot;&quot;&gt;
&lt;/email&gt;&lt;/api&gt;&lt;/api&gt;
```