Getting Started
Quick Start
Make your first API call to the Quote Gallery API in under 5 minutes.
This guide walks you through making your first requests. You'll need a Quote Gallery account and an API key before you start — see Authentication if you haven't set that up yet.
Set up your API key
Store your key as an environment variable so it's never hardcoded in your source:
export QUOTE_GALLERY_API_KEY="your_api_key_here"
Fetch some quotes
curl -s -H "X-API-Key: $QUOTE_GALLERY_API_KEY" \
"https://quotegallery.nl/api/v1/quotes?limit=3"
const response = await fetch('https://quotegallery.nl/api/v1/quotes?limit=3', {
headers: { 'X-API-Key': process.env.QUOTE_GALLERY_API_KEY },
})
const { data, pagination } = await response.json()
data.forEach((quote) => {
console.log(`"${quote.text}" — ${quote.author.name}`)
})
import os, requests
response = requests.get(
'https://quotegallery.nl/api/v1/quotes',
headers={'X-API-Key': os.environ['QUOTE_GALLERY_API_KEY']},
params={'limit': 3}
)
for quote in response.json()['data']:
print(f'"{quote["text"]}" — {quote["author"]["name"]}')
The response looks like this:
{
"data": [
{
"id": "abc123",
"text": "The only way to do great work is to love what you do.",
"language": "en",
"categories": ["wisdom", "success"],
"likeCount": 42,
"author": {
"id": "xyz789",
"name": "Steve Jobs"
},
"createdAt": 1704067200000
}
],
"pagination": {
"total": 150,
"limit": 3,
"offset": 0,
"hasMore": true
}
}
Get a random quote
The random endpoint is perfect for quote-of-the-day features. You can filter by language or category:
curl -s -H "X-API-Key: $QUOTE_GALLERY_API_KEY" \
"https://quotegallery.nl/api/v1/quotes/random?language=en"
const response = await fetch(
'https://quotegallery.nl/api/v1/quotes/random?language=en',
{ headers: { 'X-API-Key': process.env.QUOTE_GALLERY_API_KEY } }
)
const { data: quote } = await response.json()
console.log(`"${quote.text}" — ${quote.author.name}`)
Filter by language and category
Use language and categories query parameters to narrow results. Multiple categories are comma-separated and match with OR logic:
curl -s -H "X-API-Key: $QUOTE_GALLERY_API_KEY" \
"https://quotegallery.nl/api/v1/quotes?language=en&categories=inspirational,wisdom&limit=5"
Search for an author
curl -s -H "X-API-Key: $QUOTE_GALLERY_API_KEY" \
"https://quotegallery.nl/api/v1/authors?search=einstein&limit=5"
Paginate through results
All list endpoints accept limit (max 100) and offset for pagination:
async function getAllQuotes(apiKey) {
const quotes = []
let offset = 0
while (true) {
const response = await fetch(
`https://quotegallery.nl/api/v1/quotes?limit=100&offset=${offset}`,
{ headers: { 'X-API-Key': apiKey } }
)
const { data, pagination } = await response.json()
quotes.push(...data)
if (!pagination.hasMore) break
offset += 100
}
return quotes
}
Handle errors
Check the response status on every request. A failed authentication looks like this:
{
"error": "Invalid API key",
"status": 401
}
const response = await fetch('https://quotegallery.nl/api/v1/quotes', {
headers: { 'X-API-Key': process.env.QUOTE_GALLERY_API_KEY },
})
if (!response.ok) {
const { error } = await response.json()
if (response.status === 429) {
const reset = response.headers.get('X-RateLimit-Reset')
console.log(`Rate limited — resets at ${new Date(reset * 1000)}`)
} else if (response.status === 401) {
console.error('Check your API key')
} else {
console.error(`Error ${response.status}: ${error}`)
}
}