Overview
The xkcd API lets you retrieve any xkcd webcomic as structured JSON data, including the comic title, image URL, alt text, and publication date. It requires no authentication and is extremely simple to use. A perfect first API for beginners learning to make HTTP requests and parse JSON responses.
Beginner Tip
To get the latest comic, request https://xkcd.com/info.0.json. To get a specific comic by its number, use https://xkcd.com/NUMBER/info.0.json, where NUMBER is the comic's ID.
Measurement Record
What actually happened when we called this API from our own infrastructure. Every value below was recorded by the request, not copied from the provider's documentation.
- Request
- GET https://xkcd.com/info.0.json
- Result
- HTTP 200 · application/json · 395 bytes · compressed
- Response time
- 29 ms (median of 3) · fastest 19 ms
- Transport
- TLSv1.2 · ECDHE-RSA-AES128-GCM-SHA256 · certificate issued by GlobalSign nv-sa
- Browser CORS
- No Access-Control-Allow-Origin header — call it from a server, not the browser
- Served by
- nginx
- Recorded
- 2026-08-10
Fields Returned
Top-level fields present in the response we captured, with the type and value we actually received.
| Field | Type | Value received |
|---|---|---|
| month | string | 8 |
| num | integer | 3283 |
| link | string | |
| year | string | 2026 |
| news | string | |
| safe_title | string | Size and Lifespan |
| transcript | string | |
| alt | string | With their 13 years recording and performing … |
| img | string (url) | https://imgs.xkcd.com/comics/size_and_lifespa… |
| title | string | Size and Lifespan |
| day | string | 10 |
Captured Response
Captured from a real request to https://xkcd.com/info.0.json on 2026-08-10. Long arrays and nested objects are truncated to keep the shape readable.
{
"month": "8",
"num": 3283,
"link": "",
"year": "2026",
"news": "",
"safe_title": "Size and Lifespan",
"transcript": "",
"alt": "With their 13 years recording and performing together and two humans worth of mass, the White Stripes are sandwiched neatly between gray wolves and blue whales.",
"img": "https://imgs.xkcd.com/comics/size_and_lifespan.png",
"title": "Size and Lifespan",
"day": "10"
} Field Reference
num The unique comic number, incrementing with each new publication. title The title of the xkcd comic strip. img URL to the comic's image file, typically a PNG or JPEG. alt The hover text / alt text, often containing the punchline or extra joke. transcript Full text transcript of the comic dialogue (may be empty for newer comics). year Four-digit year the comic was published. Implementation Example
Calls a real endpoint of this API. Replace any placeholder credentials with your own key.
const url = "https://xkcd.com/";
const response = await fetch(url);
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
const data = await response.json();
console.log(data); What Can You Build?
Note: These code examples are AI-generated and unverified. Always refer to the official API documentation for accurate usage.
How This API Fails
We deliberately sent this API a broken request and recorded exactly what came back on 2026-08-10. Knowing the shape of an error before you hit it makes error handling much easier to write.
Returned an HTML error page rather than JSON — worth knowing if your client assumes every response can be parsed as JSON.
Common Errors & Troubleshooting
Generated guidance based on this API's documentation, not observed by us. Treat it as a starting point and check against the provider's own error reference.
Measured Score Breakdown
Live HTTP request to the API endpoint
Fully tested on Aug 10, 2026
Technical Specifications
Related Tags
Similar APIs
View All →Animal Crossing: New Horizons
⭐ Beginner's PickThe Animal Crossing: New Horizons API gives you free access to in-game data including villagers, critters, fossils, art, music, and furniture.
Autochess VNG
The Autochess VNG API provides game data for the Autochess VNG mobile game including heroes, items, and races.
Barter.VG
Barter.VG aggregates data about PC games, DLC, bundles, giveaways, and trading from Steam and other platforms.
Digimon Information
⭐ Beginner's PickThe Digimon Information API provides easy access to data about Digimon creatures, including their names, levels, types, and images.
Genshin Impact
⭐ Beginner's PickThe Genshin Impact API provides detailed game data including characters, weapons, artifacts, enemies, and domains from the popular action RPG.