icanhazdadjoke API
Free dad joke API with no key. Returns jokes as JSON, plain text or image depending on the Accept header. Search supported. Tested curl example included.
Endpoint tested and returned HTTP 200 on 2026-08-19
What is the icanhazdadjoke API?
icanhazdadjoke is a free dad joke API requiring no API key. It returns a random joke, and uniquely uses the HTTP Accept header to decide whether to respond with JSON, plain text or an image.
icanhazdadjoke is the clearest real-world example of HTTP content negotiation you will find in a free API. The same URL returns HTML in a browser, plain text to a bare curl call, and JSON when you send `Accept: application/json` — one endpoint, three representations.
That makes it genuinely useful for teaching, because it demonstrates that the Accept header is a real mechanism and not just boilerplate. The API also asks that you send a User-Agent identifying your app, which is a reasonable courtesy worth honouring.
Quick facts
- Base URL
https://icanhazdadjoke.com- Authentication
- No key. The maintainer asks that you send a descriptive User-Agent with a contact URL.
- Rate limit
- No published limit; fair use expected.
- Pricing
- Free.
- CORS
- Enabled — callable directly from browser JavaScript
- Official docs
- Read the docs
How to use the icanhazdadjoke API
Every request below was executed against the live API on 2026-08-19, and the response shown is the real body it returned — not an illustration.
1. Fetch a random dad joke as JSON
GET https://icanhazdadjoke.com/
curl 'https://icanhazdadjoke.com/' \
-H 'Accept: application/json'const res = await fetch("https://icanhazdadjoke.com/", {
headers: {
"Accept": "application/json",
},
});
if (!res.ok) throw new Error(`Request failed: ${res.status}`);
const data = await res.json();
console.log(data);import requests
headers = {
"Accept": "application/json",
}
res = requests.get("https://icanhazdadjoke.com/", headers=headers, timeout=20)
res.raise_for_status()
print(res.json()){
"id": "wXDIB5h3wc",
"joke": "I used to have a job at a calendar factory but I got the sack because I took a couple of days off.",
"status": 200
}Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
Accept | header | Required | Set to application/json for JSON. Omit for plain text, or use text/html for HTML. application/json |
term | query | Optional | Search term, used with the /search endpoint. cat |
page / limit | query | Optional | Pagination controls on /search. 1 |
Response fields
idstring- Joke identifier, usable with /j/{id} to fetch it again.
jokestring- The joke text as a single string — no setup/punchline split.
statusinteger- HTTP status echoed in the body.
What you can build with the icanhazdadjoke API
- Teach HTTP content negotiation with a single memorable example
- Add a random joke command to a Slack or Discord bot
- Search a joke corpus by keyword with the /search endpoint
- Generate joke images for social posts using the image representation
Common errors and how to fix them
HTML returned instead of JSON
The Accept header was missing.
Fix: Send `Accept: application/json` — this is the whole point of the API's design.
403
Blocked for a missing or generic User-Agent.
Fix: Send a User-Agent naming your app and a contact URL.
icanhazdadjoke API — frequently asked questions
How do I get JSON from icanhazdadjoke?
Send the header `Accept: application/json`. Without it the API returns plain text or HTML, because it uses content negotiation to pick the representation.
Does icanhazdadjoke require an API key?
No key is needed. The maintainer does ask that you send a descriptive User-Agent identifying your application and a contact URL.
Can I search for jokes on a specific topic?
Yes, the /search endpoint accepts a `term` parameter plus pagination, returning matching jokes with a total count.
Can I get a joke as an image?
Yes. Requesting /j/{id}.png returns the joke rendered as an image, which is convenient for social media posts.
Tools that pair with this API
JSON Formatter
Format, beautify and minify JSON online with 2-space, 4-space or tab indentation. Sort keys alphabetically and catch syntax errors instantly — free and private.
Word Counter
Count words, characters, sentences, paragraphs and estimated reading time instantly. Free online word counter for essays, blogs and social media.
icanhazdadjoke is an independent third-party service and is not affiliated with ByteTools or ByteVancer. Details on this page were verified on 2026-08-19; always check the official documentation before relying on this API in production, as terms and limits can change.