---
title: "Categories"
description: "API reference for the Categories endpoint - retrieve all available categories with quote counts."
canonical_url: "https://docs.quotegallery.nl/docs/api/categories"
---
# Categories

> API reference for the Categories endpoint - retrieve all available categories with quote counts.

Categories organize quotes and authors by topic or theme. The Categories endpoint returns the full list in one call - no pagination needed.

## List Categories

```text
GET /api/v1/categories
```

This endpoint accepts no query parameters.

<tabs>
<tabs-item label="cURL">

```bash
curl -H "X-API-Key: your_api_key_here" \
  "https://quotegallery.nl/api/v1/categories"
```

</tabs-item>

<tabs-item label="JavaScript">

```js
const response = await fetch(
  'https://quotegallery.nl/api/v1/categories',
  { headers: { 'X-API-Key': process.env.QUOTE_GALLERY_API_KEY } }
)

const { data: categories } = await response.json()

categories.forEach((c) => console.log(`${c.name}: ${c.quoteCount} quotes`))
```

</tabs-item>

<tabs-item label="Python">

```python
import requests, os

response = requests.get(
    'https://quotegallery.nl/api/v1/categories',
    headers={'X-API-Key': os.environ['QUOTE_GALLERY_API_KEY']}
)

for c in response.json()['data']:
    print(f'{c["name"]}: {c["quoteCount"]} quotes')
```

</tabs-item>
</tabs>

```json
{
  "data": [
    { "id": "wisdom", "name": "Wisdom", "quoteCount": 245 },
    { "id": "philosophy", "name": "Philosophy", "quoteCount": 189 },
    { "id": "life", "name": "Life", "quoteCount": 167 },
    { "id": "inspirational", "name": "Inspirational", "quoteCount": 156 },
    { "id": "success", "name": "Success", "quoteCount": 134 }
  ]
}
```

<table>
<thead>
  <tr>
    <th>
      Field
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        data[].id
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      Category slug, used in filter parameters
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        data[].name
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      Human-readable display name
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        data[].quoteCount
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      Approved quotes in this category, counted over a sample of up to 2,000. Use it to compare categories, not as a total
    </td>
  </tr>
</tbody>
</table>

<table>
<thead>
  <tr>
    <th>
      Status
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        401
      </code>
    </td>
    
    <td>
      Missing or invalid API key
    </td>
  </tr>
</tbody>
</table>

<callout type="tip">

The categories list is small and changes infrequently. Cache it for a few hours to avoid burning requests on repeat calls.

</callout>

## Using categories with other endpoints

Category slugs from the `id` field are what you pass as the `categories` parameter on Quotes, Authors, and Playlists endpoints. Multiple slugs are comma-separated and match with OR logic.

```bash
# Quotes in any of these categories
curl -H "X-API-Key: your_api_key_here" \
  "https://quotegallery.nl/api/v1/quotes?categories=wisdom,philosophy,life"

# Authors associated with courage or leadership
curl -H "X-API-Key: your_api_key_here" \
  "https://quotegallery.nl/api/v1/authors?categories=courage,leadership"

# Playlists tagged as inspirational
curl -H "X-API-Key: your_api_key_here" \
  "https://quotegallery.nl/api/v1/playlists?categories=inspirational"
```

## Example: cached category lookup

```js
let cache = null
let expiry = 0

async function getCategories(apiKey) {
  if (cache && Date.now() < expiry) return cache

  const response = await fetch(
    'https://quotegallery.nl/api/v1/categories',
    { headers: { 'X-API-Key': apiKey } }
  )

  const { data } = await response.json()
  cache = data
  expiry = Date.now() + 4 * 60 * 60 * 1000 // 4 hours

  return cache
}

async function getCategoryName(apiKey, slug) {
  const categories = await getCategories(apiKey)
  return categories.find((c) => c.id === slug)?.name ?? slug
}
```


## Sitemap

See the full [sitemap](https://docs.quotegallery.nl/sitemap.md) for all pages.
