Categories
Categories
The Categories endpoint returns all available categories in the Quote Gallery catalog. Categories are used to organize quotes and authors by topic or theme.
List Categories
Retrieve all available categories along with the number of quotes in each.
GET /api/v1/categories
Query Parameters
This endpoint does not accept any query parameters. It always returns the full list of categories.
Example Request
curl -H "X-API-Key: your_api_key_here" \
"https://quotegallery.nl/api/v1/categories"
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((category) => {
console.log(`${category.name}: ${category.quoteCount} quotes`)
})
import requests
import os
response = requests.get(
'https://quotegallery.nl/api/v1/categories',
headers={'X-API-Key': os.environ['QUOTE_GALLERY_API_KEY']}
)
categories = response.json()['data']
for category in categories:
print(f'{category["name"]}: {category["quoteCount"]} quotes')
Example Response
{
"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 },
{ "id": "love", "name": "Love", "quoteCount": 112 },
{ "id": "humor", "name": "Humor", "quoteCount": 98 },
{ "id": "technology", "name": "Technology", "quoteCount": 76 },
{ "id": "leadership", "name": "Leadership", "quoteCount": 64 },
{ "id": "science", "name": "Science", "quoteCount": 53 }
]
}
Response Fields
| Field | Type | Description |
|---|---|---|
data | array | Array of category objects |
data[].id | string | Unique slug identifier for the category (used in filter parameters) |
data[].name | string | Human-readable display name of the category |
data[].quoteCount | number | Total number of approved quotes tagged with this category |
Error Responses
| Status | Description |
|---|---|
401 | Unauthorized — missing or invalid API key |
Using Categories with Other Endpoints
Categories are referenced by their id (slug) across the API. You can use the categories query parameter on several endpoints to filter results.
Filtering Quotes by Category
Pass one or more category IDs (comma-separated) to the quotes list endpoint:
# Single category
curl -H "X-API-Key: your_api_key_here" \
"https://quotegallery.nl/api/v1/quotes?categories=wisdom"
# Multiple categories (OR logic — quotes matching any of the categories)
curl -H "X-API-Key: your_api_key_here" \
"https://quotegallery.nl/api/v1/quotes?categories=wisdom,philosophy,life"
Filtering Authors by Category
Similarly, filter authors who have quotes in specific categories:
curl -H "X-API-Key: your_api_key_here" \
"https://quotegallery.nl/api/v1/authors?categories=technology,science"
Filtering Playlists by Category
Find playlists tagged with specific categories:
curl -H "X-API-Key: your_api_key_here" \
"https://quotegallery.nl/api/v1/playlists?categories=inspirational"
Use Cases
Here are some common patterns for working with the Categories endpoint:
Category Navigation Menu
Build a navigation menu that lets users browse by category:
async function buildCategoryNav(apiKey) {
const response = await fetch(
'https://quotegallery.nl/api/v1/categories',
{ headers: { 'X-API-Key': apiKey } }
)
const { data: categories } = await response.json()
// Sort by quote count (most popular first)
return categories
.sort((a, b) => b.quoteCount - a.quoteCount)
.map((category) => ({
label: `${category.name} (${category.quoteCount})`,
value: category.id,
}))
}
Category Tag Cloud
Generate a weighted tag cloud based on quote counts:
async function getCategoryCloud(apiKey) {
const response = await fetch(
'https://quotegallery.nl/api/v1/categories',
{ headers: { 'X-API-Key': apiKey } }
)
const { data: categories } = await response.json()
const maxCount = Math.max(...categories.map((c) => c.quoteCount))
const minCount = Math.min(...categories.map((c) => c.quoteCount))
const range = maxCount - minCount || 1
return categories.map((category) => ({
id: category.id,
name: category.name,
count: category.quoteCount,
// Normalize weight between 0.5 and 2.0 for font sizing
weight: 0.5 + ((category.quoteCount - minCount) / range) * 1.5,
}))
}
Cached Category Lookup
Cache the categories list and provide a lookup helper:
let cachedCategories = null
let cacheExpiry = 0
async function getCategories(apiKey) {
const now = Date.now()
if (cachedCategories && now < cacheExpiry) {
return cachedCategories
}
const response = await fetch(
'https://quotegallery.nl/api/v1/categories',
{ headers: { 'X-API-Key': apiKey } }
)
const { data } = await response.json()
cachedCategories = data
cacheExpiry = now + 4 * 60 * 60 * 1000 // Cache for 4 hours
return cachedCategories
}
async function getCategoryName(apiKey, categoryId) {
const categories = await getCategories(apiKey)
const category = categories.find((c) => c.id === categoryId)
return category?.name ?? categoryId
}
Category Statistics Dashboard
import requests
import os
api_key = os.environ['QUOTE_GALLERY_API_KEY']
response = requests.get(
'https://quotegallery.nl/api/v1/categories',
headers={'X-API-Key': api_key}
)
categories = response.json()['data']
total_quotes = sum(c['quoteCount'] for c in categories)
print(f'Total categories: {len(categories)}')
print(f'Total categorized quotes: {total_quotes}')
print(f'Average quotes per category: {total_quotes // len(categories)}')
print()
print('Category breakdown:')
for category in sorted(categories, key=lambda c: c['quoteCount'], reverse=True):
pct = (category['quoteCount'] / total_quotes) * 100
bar = '█' * int(pct / 2)
print(f' {category["name"]:20s} {category["quoteCount"]:>5d} ({pct:5.1f}%) {bar}')