Guides
SDKs & Libraries
Official and community SDKs, libraries, and tools for integrating with the Quote Gallery API.
The Quote Gallery API works with any HTTP client, but a thin wrapper makes things more pleasant. Below are copy-paste clients for JavaScript and Python, plus snippets for other languages.
JavaScript / TypeScript client
A lightweight, zero-dependency client you can drop directly into your project:
class QuoteGalleryClient {
constructor(apiKey, options = {}) {
this.apiKey = apiKey
this.baseUrl = options.baseUrl ?? 'https://quotegallery.nl/api/v1'
}
async request(endpoint, params = {}) {
const url = new URL(`${this.baseUrl}${endpoint}`)
Object.entries(params).forEach(([k, v]) => {
if (v !== undefined && v !== null) url.searchParams.set(k, String(v))
})
const response = await fetch(url.toString(), {
headers: { 'X-API-Key': this.apiKey },
})
if (!response.ok) {
const error = await response.json()
throw new Error(`API Error ${response.status}: ${error.error}`)
}
return response.json()
}
getQuotes(params) { return this.request('/quotes', params) }
getRandomQuote(params) { return this.request('/quotes/random', params) }
getQuote(id, params) { return this.request(`/quotes/${id}`, params) }
getAuthors(params) { return this.request('/authors', params) }
getAuthor(id, params) { return this.request(`/authors/${id}`, params) }
getPlaylists(params) { return this.request('/playlists', params) }
getPlaylist(id, params) { return this.request(`/playlists/${id}`, params) }
getCategories() { return this.request('/categories') }
}
const client = new QuoteGalleryClient(process.env.QUOTE_GALLERY_API_KEY)
const { data: quotes } = await client.getQuotes({ language: 'en', limit: 5 })
const { data: random } = await client.getRandomQuote({ language: 'en' })
const { data: categories } = await client.getCategories()
For production use — retries, timeouts, and structured error handling — see the full client in the Error Handling guide.
Python client
A minimal Python wrapper using requests.Session for connection reuse:
import os
import requests
class QuoteGalleryClient:
def __init__(self, api_key=None, base_url='https://quotegallery.nl/api/v1'):
self.api_key = api_key or os.environ.get('QUOTE_GALLERY_API_KEY')
self.base_url = base_url
self.session = requests.Session()
self.session.headers.update({'X-API-Key': self.api_key})
def _request(self, endpoint, params=None):
response = self.session.get(f'{self.base_url}{endpoint}', params=params)
response.raise_for_status()
return response.json()
def get_quotes(self, **params): return self._request('/quotes', params)
def get_random_quote(self, **params): return self._request('/quotes/random', params)
def get_quote(self, quote_id, **params): return self._request(f'/quotes/{quote_id}', params)
def get_authors(self, **params): return self._request('/authors', params)
def get_author(self, author_id, **params): return self._request(f'/authors/{author_id}', params)
def get_playlists(self, **params): return self._request('/playlists', params)
def get_playlist(self, playlist_id, **params): return self._request(f'/playlists/{playlist_id}', params)
def get_categories(self): return self._request('/categories')
client = QuoteGalleryClient()
quotes = client.get_quotes(language='en', limit=5)
random_quote = client.get_random_quote(language='en')
categories = client.get_categories()
Community libraries
No community packages yet — be the first to build one! If you publish a library for the Quote Gallery API, open a pull request on our GitHub repository to get it listed here.
Other languages
PHP
<?php
$apiKey = getenv('QUOTE_GALLERY_API_KEY');
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => 'https://quotegallery.nl/api/v1/quotes?limit=5',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["X-API-Key: $apiKey"],
]);
$data = json_decode(curl_exec($ch), true);
curl_close($ch);
foreach ($data['data'] as $quote) {
echo "\"{$quote['text']}\" — {$quote['author']['name']}\n";
}
Ruby
require 'net/http'
require 'json'
require 'uri'
uri = URI('https://quotegallery.nl/api/v1/quotes?limit=5')
request = Net::HTTP::Get.new(uri)
request['X-API-Key'] = ENV['QUOTE_GALLERY_API_KEY']
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |h| h.request(request) }
data = JSON.parse(response.body)
data['data'].each { |q| puts "\"#{q['text']}\" — #{q['author']['name']}" }
Go
package main
import (
"encoding/json"
"fmt"
"io"
"net/http"
"os"
)
func main() {
req, _ := http.NewRequest("GET", "https://quotegallery.nl/api/v1/quotes?limit=5", nil)
req.Header.Set("X-API-Key", os.Getenv("QUOTE_GALLERY_API_KEY"))
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
var result map[string]interface{}
json.Unmarshal(body, &result)
fmt.Println(string(body))
}
Rust
use reqwest::header;
use serde_json::Value;
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let api_key = env::var("QUOTE_GALLERY_API_KEY")?;
let response = reqwest::Client::new()
.get("https://quotegallery.nl/api/v1/quotes?limit=5")
.header("X-API-Key", &api_key)
.send()
.await?
.json::<Value>()
.await?;
println!("{:#}", response);
Ok(())
}
SDK guidelines
Building a wrapper? A few things that matter:
- Include the version in the base URL (
/api/v1) and allow overriding it — makes future upgrades easier. - Handle
429and5xxwith exponential backoff. ParseX-RateLimit-Resetfor optimal retry timing. - Read the API key from
QUOTE_GALLERY_API_KEYby default so it works without configuration. - Expose typed response models if your language supports it.