Home › 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
exclude-tags=nsfw,dark,racist,sexist,sexual keeps a feed family-friendly.| Endpoint | GET https://api.humorapi.com/jokes/random |
|---|---|
| Authentication | API key as api-key query parameter or x-api-key header |
| Response | JSON |
| Cost | 1 point per call |
| Reference | Random Joke in the docs |
{
"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 "https://api.humorapi.com/jokes/random?api-key=YOUR_API_KEY" 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); import os, requests
res = requests.get("https://api.humorapi.com/jokes/random",
headers={"x-api-key": os.environ["HUMOR_API_KEY"]})
print(res.json()) 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.
GET /jokes/searchGET /jokes/randomGET /jokes/createPOST /jokes/analyzePOST /jokesPOST /jokes/{id}/upvotePOST /jokes/{id}/downvotePass 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.
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); 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.
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.
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.