# xkcd API
> Randall Munroe's legendary webcomic xkcd as an API. Fetch the latest comic, any comic by its number (e.g. #353 "Python"), or a random one — each with the title, the famous hover (alt) text, the full transcript, the image URL, the publication date and links to both xkcd and explainxkcd. A clean JSON wrapper over xkcd.com with no scraping and no surprises. Ideal for Discord and Slack bots, "comic of the day" widgets, dashboards and screensavers, newsletters, and any app that wants a daily dose of xkcd.

## Authentication
All requests require your oanor API key in the `x-oanor-key` header. Get one at https://www.oanor.com/developer/keys.

```bash
curl -H "x-oanor-key: oanor_live_…" "https://api.oanor.com/xkcd-api/..."
```

## Pricing
- **Free** (Free) — 13,500 calls/Mo, 2 req/s
- **Starter** ($3/Mo) — 195,000 calls/Mo, 8 req/s
- **Pro** ($9/Mo) — 840,000 calls/Mo, 20 req/s
- **Mega** ($30/Mo) — 3,450,000 calls/Mo, 50 req/s

## Endpoints

### Comics

#### `GET /v1/comic` — A comic by number

**Parameters:**
- `number` (query, required, string) — Comic number, e.g. 353 Example: `353`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/xkcd-api/v1/comic?number=353"
```

**Response:**
```json
{
    "data": {
        "comic": {
            "alt": "I wrote 20 short programs in Python yesterday. It was wonderful. Perl, I'm leaving you.",
            "date": "2007-12-05",
            "link": null,
            "news": null,
            "image": "https://imgs.xkcd.com/comics/python.png",
            "title": "Python",
            "number": 353,
            "comic_url": "https://xkcd.com/353/",
            "safe_title": "Python",
            "transcript": "[[ Guy 1 is talking to Guy 2, who is floating in the sky ]] Guy 1: You're flying! How? Guy 2: Python! Guy 2: I learned it last night! Everything is so simple! Guy 2: Hello world is just 'print \"Hello, World!\" ' Guy 1: I dunno... Dynamic typing? Whitespace? Guy 2: Come join us! Programming is fun again! It's a whole new world up here! Guy 1: But how are you flying? Guy 2: I just typed 'import antigravity' Guy 1: That's it? Guy 2: ...I also sampled everything in the medicine cabinet for comparison. Guy 2: But i think this is the python. {{ I wrote 20 short programs in Python yesterday. It was wonderful. Perl, I'm leaving you. }}",
            "explain_url": "https://www.explainxkcd.com/wiki/index.php/353"
        }
    },
    "meta": {
        "timestamp": "2026-06-01T00:04:28.749Z",
        "request_id": "4d84ec2d-3603-49b8-922f-717cde6b6932"
    },
    "status": "ok",
    "message": "Comic retrieved",
    "success": true
}
```

#### `GET /v1/latest` — The most recent comic

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/xkcd-api/v1/latest"
```

**Response:**
```json
{
    "data": {
        "comic": {
            "alt": "SUGGESTIONS FOR FUTURE RESEARCH: No further research is needed as it is frankly none of our business.",
            "date": "2026-05-29",
            "link": null,
            "news": null,
            "image": "https://imgs.xkcd.com/comics/ancestral_genomes.png",
            "title": "Ancestral Genomes",
            "number": 3252,
            "comic_url": "https://xkcd.com/3252/",
            "safe_title": "Ancestral Genomes",
            "transcript": null,
            "explain_url": "https://www.explainxkcd.com/wiki/index.php/3252"
        }
    },
    "meta": {
        "timestamp": "2026-06-01T00:04:28.832Z",
        "request_id": "38672f42-4890-4500-a0e2-86611a7e88e1"
    },
    "status": "ok",
    "message": "Latest comic retrieved",
    "success": true
}
```

#### `GET /v1/random` — A random comic

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/xkcd-api/v1/random"
```

**Response:**
```json
{
    "data": {
        "comic": {
            "alt": "An occasional source of mild Thanksgiving tension in my family is that my mother is a die-hard fan of The Core (2003), and various family members sometimes have differing levels of enthusiasm for her annual tradition of watching it.",
            "date": "2023-11-22",
            "link": null,
            "news": null,
            "image": "https://imgs.xkcd.com/comics/thanksgiving_arguments.png",
            "title": "Thanksgiving Arguments",
            "number": 2858,
            "comic_url": "https://xkcd.com/2858/",
            "safe_title": "Thanksgiving Arguments",
            "transcript": null,
            "explain_url": "https://www.explainxkcd.com/wiki/index.php/2858"
        }
    },
    "meta": {
        "timestamp": "2026-06-01T00:04:29.229Z",
        "request_id": "d8be89c3-4a9e-4cfd-800f-8ef38b59be85"
    },
    "status": "ok",
    "message": "Random comic retrieved",
    "success": true
}
```

### Meta

#### `GET /v1/meta` — Usage notes

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/xkcd-api/v1/meta"
```

**Response:**
```json
{
    "data": {
        "note": "xkcd webcomic. /v1/latest = the most recent comic; /v1/comic?number=353 = a specific comic by number; /v1/random = a random comic. Each returns the title, hover (alt) text, transcript, image URL, publication date and links to xkcd and explainxkcd. xkcd is licensed CC BY-NC 2.5 by Randall Munroe.",
        "source": "xkcd.com (Randall Munroe)",
        "endpoints": [
            "/v1/latest",
            "/v1/comic",
            "/v1/random",
            "/v1/meta"
        ]
    },
    "meta": {
        "timestamp": "2026-06-01T00:04:29.276Z",
        "request_id": "9d91034f-ede2-48fd-b66e-505ad62c6c93"
    },
    "status": "ok",
    "message": "Meta retrieved",
    "success": true
}
```


---
Marketplace page: https://www.oanor.com/api/xkcd-api
OpenAPI spec: https://www.oanor.com/api/xkcd-api/openapi.json
