Getting Started
Quick Start
Make your first API call to the Quote Gallery API in under 5 minutes.
Quick Start
Get up and running with the Quote Gallery API in minutes. This guide walks you through making your first API call.
Prerequisites
Before you begin, make sure you have:
- A Quote Gallery account
- An API key (see Authentication)
Step 1: Set Up Your API Key
Store your API key as an environment variable:
export QUOTE_GALLERY_API_KEY="your_api_key_here"
Step 2: Make Your First Request
Let's fetch a list of quotes. You can use any HTTP client — here are examples in several languages.
curl -s -H "X-API-Key: $QUOTE_GALLERY_API_KEY" \
"https://quotegallery.nl/api/v1/quotes?limit=3" | python3 -m json.tool
const API_KEY = process.env.QUOTE_GALLERY_API_KEY
const response = await fetch('https://quotegallery.nl/api/v1/quotes?limit=3', {
headers: { 'X-API-Key': API_KEY },
})
const { data, pagination } = await response.json()
data.forEach((quote) => {
console.log(`"${quote.text}" — ${quote.author.name}`)
})
import os
import requests
api_key = os.environ['QUOTE_GALLERY_API_KEY']
response = requests.get(
'https://quotegallery.nl/api/v1/quotes',
headers={'X-API-Key': api_key},
params={'limit': 3}
)
data = response.json()
for quote in data['data']:
print(f'"{quote["text"]}" — {quote["author"]["name"]}')
Example Response
{
"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
}
}
Step 3: Get a Random Quote
One of the most popular endpoints — perfect for "quote of the day" features:
curl -s -H "X-API-Key: $QUOTE_GALLERY_API_KEY" \
"https://quotegallery.nl/api/v1/quotes/random"
const response = await fetch('https://quotegallery.nl/api/v1/quotes/random', {
headers: { 'X-API-Key': API_KEY },
})
const { data: quote } = await response.json()
console.log(`"${quote.text}" — ${quote.author.name}`)
response = requests.get(
'https://quotegallery.nl/api/v1/quotes/random',
headers={'X-API-Key': api_key}
)
quote = response.json()['data']
print(f'"{quote["text"]}" — {quote["author"]["name"]}')
Step 4: Filter by Language and Category
Narrow down results using query parameters:
# Get inspirational quotes in English
curl -s -H "X-API-Key: $QUOTE_GALLERY_API_KEY" \
"https://quotegallery.nl/api/v1/quotes?language=en&categories=inspirational&limit=5"
Step 5: Browse Authors
Explore the authors in the catalog:
# Search for authors by name
curl -s -H "X-API-Key: $QUOTE_GALLERY_API_KEY" \
"https://quotegallery.nl/api/v1/authors?search=einstein&limit=5"
Step 6: Explore Playlists
Access curated collections of quotes:
# Get public playlists
curl -s -H "X-API-Key: $QUOTE_GALLERY_API_KEY" \
"https://quotegallery.nl/api/v1/playlists?limit=5"
# Get a playlist with its quotes included
curl -s -H "X-API-Key: $QUOTE_GALLERY_API_KEY" \
"https://quotegallery.nl/api/v1/playlists/playlist123?include_quotes=true"
Common Patterns
Pagination
All list endpoints support pagination with limit and offset:
async function getAllQuotes(apiKey) {
const quotes = []
let offset = 0
const limit = 100
while (true) {
const response = await fetch(
`https://quotegallery.nl/api/v1/quotes?limit=${limit}&offset=${offset}`,
{ headers: { 'X-API-Key': apiKey } }
)
const { data, pagination } = await response.json()
quotes.push(...data)
if (!pagination.hasMore) break
offset += limit
}
return quotes
}
Error Handling
Always check the response status and handle errors gracefully:
const response = await fetch('https://quotegallery.nl/api/v1/quotes', {
headers: { 'X-API-Key': API_KEY },
})
if (!response.ok) {
const error = await response.json()
if (response.status === 429) {
console.log('Rate limited — wait and retry')
} else if (response.status === 401) {
console.log('Check your API key')
} else {
console.log(`Error ${response.status}: ${error.message}`)
}
}