/i18n-quotes

Retrieves random quotes in different languages

Primary LanguageTypeScriptThe UnlicenseUnlicense

A Quotes API used by Bonjourr

Tests

This API returns quotes using 3 different providers:

  • Random quotes found on the internet
  • Inspirational quotes by inspirobot
  • Famous quotes from the tv show kaamelott

⚠️ For performance reasons when used in Bonjourr API, classic and kaamelott quotes are fetched from this repo using jsDelivr CDN. This may cause problem when forking this repo.

Run and deploy

This API can easily be deployed as a Cloudflare Worker or a Netlify Edge Function. Other integrations might be added in the future.

# pnpm is needed in package scripts
npm install --global pnpm

Cloudflare Worker

npm install --global wrangler

# dev
pnpm cloudflare:dev

# ⎔ Starting local server...
# Ready on http://127.0.0.1:8787  

# deploy
pnpm cloudflare:deploy

Netlify Edge Function

npm install --global netlify

# dev
pnpm netlify:dev

# ◈ Server now ready on http://localhost:8888 
# ◈ Loaded edge function index

# deploy using dashboard

API Endpoints

All endpoints return a list of quotes with the same type

type Quotes = {
  author: string
  content: string
}[]

Classic

Returns 20 random english quotes

GET /classic
[
  {
    "author": "Joseph Campbell",
    "content": "Find a place inside where there's joy, and the joy will burn out the pain."
  },
  {
    "author": "Theodore Roosevelt",
    "content": "With self-discipline most anything is possible."
  },
  // ...
]

Returns 20 random quotes from a specified language

GET /classic/:lang
[
  {
    "author": "Socrate",
    "content": "Tout ce que je sais, c'est que je ne sais rien."
  },
  {
    "content": "L’enthousiasme a toujours engendré la certitude.",
    "author": "Alfred Espinas"
  },
  // ...
]

Inspirobot

Returns at least 10 quotes from Inspirobot

GET /inspirobot
[
  {
    "author": "Inspirobot",
    "content": "Depressions can become memorable."
  },
  {
    "author": "Inspirobot",
    "content": "Notice how your left nostril is connecting to your heart."
  },
  // ...
]

Kaamelott

Returns 20 quotes from a list of kaamelott quotes shamelessly stolen from sin0light/api-kaamelott.

GET /kaamelott
[
  {
    "author": "Le Roi Burgonde",
    "content": "Arthour !… Pas changer assiette pour fromage !"
  },
  {
    "author": "Perceval",
    "content": "Là, vous faites sirop de vingt-et-un et vous dites: beau sirop, mi-sirop, siroté, gagne-sirop, sirop-grelot, passe-montagne, sirop au bon goût."
  },
  // ...
]