Home › Joke API

Joke API

Get random jokes or search 50,000+ jokes by keyword, category, rating and length with one HTTP call. Humor API returns clean JSON, filters out adult and offensive jokes when you ask it to, and works from any language.

Get a free API key Read the docs See pricing

What the joke API does

Get a random joke

EndpointGET https://api.humorapi.com/jokes/random
AuthenticationAPI key as api-key query parameter or x-api-key header
ResponseJSON
Cost1 point per call
ReferenceRandom Joke in the docs
Example response
{
    "id": 38242,
    "joke": "Q: How many divorced men does it take to screw in a light bulb?\nA: None, the sockets go with the house."
}
curl
curl "https://api.humorapi.com/jokes/random?api-key=YOUR_API_KEY"
JavaScript (fetch)
const res = await fetch("https://api.humorapi.com/jokes/random", {
  headers: { "x-api-key": process.env.HUMOR_API_KEY }
});
const data = await res.json();
console.log(data);
Python (requests)
import os, requests

res = requests.get("https://api.humorapi.com/jokes/random",
                   headers={"x-api-key": os.environ["HUMOR_API_KEY"]})
print(res.json())

Search jokes by keyword, category and rating

Combine filters freely. This request asks for three jokes that mention both "horse" and "man":

GET https://api.humorapi.com/jokes/search?number=3&keywords=horse,man

The response lists the jokes and an available count of matching jokes. Useful parameters: keywords, include-tags, exclude-tags, min-rating, max-length, number (up to 10) and offset for paging. See Search Jokes for the full parameter list.

All joke endpoints

Search JokesGET /jokes/search
With over 50,000 jokes, you should find something for any occasion. There are 27 categories to choose from but you can also search for very specific words within jokes.
Random JokeGET /jokes/random
This endpoint is similar to the Search Jokes endpoint but you'll receive a random joke every time.
Create JokeGET /jokes/create
Use a large language model to create a joke for a certain topic or even multiple topics.
Analyze JokePOST /jokes/analyze
This endpoint analyzes and tags the joke.
Submit JokePOST /jokes
Submit a joke to the database.
Upvote JokePOST /jokes/{id}/upvote
Upvote a joke that is liked by you or your users.
Downvote JokePOST /jokes/{id}/downvote
Downvote a joke that you or your users don't like.

Joke categories

Pass these tag values to include-tags or exclude-tags:

clean animal food sexual knock_knock sport blondes law nerdy relationship deep_thoughts dark one_liner political chuck_norris yo_mama nsfw religious school jewish racist insults sexist holiday analogy christmas kids

Dedicated guides: Chuck Norris jokes API and knock knock jokes API.

Example: a Discord joke bot in 16 lines

With discord.js, a bot that answers !joke with a family-friendly joke. Turn on the Message Content intent for your bot in the Discord developer portal first.

import { Client, GatewayIntentBits } from "discord.js";

const client = new Client({ intents: [GatewayIntentBits.Guilds,
  GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent] });

client.on("messageCreate", async (message) => {
  if (message.content !== "!joke") return;
  const res = await fetch(
    "https://api.humorapi.com/jokes/random?exclude-tags=nsfw,dark,racist,sexist,sexual",
    { headers: { "x-api-key": process.env.HUMOR_API_KEY } });
  if (!res.ok) return message.reply("No more jokes today, try again tomorrow!");
  const { joke } = await res.json();
  await message.reply(joke);
});

client.login(process.env.DISCORD_TOKEN);

Pricing

The free plan has 10 points per day (most calls cost 1 point) and needs a backlink; paid plans start at $3 per month for 100 points per day and bill extra points instead of stopping. Compare the plans.

Questions about the joke API

Is the joke API free?

There is a free plan with 10 points per day, enough for about 10 jokes a day while you build. Paid plans start at $3 per month for 100 points per day. See pricing.

How is Humor API different from free joke APIs like JokeAPI or icanhazdadjoke?

Free APIs need no key but hold a few hundred to about a thousand jokes. Humor API has 50,000+ jokes, 27 categories, ratings and AI-written jokes, and needs an API key. Our joke API comparison lays out the trade-offs.

More from Humor API

Meme API GIF Search API Insult & Praise API Nonsense Word API Chuck Norris Jokes API Knock Knock Jokes API

Get a free API key Read the docs See pricing