Random Quote API: The Complete Guide

Need to display random quotes in your application? This guide covers everything you need to know about getting random quotes via API, including categories, filtering options, and implementation examples.

Types of Quotes

The API provides access to thousands of curated quotes from various sources. Quotes are categorized to help you find the perfect content for your application's context and audience.

Each quote includes the text, author, and optional metadata like category, source, and tags.

Filtering and Categories

Available quote categories:

Inspirational

Uplifting quotes about dreams, perseverance, and potential. Great for motivation apps.

Motivational

Action-oriented quotes about success, hard work, and achievement.

Wisdom

Thoughtful quotes about life, philosophy, and human nature.

Humor

Witty and funny quotes to bring a smile. Good for entertainment features.

Technology

Quotes about innovation, programming, and the digital world.

Attribution: Always display the author name when showing quotes. It's both respectful and adds credibility to your content.

Using the Random Quote API

TinyFn provides a simple endpoint to get random quotes:

API Request
GET https://api.tinyfn.io/v1/random/quote?category=inspirational
Headers: X-API-Key: your-api-key
Response
{
  "quote": "The only way to do great work is to love what you do.",
  "author": "Steve Jobs",
  "category": "inspirational",
  "tags": ["work", "passion", "success"],
  "source": "Stanford Commencement Speech, 2005"
}

Parameters

Parameter Type Description
category string Filter by category (optional)
author string Filter by author name (optional)
tag string Filter by tag (optional)
max_length integer Maximum quote length in characters
count integer Number of quotes to return (default: 1)

Code Examples

JavaScript / Node.js

const response = await fetch(
  'https://api.tinyfn.io/v1/random/quote?category=inspirational',
  { headers: { 'X-API-Key': 'your-api-key' } }
);
const { quote, author } = await response.json();
console.log(`"${quote}" - ${author}`);
// "The only way to do great work is to love what you do." - Steve Jobs

Python

import requests

response = requests.get(
    'https://api.tinyfn.io/v1/random/quote',
    params={'category': 'inspirational'},
    headers={'X-API-Key': 'your-api-key'}
)
data = response.json()
print(f'"{data["quote"]}" - {data["author"]}')

cURL

curl "https://api.tinyfn.io/v1/random/quote?category=inspirational" \
  -H "X-API-Key: your-api-key"

Common Use Cases

  • Daily Quote Features: Quote of the day widgets and notifications
  • Loading Screens: Display quotes while content loads
  • Email Signatures: Rotating quotes in email footers
  • Social Media: Auto-post daily quotes
  • Meditation Apps: Inspirational quotes for mindfulness

Best Practices

  1. Always attribute: Display the author with every quote
  2. Cache appropriately: Cache "quote of the day" for 24 hours
  3. Match context: Choose categories that fit your app's purpose
  4. Consider length: Use max_length for UI constraints

Use via MCP

Your AI agent can call this tool directly via Model Context Protocol — no HTTP code needed. Add TinyFn to Claude Desktop, Cursor, or any MCP client:

{
  "mcpServers": {
    "tinyfn-random": {
      "url": "https://api.tinyfn.io/mcp/random/",
      "headers": {
        "X-API-Key": "your-api-key"
      }
    }
  }
}

See all random tools available via MCP in our Random MCP Tools for AI Agents guide.

Try the Random Quote API

Get your free API key and start displaying quotes in seconds.

Get Free API Key

Ready to try TinyFn?

Get your free API key and start building in minutes.

Get Free API Key