# List all purchase links

Source: https://developers.swell.is/backend-api/purchase-links/list-all-purchase-links

List all purchase links.

## Arguments

- `expand` (string): Expand link fields and child collections by using the expand argument.

  - For example, `expand=account` would return a related customer account if one exists.

  When the field represents a collection, you can specify the query limit.

  - For example, `expand=variants:10` would return up to 10 records of the variants collection.

  See [expanding](https://developers.swell.is/backend-api/querying/expanding) for more details.
- `fields` (string): Returns only the specified fields in the result.

  - For example `fields=name,slug` would return only the fields `name` and `slug` in the response.

  Supports nested object and array fields using dot-notation.

  - For example, `items.product_id`. The product `id` is always returned.
- `include` (object): Include one or more arbitrary queries in the response which are potentially related to the main query.

  See [including](https://developers.swell.is/backend-api/querying/including) for more details.
- `limit` (int): Limit the number of records returned, ranging between `1` and `1000`. Defaults to `15`. Default: `15`.
- `page` (int): The page number of results to return given the specified or default `limit`.
- `search` (string): A text search is performed using the search argument. Searchable fields are defined by the model.

  - For example, `search=red` would return records containing the word "red" anywhere in the defined text fields.

  See [searching](https://developers.swell.is/backend-api/querying/searching) for more details.
- `sort` (string): Expression to sort results by using a format similar to a SQL sort statement.

  - For example, `sort=name asc` would return records sorted by name ascending.

  See [sorting](https://developers.swell.is/backend-api/querying/sorting) for more details.
- `where` (object): An object with criteria to filter the result.

  - For example, `active=true` would return records containing a field `active` with the value `true`.

  It's also possible to use query operators, for example, `$eq`, `$ne`, `$gt`, and more.

  See [querying](https://developers.swell.is/backend-api/querying) for more details.

## Example request

`GET /purchaselinks`

**cURL**

```sh
$ curl https://api.swell.store/purchaselinks/ \
  -u store-id:secret-key
```

**Node**

```javascript
const { swell } = require('swell-node');
swell.init('store-id', 'secret-key');

await swell.get('/purchaselinks/');
```

**PHP**

```javascript
<?php $swell = new \Swell\Client('store-id', 'secret-key');

$swell->get('/purchaselinks/');
```

## Example response

```json
{
  "count": 39,
  "results": [
    {
      "active": true,
      "name": "Purchase link example",
      "items": [
        {
          "product_id": "626034d4e7b741001968292d",
          "options": [
            {
              "id": "626034de60bd1a69a444f233",
              "name": "Size20-04",
              "value": "s",
              "value_id": "626034ee60bd1a69a444f234",
              "variant": true
            }
          ],
          "quantity": 1,
          "price": 5,
          "price_total": 5,
          "discount_total": 0,
          "discount_each": 0,
          "id": "62681502ea4c3f00138da5ea"
        }
      ],
      "currency": "USD",
      "sub_total": 5,
      "item_discount": 0,
      "discount_total": 0,
      "grand_total": 5,
      "date_created": "2022-04-26T15:51:30.324Z",
      "date_updated": "2022-04-26T15:52:33.949Z",
      "id": "DEEFRebs"
    },
    {
      "active": true,
      "name": "Test items",
      "items": [
        {
          "product_id": "625daa41e6e0e30019c4a084",
          "quantity": 1,
          "price": 100,
          "id": "625daa53e6e0e30019c4a2a3",
          "orig_price": 100,
          "delivery": "shipment",
          "shipment_weight": 0,
          "price_total": 100,
          "discount_total": 50,
          "discount_each": 50,
          "discounts": [
            {
              "id": "coupon-0",
              "amount": 50
            }
          ]
        }
      ],
      "shipment_delivery": true,
      "currency": "USD",
      "sub_total": 100,
      "item_discount": 50,
      "discount_total": 50,
      "grand_total": 50,
      "date_created": "2022-04-18T17:51:34.937Z",
      "date_updated": "2022-04-18T18:13:40.581Z",
      "coupon_code": "SIMPLETEST",
      "promotion_ids": [
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        "625da6a2e6e0e30019c471dd"
      ],
      "coupon_id": "625da691e6e0e30019c46fea",
      "discounts": [
        {
          "type": "coupon",
          "rule": {
            "value_fixed": 50,
            "type": "total",
            "value_type": "fixed"
          },
          "amount": 50,
          "id": "coupon-0"
        }
      ],
      "shipment_discount": null,
      "id": "vASbh0zY"
    },
    {
      "name": "NEW PURCHASE LINK",
      "items": [
        {
          "purchase_option": {
            "plan_id": "6256eb710c7aaf0012dd1731",
            "billing_schedule": {
              "interval": "weekly",
              "interval_count": 1,
              "trial_days": 0,
              "limit": null
            },
            "type": "subscription",
            "plan_name": "Weekly"
          },
          "quantity": 1,
          "price": 65,
          "product_id": "6256eb710c7aaf0012dd1722",
          "id": "62599ad09a57a6001a8ca827",
          "orig_price": 65,
          "shipment_weight": 0,
          "price_total": 65,
          "discount_total": 0,
          "discount_each": 0
        }
      ],
      "subscription_delivery": true,
      "currency": "USD",
      "sub_total": 65,
      "item_discount": 0,
      "discount_total": 0,
      "grand_total": 65,
      "date_created": "2022-04-15T16:18:24.644Z",
      "active": true,
      "date_updated": "2022-04-15T16:31:35.254Z",
      "id": "midpIahm"
    },
    {...}
  ],
  "page": 1,
  "page_count": 3,
  "limit": 15,
  "pages": {
    "1": {
      "start": 1,
      "end": 15
    },
    "2": {
      "start": 16,
      "end": 30
    },
    "3": {
      "start": 31,
      "end": 39
    }
  }
}
```
