DEV Community

Cover image for Chuck Norris API: Add Random Facts to Your App
APIVerve
APIVerve

Posted on • Originally published at blog.apiverve.com

Chuck Norris API: Add Random Facts to Your App

Sometimes you just need to add something stupid to your app. A loading screen that makes people smile. A Slack bot that breaks up the monotony. A 404 page that's actually funny.

Chuck Norris facts are perfect for this.

One Request, One Laugh

const response = await fetch('https://api.apiverve.com/v1/chucknorrisjokes', {
  headers: { 'x-api-key': 'YOUR_API_KEY' }
});

const { data } = await response.json();
console.log(data.joke);
// "Chuck Norris can divide by zero."
Enter fullscreen mode Exit fullscreen mode

That's the whole thing. Call endpoint, get joke. No configuration, no parameters, just randomness.

Slack Bot (5 Minutes)

Create a slash command that responds with a fact:

app.post('/slack/chuck', async (req, res) => {
  const { data } = await fetch('https://api.apiverve.com/v1/chucknorrisjokes', {
    headers: { 'x-api-key': process.env.API_KEY }
  }).then(r => r.json());

  res.json({
    response_type: 'in_channel',
    text: `πŸ₯‹ ${data.joke}`
  });
});
Enter fullscreen mode Exit fullscreen mode

Point your Slack slash command at this endpoint. Type /chuck in any channel. Instant team morale boost.

Discord Bot (Also 5 Minutes)

client.on('messageCreate', async (message) => {
  if (message.content === '!chuck') {
    const { data } = await fetch('https://api.apiverve.com/v1/chucknorrisjokes', {
      headers: { 'x-api-key': process.env.API_KEY }
    }).then(r => r.json());

    message.reply(`πŸ₯‹ ${data.joke}`);
  }
});
Enter fullscreen mode Exit fullscreen mode

Same energy, different platform.

Loading States That Don't Suck

Instead of a boring spinner:

async function showLoadingWithJoke() {
  const jokePromise = fetch('https://api.apiverve.com/v1/chucknorrisjokes', {
    headers: { 'x-api-key': 'YOUR_API_KEY' }
  }).then(r => r.json());

  const { data } = await jokePromise;
  document.getElementById('loading-text').textContent = data.joke;
}
Enter fullscreen mode Exit fullscreen mode

User sees a Chuck Norris fact while waiting. Loading feels shorter when you're laughing.

Categories

Filter by topic if the API supports it:

// Get programming-related jokes only
const url = 'https://api.apiverve.com/v1/chucknorrisjokes?category=dev';
Enter fullscreen mode Exit fullscreen mode

Dev jokes hit different in a developer tool. Movie jokes work better in entertainment apps.

Why This Actually Matters

Fun APIs seem trivial. They're not.

They teach async patterns, error handling, API authentication β€” same fundamentals as "serious" APIs. But you actually want to build with them. Nobody dreads working on their joke bot at 11pm.

Ship something fun. Learn the patterns. Apply them to the boring stuff later.

Other Joke APIs

Once you're tired of Chuck Norris (impossible, but hypothetically):

Same authentication, same response format. Swap the endpoint, get different content.


Get an API key and go build something that makes someone smile today.


Originally published at APIVerve Blog

Top comments (0)