Overview

icanhazdadjoke is a free API serving the internet's largest collection of dad jokes. It returns a random dad joke in JSON, plain text, or image format with no API key needed. It is a favorite beginner project API because the responses are simple, clean, and always entertaining.

Beginner Tip

Set the Accept header to application/json to get a JSON response. Without it, the API returns plain text. You can also search jokes by keyword using the /search endpoint.

Available Data

The kind of data this API exposes, based on its documentation. We could not call the endpoint to confirm the exact field names.

joke text (setup/punchline)
joke category
joke type (single/twopart)

Example Response

Illustrative shape only — we were not able to call this endpoint (it requires credentials or exposes no public sample URL), so the fields below show the kind of data this API returns rather than a recorded response.

JSON Response · Illustrative
{
  "error": false,
  "category": "Programming",
  "type": "twopart",
  "setup": "Why do programmers prefer dark mode?",
  "delivery": "Because light attracts bugs.",
  "id": 42,
  "lang": "en"
}

Field Reference

id Unique identifier for the joke.
joke The full text of the dad joke.
status HTTP status code of the response, typically 200.

Implementation Example

Calls a real endpoint of this API. Replace any placeholder credentials with your own key.

Request
const url = "https://icanhazdadjoke.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.

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.

Response is plain text or HTML instead of JSON The Accept: application/json header was not included.
Always include -H "Accept: application/json" in your request.
404 on /search with no results The search term returned no matching jokes.
Check that the "results" array is not empty before accessing results[0]; try a broader search term.
CORS error in browser Request originates from a disallowed origin.
icanhazdadjoke supports CORS, so this usually means a local file:// origin; serve your page from a local server instead.

Metadata Score Breakdown

Estimated from metadata — endpoint not independently tested

This score is estimated from observable metadata — HTTPS support, authentication model, declared CORS, and documentation reachability — because the API requires authentication or exposes no publicly testable endpoint. The five-signal breakdown is only shown for live-tested APIs.

Metadata estimate · endpoint not independently tested

Technical Specifications

Auth No Auth
HTTPS REQUIRED
CORS UNKNOWN
Category Personality
Difficulty Beginner
Listing details not endpoint-verified

Related Tags

Similar APIs

View All →