# QuoteLore API

Public, unauthenticated JSON API for the Cascade quote dataset.

**Host:** `https://api.casw.app`

**Base path:** `/quotelore`

**CORS:** open (`Access-Control-Allow-Origin: *`)

**Methods:** `GET`, `HEAD`, `OPTIONS`

Raw markdown: [/docs/quotelore.md](/docs/quotelore.md)

Related: [Edge API](/docs/edge) — the original five dynamic routes at `/edge`.

| | |
|---|---|
| Quotes | 4048 |
| Authors | 1039 |
| Tags | film, indian-thinkers, leaders, literature, philosophy, science, sports |

---

## Endpoints

| Method | Path | What it returns |
|---|---|---|
| GET | [/quotelore](/quotelore) | Catalog, counts, endpoint list |
| GET | [/quotelore/quote](/quotelore/quote?id=1) | One quote by `id` |
| GET | [/quotelore/quotes](/quotelore/quotes) | Paginated quotes |
| GET | [/quotelore/search](/quotelore/search?q=life) | Search quotes |
| GET | [/quotelore/random](/quotelore/random) | Random quote(s) |
| GET | [/quotelore/today](/quotelore/today) | Quote of the day (IST) |
| GET | [/quotelore/author](/quotelore/author?slug=socrates) | Author + all of their quotes |
| GET | [/quotelore/authors](/quotelore/authors) | Paginated authors |
| GET | [/quotelore/authors/search](/quotelore/authors/search?q=curie) | Search authors |
| GET | [/quotelore/tag](/quotelore/tag?name=philosophy) | One tag + its quotes |
| GET | [/quotelore/tags](/quotelore/tags) | All tags |

Production examples use `https://api.casw.app`. The same paths work on this host.

---

## Shared query parameters

These filters work on `/quotelore/quotes`, `/quotelore/search`, and `/quotelore/random`.

| Param | Required | Description |
|---|---|---|
| `tag` | no | One of: `film`, `indian-thinkers`, `leaders`, `literature`, `philosophy`, `science`, `sports` |
| `author` | no | Author slug, e.g. `socrates` |
| `minlen` | no | Minimum quote character length. Default `0` |
| `maxlen` | no | Maximum quote character length. Default unlimited |
| `photo` | no | `1` or `true` — only authors with a portrait photo |
| `grade` | no | `A` or `B` |
| `film` | no | `1` only film dialogue, `0` exclude film dialogue |
| `kind` | no | `person` or `character` |
| `page` | no | Page number. Default `1`. Max `1000` |
| `limit` | no | Page size. Default `20`. Max `50` |

---

## GET /quotelore/quote

One quote by numeric id.

| Param | Required | Description |
|---|---|---|
| `id` | yes | Quote id, `1`–`4048` |

```
GET https://api.casw.app/quotelore/quote?id=1
```

Sample response:

```json
{
  "id": 1,
  "text": "The unexamined life is not worth living.",
  "length": 40,
  "author": {
    "name": "Socrates",
    "slug": "socrates",
    "role": "Greek philosopher",
    "years": "c. 470–399 BC",
    "bio": "Wrote nothing himself. We know him through his students, mainly Plato.",
    "kind": "person",
    "wikidata_id": "Q913",
    "image": {
      "256": "https://api.casw.app/quotelore/img/authors/256/socrates.jpg",
      "512": "https://api.casw.app/quotelore/img/authors/512/socrates.jpg"
    },
    "image_type": "photo",
    "license": "Public domain",
    "url": "https://api.casw.app/quotelore/author?slug=socrates"
  },
  "source": "Plato, Apology 38a",
  "year": "c. 399 BC",
  "context": "Said at his own trial, when he chose death over giving up philosophy.",
  "tags": ["philosophy"],
  "grade": "A",
  "film_dialogue": false,
  "url": "https://api.casw.app/quotelore/quote?id=1"
}
```

Errors: `400` missing `id`, `404` unknown id.

---

## GET /quotelore/quotes

Paginated list. Combine any shared filters.

```
GET https://api.casw.app/quotelore/quotes?tag=philosophy&page=1&limit=20
GET https://api.casw.app/quotelore/quotes?author=socrates
GET https://api.casw.app/quotelore/quotes?photo=1&grade=A&minlen=25&maxlen=200
GET https://api.casw.app/quotelore/quotes?film=1&kind=character
```

Sample response:

```json
{
  "total": 618,
  "page": 1,
  "limit": 20,
  "results": [
    {
      "id": 1,
      "text": "The unexamined life is not worth living.",
      "author": { "name": "Socrates", "slug": "socrates" },
      "tags": ["philosophy"]
    }
  ]
}
```

---

## GET /quotelore/search

Full-text search over quote text, author name/slug, source, and role. `q` must be at least 2 characters. Shared filters still apply.

| Param | Required | Description |
|---|---|---|
| `q` | yes | Search string, min 2 characters |
| `page` | no | Default `1` |
| `limit` | no | Default `20`, max `50` |

```
GET https://api.casw.app/quotelore/search?q=unexamined%20life
GET https://api.casw.app/quotelore/search?q=gandhi&tag=leaders
GET https://api.casw.app/quotelore/search?q=science&photo=1&page=2
```

Sample response:

```json
{
  "query": "unexamined life",
  "total": 1,
  "page": 1,
  "limit": 20,
  "results": [
    {
      "id": 1,
      "text": "The unexamined life is not worth living.",
      "author": {
        "name": "Socrates",
        "slug": "socrates"
      }
    }
  ]
}
```

Errors: `400` if `q` is shorter than 2 characters.

```json
{ "error": "q_too_short", "hint": "?q= needs at least 2 characters" }
```

---

## GET /quotelore/random

Random quote from the filtered pool.

| Param | Required | Description |
|---|---|---|
| `count` | no | How many quotes, `1`–`20`. Default `1` (bare quote object). `count>1` wraps `{ count, quotes }` |

```
GET https://api.casw.app/quotelore/random
GET https://api.casw.app/quotelore/random?tag=science&photo=1
GET https://api.casw.app/quotelore/random?count=3&tag=sports
GET https://api.casw.app/quotelore/random?author=sagan&maxlen=120
```

Sample (`count` omitted): same shape as `/quotelore/quote`.

Sample (`count=3`):

```json
{
  "count": 3,
  "quotes": [
    { "id": 201, "text": "...", "tags": ["sports"] },
    { "id": 844, "text": "...", "tags": ["sports"] },
    { "id": 1102, "text": "...", "tags": ["sports"] }
  ]
}
```

Errors: `404` `{ "error": "no_match" }` when filters match nothing.

---

## GET /quotelore/today

Deterministic quote of the day. Same quote for everyone until midnight **Asia/Kolkata**. No query params.

```
GET https://api.casw.app/quotelore/today
```

Sample response:

```json
{
  "date": "2026-11-28",
  "timezone": "Asia/Kolkata",
  "quote": {
    "id": 1240,
    "text": "...",
    "author": { "name": "...", "slug": "..." }
  }
}
```

---

## GET /quotelore/author

Author profile plus every quote by that author. Quotes in this payload omit the nested `author` object.

| Param | Required | Description |
|---|---|---|
| `slug` | yes | Author slug, e.g. `socrates`, `marie-curie` |

```
GET https://api.casw.app/quotelore/author?slug=socrates
GET https://api.casw.app/quotelore/author?slug=marie-curie
```

Sample response:

```json
{
  "name": "Socrates",
  "slug": "socrates",
  "role": "Greek philosopher",
  "years": "c. 470–399 BC",
  "kind": "person",
  "image_type": "photo",
  "quote_count": 1,
  "count": 1,
  "url": "https://api.casw.app/quotelore/author?slug=socrates",
  "quotes": [
    {
      "id": 1,
      "text": "The unexamined life is not worth living.",
      "source": "Plato, Apology 38a",
      "tags": ["philosophy"]
    }
  ]
}
```

Errors: `400` missing `slug`, `404` unknown slug.

---

## GET /quotelore/authors

Paginated authors.

| Param | Required | Description |
|---|---|---|
| `page` | no | Default `1` |
| `limit` | no | Default `20`, max `50` |
| `kind` | no | `person` or `character` |
| `photo` | no | `1` to keep portrait photos |

```
GET https://api.casw.app/quotelore/authors
GET https://api.casw.app/quotelore/authors?kind=person&photo=1
GET https://api.casw.app/quotelore/authors?kind=character&page=2
```

Sample response:

```json
{
  "total": 839,
  "page": 1,
  "limit": 20,
  "results": [
    {
      "name": "A. C. Bhaktivedanta Swami Prabhupada",
      "slug": "a-c-bhaktivedanta-swami-prabhupada",
      "kind": "person",
      "quote_count": 3,
      "image_type": "photo"
    }
  ]
}
```

---

## GET /quotelore/authors/search

Search authors by name, slug, role, or bio.

| Param | Required | Description |
|---|---|---|
| `q` | yes | Search string, min 2 characters |
| `page` | no | Default `1` |
| `limit` | no | Default `20`, max `50` |
| `kind` | no | `person` or `character` |
| `photo` | no | `1` to keep portrait photos |

```
GET https://api.casw.app/quotelore/authors/search?q=curie
GET https://api.casw.app/quotelore/authors/search?q=gandhi
GET https://api.casw.app/quotelore/authors/search?q=bourne&kind=character
```

Sample response:

```json
{
  "query": "curie",
  "total": 1,
  "page": 1,
  "limit": 20,
  "results": [
    {
      "name": "Marie Curie",
      "slug": "marie-curie",
      "role": "Physicist and chemist",
      "quote_count": 4
    }
  ]
}
```

---

## GET /quotelore/tag

One tag plus paginated quotes for that tag.

| Param | Required | Description |
|---|---|---|
| `name` | yes | Tag slug. Alias: `tag` |
| `page` | no | Default `1` |
| `limit` | no | Default `20`, max `50` |

```
GET https://api.casw.app/quotelore/tag?name=philosophy
GET https://api.casw.app/quotelore/tag?name=sports&page=1&limit=10
GET https://api.casw.app/quotelore/tag?tag=film
```

Sample response:

```json
{
  "tag": "philosophy",
  "label": "Philosophy",
  "count": 618,
  "url": "https://api.casw.app/quotelore/tag?name=philosophy",
  "total": 618,
  "page": 1,
  "limit": 20,
  "results": []
}
```

---

## GET /quotelore/tags

All tags. No query params.

```
GET https://api.casw.app/quotelore/tags
```

Sample response:

```json
{
  "count": 7,
  "tags": [
    { "tag": "film", "label": "Film", "count": 483 },
    { "tag": "indian-thinkers", "label": "Indian thinkers", "count": 569 },
    { "tag": "leaders", "label": "Leaders", "count": 652 },
    { "tag": "literature", "label": "Literature", "count": 917 },
    { "tag": "philosophy", "label": "Philosophy", "count": 618 },
    { "tag": "science", "label": "Science", "count": 525 },
    { "tag": "sports", "label": "Sports", "count": 284 }
  ]
}
```

---

## Images

Portraits are static files, not JSON routes.

```
https://api.casw.app/quotelore/img/authors/256/{slug}.jpg
https://api.casw.app/quotelore/img/authors/512/{slug}.jpg
```

`image_type` is `photo` (real portrait) or `initials` (generated tile).

---

## Errors

| Status | Body | When |
|---|---|---|
| 400 | `{ "error": "missing_id" }` | `/quote` without `id` |
| 400 | `{ "error": "missing_slug" }` | `/author` without `slug` |
| 400 | `{ "error": "missing_name" }` | `/tag` without `name` |
| 400 | `{ "error": "q_too_short" }` | search `q` shorter than 2 chars |
| 404 | `{ "error": "not_found" }` | unknown id, slug, or tag |
| 404 | `{ "error": "no_match" }` | `/random` filters matched nothing |
| 405 | `{ "error": "method_not_allowed" }` | non-GET (except OPTIONS) |

---

## Attribution

Quote text and citations: Wikiquote contributors, [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/). Author facts: Wikidata (CC0). Portraits: Wikimedia Commons, licensed per file (`author.license`). Film dialogue remains copyright of the studios; short credited lines only.
