# Edge API

The original QuoteLore dynamic routes, mounted at `/edge`. Same dataset and response shape as [QuoteLore](/docs/quotelore). Use this if you want the shorter edge-style surface:

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

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

**Base path:** `/edge`

**CORS:** open

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

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

For list, tag, and author-search endpoints, use [QuoteLore](/docs/quotelore).

---

## Endpoints

| Method | Path | Query | Example |
|---|---|---|---|
| GET | [/edge](/edge) | — | Catalog |
| GET | [/edge/quote](/edge/quote?id=1) | `id*` | `/edge/quote?id=1` |
| GET | [/edge/search](/edge/search?q=life) | `q*`, `page`, `limit`, filters | `/edge/search?q=unexamined%20life` |
| GET | [/edge/random](/edge/random) | `count`, filters | `/edge/random?tag=science&photo=1` |
| GET | [/edge/today](/edge/today) | — | `/edge/today` |
| GET | [/edge/author](/edge/author?slug=socrates) | `slug*` | `/edge/author?slug=socrates` |

`*` = required.

---

## Shared filters

On `/edge/search` and `/edge/random`:

| Param | Description |
|---|---|
| `tag` | `film`, `indian-thinkers`, `leaders`, `literature`, `philosophy`, `science`, `sports` |
| `author` | Author slug |
| `minlen` / `maxlen` | Quote length |
| `photo=1` | Authors with a portrait |
| `grade` | `A` or `B` |
| `film` | `1` film dialogue only, `0` exclude it |
| `kind` | `person` or `character` |
| `page` / `limit` | Search pagination (`limit` max 50) |
| `count` | `/random` only, 1–20 |

---

## GET /edge/quote

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

Sample response:

```json
{
  "id": 1,
  "text": "The unexamined life is not worth living.",
  "author": {
    "name": "Socrates",
    "slug": "socrates",
    "url": "https://api.casw.app/quotelore/author?slug=socrates"
  },
  "tags": ["philosophy"],
  "url": "https://api.casw.app/quotelore/quote?id=1"
}
```

Canonical `url` fields point at `/quotelore`, even when you called `/edge`.

---

## GET /edge/search

```
GET https://api.casw.app/edge/search?q=unexamined%20life
GET https://api.casw.app/edge/search?q=gandhi&tag=leaders&limit=10
```

```json
{
  "query": "unexamined life",
  "total": 1,
  "page": 1,
  "limit": 20,
  "results": []
}
```

`q` must be at least 2 characters.

---

## GET /edge/random

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

`count=1` (default) returns a quote object. `count>1` returns `{ "count": n, "quotes": [...] }`.

---

## GET /edge/today

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

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

Same quote for everyone until midnight Asia/Kolkata.

---

## GET /edge/author

```
GET https://api.casw.app/edge/author?slug=socrates
```

Returns the author profile plus `quotes` (without a nested author object on each quote).

---

## Errors

Same as QuoteLore: `missing_id`, `missing_slug`, `q_too_short`, `not_found`, `no_match`.
