# List all categories

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

Return a list of product categories.

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

**cURL**

```bash
$ curl https://api.swell.store/categories?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('/categories', {
  where: {
    active: true
  },
  limit: 25,
  page: 1
});
```

**PHP**

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

$swell->get('/categories', [
  'where' => [
    'active' => true
  ],
  'limit' => 25,
  'page' => 1
]);
```

## Example response

```json
{
  "count": 29,
  "results": [
    {
      "name": "Luck",
      "active": true,
      "sorting": null,
      "images": null,
      "description": null,
      "meta_title": null,
      "meta_description": null,
      "parent_id": "628bae71499bba0019b1aac2",
      "slug": "skills-luck",
      "top_id": "628bae71499bba0019b1aac2",
      "date_created": "2022-05-23T16:06:40.137Z",
      "date_updated": "2022-05-23T16:10:52.946Z",
      "sort": 7,
      "id": "628bb1101869c10019b4205c"
    },
    {
      "name": "Willpower",
      "active": true,
      "sorting": null,
      "images": null,
      "description": null,
      "meta_title": null,
      "meta_description": null,
      "parent_id": "628bae71499bba0019b1aac2",
      "slug": "skills-willpower",
      "top_id": "628bae71499bba0019b1aac2",
      "date_created": "2022-05-23T16:06:33.466Z",
      "date_updated": "2022-05-23T16:10:20.092Z",
      "sort": 5,
      "id": "628bb1091869c10019b4205a"
    },
    {
      "name": "Intelligence",
      "active": true,
      "sorting": null,
      "images": null,
      "description": null,
      "meta_title": null,
      "meta_description": null,
      "parent_id": "628bae71499bba0019b1aac2",
      "slug": "skills-intelligence",
      "top_id": "628bae71499bba0019b1aac2",
      "date_created": "2022-05-23T16:06:23.079Z",
      "date_updated": "2022-05-23T16:10:20.090Z",
      "sort": 6,
      "id": "628bb0ff1869c10019b42058"
    },
    {
      "name": "Personality",
      "active": true,
      "sorting": null,
      "images": null,
      "description": null,
      "meta_title": null,
      "meta_description": null,
      "parent_id": "628bae71499bba0019b1aac2",
      "slug": "skills-personality",
      "top_id": "628bae71499bba0019b1aac2",
      "date_created": "2022-05-23T16:06:13.645Z",
      "date_updated": "2022-05-23T16:10:52.955Z",
      "sort": 4,
      "id": "628bb0f5499bba0019b1ab25"
    },
    {
      "name": "Agility",
      "active": true,
      "sorting": null,
      "images": null,
      "description": null,
      "meta_title": null,
      "meta_description": null,
      "parent_id": "628bae71499bba0019b1aac2",
      "slug": "skills-agility",
      "top_id": "628bae71499bba0019b1aac2",
      "date_created": "2022-05-23T16:06:00.026Z",
      "date_updated": "2022-05-23T16:10:52.961Z",
      "sort": 3,
      "id": "628bb0e81869c10019b42056"
    },
    {
      "name": "Speed",
      "active": true,
      "sorting": null,
      "images": null,
      "description": null,
      "meta_title": null,
      "meta_description": null,
      "parent_id": "628bae71499bba0019b1aac2",
      "slug": "skills-speed",
      "top_id": "628bae71499bba0019b1aac2",
      "date_created": "2022-05-23T16:05:50.621Z",
      "date_updated": "2022-05-23T16:10:52.953Z",
      "sort": 2,
      "id": "628bb0de1869c10019b42054"
    },
    {
      "name": "Endurance",
      "active": true,
      "sorting": null,
      "images": null,
      "description": null,
      "meta_title": null,
      "meta_description": null,
      "parent_id": "628bae71499bba0019b1aac2",
      "slug": "skills-endurance",
      "top_id": "628bae71499bba0019b1aac2",
      "date_created": "2022-05-23T16:05:41.771Z",
      "date_updated": "2022-05-23T16:10:52.941Z",
      "sort": 1,
      "id": "628bb0d5499bba0019b1ab23"
    },
    {
      "name": "Strength",
      "active": true,
      "sorting": null,
      "images": null,
      "description": null,
      "meta_title": null,
      "meta_description": null,
      "parent_id": "628bae71499bba0019b1aac2",
      "slug": "strength",
      "top_id": "628bae71499bba0019b1aac2",
      "date_created": "2022-05-23T16:05:34.393Z",
      "date_updated": "2022-05-23T16:10:52.953Z",
      "sort": 0,
      "id": "628bb0ce499bba0019b1ab21"
    },
    {
      "name": "Speechcraft",
      "active": false,
      "sorting": null,
      "images": null,
      "description": null,
      "meta_title": null,
      "meta_description": null,
      "parent_id": "628bb0f5499bba0019b1ab25",
      "slug": "skills-speechcraft",
      "top_id": "628bae71499bba0019b1aac2",
      "date_created": "2022-05-23T16:05:18.864Z",
      "date_updated": "2022-05-23T16:10:20.092Z",
      "sort": 1,
      "id": "628bb0be499bba0019b1ab1f"
    },
    {
      "name": "Mercantile",
      "active": false,
      "sorting": null,
      "images": null,
      "description": null,
      "meta_title": null,
      "meta_description": null,
      "parent_id": "628bb0f5499bba0019b1ab25",
      "slug": "skills-mercantile",
      "top_id": "628bae71499bba0019b1aac2",
      "date_created": "2022-05-23T16:05:08.369Z",
      "date_updated": "2022-05-23T16:10:20.092Z",
      "sort": 0,
      "id": "628bb0b4499bba0019b1ab1d"
    },
    {
      "name": "Marksman",
      "active": false,
      "sorting": null,
      "images": null,
      "description": null,
      "meta_title": null,
      "meta_description": null,
      "parent_id": "628bb0e81869c10019b42056",
      "slug": "skills-marksman",
      "top_id": "628bae71499bba0019b1aac2",
      "date_created": "2022-05-23T16:04:57.274Z",
      "date_updated": "2022-05-23T16:10:20.112Z",
      "sort": 2,
      "id": "628bb0a91869c10019b42052"
    },
    {
      "name": "Sneak",
      "active": false,
      "sorting": null,
      "images": null,
      "description": null,
      "meta_title": null,
      "meta_description": null,
      "parent_id": "628bb0e81869c10019b42056",
      "slug": "skills-sneak",
      "top_id": "628bae71499bba0019b1aac2",
      "date_created": "2022-05-23T16:04:47.385Z",
      "date_updated": "2022-05-23T16:10:20.112Z",
      "sort": 0,
      "id": "628bb09f1869c10019b42050"
    },
    {
      "name": "Security",
      "active": false,
      "sorting": null,
      "images": null,
      "description": null,
      "meta_title": null,
      "meta_description": null,
      "parent_id": "628bb0e81869c10019b42056",
      "slug": "security",
      "top_id": "628bae71499bba0019b1aac2",
      "date_created": "2022-05-23T16:04:37.967Z",
      "date_updated": "2022-05-23T16:10:20.114Z",
      "sort": 1,
      "id": "628bb0951869c10019b4204e"
    },
    {
      "name": "Light armor",
      "active": false,
      "sorting": null,
      "images": null,
      "description": null,
      "meta_title": null,
      "meta_description": null,
      "parent_id": "628bb0de1869c10019b42054",
      "slug": "skills-light-armor",
      "top_id": "628bae71499bba0019b1aac2",
      "date_created": "2022-05-23T16:04:27.646Z",
      "date_updated": "2022-05-23T16:10:20.114Z",
      "sort": 2,
      "id": "628bb08b499bba0019b1ab1b"
    },
    {
      "name": "Acrobatics",
      "active": false,
      "sorting": null,
      "images": null,
      "description": null,
      "meta_title": null,
      "meta_description": null,
      "parent_id": "628bb0de1869c10019b42054",
      "slug": "skills-acrobatics",
      "top_id": "628bae71499bba0019b1aac2",
      "date_created": "2022-05-23T16:04:17.292Z",
      "date_updated": "2022-05-23T16:10:20.114Z",
      "sort": 1,
      "id": "628bb0811869c10019b4204c"
    }
  ],
  "page": 1,
  "page_count": 2,
  "limit": 25,
  "pages": {
    "1": {
      "start": 1,
      "end": 25
    },
    "2": {
      "start": 26,
      "end": 29
    }
  }
}
```
