icanhazdadjoke API
Random dad jokes served as JSON, text or an image — free, no key.
What it does
icanhazdadjoke.com is a database of dad jokes with a friendly API: a random joke, a specific joke by id, and keyword search with pagination. It returns plain text, HTML or JSON depending on the Accept header.
Base URL
Authentication
None, but the maintainer asks you to send a descriptive User-Agent with a contact URL. Set Accept: application/json for JSON (text/plain for a bare string).
Code examples
curl -s -H "Accept: application/json" \ -H "User-Agent: larzos-demo (https://larzos.com)" \ https://icanhazdadjoke.com/
import requests
H = {"Accept": "application/json",
"User-Agent": "larzos-demo (https://larzos.com)"}
j = requests.get("https://icanhazdadjoke.com/", headers=H, timeout=10).json()
print(j["joke"])
s = requests.get("https://icanhazdadjoke.com/search",
params={"term": "dog", "limit": 3}, headers=H, timeout=10).json()
print(s["total_jokes"], "jokes about dogs")Rate limits & quotas
No published hard rate limit, but be considerate and cache. Search paginates with page and limit (max 30). There is also a /j/{id}.png image render if you want a shareable card.
Key response fields
| id | Joke id — permalink /j/{id} |
| joke | The joke text |
| status | HTTP status echoed in the body |
| (search) results[] / total_jokes / total_pages / current_page | Search pagination |
Common errors
| 404 | Unknown joke id. |
| (HTML instead of JSON) | You didn’t send Accept: application/json. |
| 403 / throttled | Missing or generic User-Agent — set a real one. |
When to use it (and alternatives)
The go-to for a dad-joke button, Slack bot or 404 page. For broader joke categories and content filtering, JokeAPI; for Chuck Norris ‘facts’, chucknorris.io.
FAQ
Why am I getting HTML back?
The default response type is HTML (it is also a website). Send Accept: application/json or Accept: text/plain to get a machine-friendly response.
Do I really need a User-Agent?
The docs ask for one that identifies your app and links back to it. Requests with a generic agent may be throttled.
Can I get a joke as an image?
Yes — https://icanhazdadjoke.com/j/{id}.png renders the joke as a shareable image.
New to APIs?
Short guides for working with this API — and any other.