# List all accounts

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

Return a list of customer accounts.

## 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 /accounts`

**cURL**

```bash
$ curl https://api.swell.store/accounts?limit=25&page=1 \
  -u store-id:secret-key \
  -G
```

**Node**

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

await swell.get('/accounts', {
  where: {
    order_count: {
      $gt: 1
    }
  },
  limit: 25,
  page: 1
});
```

**PHP**

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

$swell->get('/accounts', [
  'where' => [
    'order_count' => [
      '$gt' => 1
    ]
  ],
  'limit' => 25,
  'page' => 1
]);
```

## Example response

```json
{
  "count": 51,
  "results": [
  {
  "type": "individual",
  "email": "customer@example.com",
  "balance": 50,
  "billing": {
    "name": "Martin Septim",
    "first_name": "Martin",
    "last_name": "Septim",
    "address1": "Waynon Priory",
    "city": "Chorrol",
    "state": "NY",
    "zip": 11201,
    "country": "US",
    "phone": "(555) 555-5555",
    "method": "card",
    "card": {
      "token": "card_1Ds1K7E30PFlZWil6Q7bJ1PD",
      "test": true,
      "last4": "4242",
      "brand": "Visa",
      "address_check": "unchecked",
      "zip_check": "unchecked",
      "cvc_check": "unchecked",
      "exp_month": 1,
      "exp_year": 2029,
      "fingerprint": "3e63991847bbdaafdbc5c8f110ad803f"
    },
    "account_card_id": "5c3ac9870b3b171a7dfaf089"
  },
  "cart_abandoned_count": 18,
  "currency": "USD",
  "date_created": "2021-07-16T14:35:59.938Z",
  "date_first_cart_abandoned": "2018-01-01T00:00:00.000Z",
  "date_first_order": "2019-01-01T00:00:00.000Z",
  "date_last_cart_abandoned": "2021-07-16T14:35:59.938Z",
  "date_last_login": "2021-07-16T14:35:59.938Z",
  "date_last_order": "2021-07-16T14:35:59.938Z",
  "date_updated": "2021-07-16T14:35:59.938Z",
  "first_name": "Martin",
  "group": "Dragonborn",
  "last_name": "Septim",
  "name": "Martin Septim",
  "order_value": 5,
  "password": "$2a$06$hnxbq8likRXJFRa6VrKn7uayucRZw1dH5EQsHwPbWliy3FoNYIpIq",
  "password_reset_key": null,
  "password_reset_url": null,
  "phone": "(555) 555-5555",
  "shipping": {
    "name": "Martin Septim",
    "first_name": "Martin",
    "last_name": "Septim",
    "address1": "Waynon Priory",
    "city": "Chorrol",
    "state": "NY",
    "zip": 11201,
    "country": "US",
    "phone": "(555) 555-5555",
    "account_address_id": "5c12c5fdfcd74b34e19cf659"
  },
  "notes": "\"Voiced by Sean Bean.\"",
  "id": "60f1994f9111e70000000007"
  },
    {...},
    {...}
  ],
  "page": 1,
  "page_count": 3,
  "limit": 25,
  "pages": {
    "1": {
      "start": 1,
      "end": 25
    },
    "2": {
      "start": 26,
      "end": 50
    },
    "3": {
      "start": 51,
      "end": 51
    }
  }
}
```
