Chuck Norris API

Entertainment
Beginner

Overview

Free JSON API for hand curated Chuck Norris facts

Integration Guide

Step 1: Understanding the API

The Chuck Norris API is a free, public API that doesn't require authentication. It provides random Chuck Norris jokes, categorized jokes, and search functionality.

Step 2: Set Up Your Project

Create the necessary files for your Chuck Norris jokes application:

  • index.html - The HTML structure
  • styles.css - CSS for styling
  • chuck.js - JavaScript for API integration

Step 3: Implement the Code

Copy the following code into your project files:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Chuck Norris Jokes</title>
  <link rel="stylesheet" href="styles.css">
</head>
<body>
  <div class="container">
    <h1>Chuck Norris Jokes</h1>
    
    <div class="categories">
      <h2>Categories</h2>
      <div id="category-buttons"></div>
    </div>
    
    <div class="joke-container">
      <div id="joke-text">Click a category or the button below to get a joke</div>
      <button id="random-joke">Get Random Joke</button>
    </div>
    
    <div class="search-container">
      <h2>Search Jokes</h2>
      <input type="text" id="search-input" placeholder="Enter search term (min 3 characters)">
      <button id="search-button">Search</button>
      <div id="search-results"></div>
    </div>
  </div>
  
  <script src="chuck.js"></script>
</body>
</html>

Step 4: Test Your Implementation

Open your HTML file in a browser to test your Chuck Norris jokes application. You should be able to:

  • View all available joke categories
  • Get a random joke by clicking the "Get Random Joke" button
  • Get a joke from a specific category by clicking on a category button
  • Search for jokes containing specific text

Error Handling

Common Errors

  • 404 Not Found: Invalid endpoint or resource not found
  • 400 Bad Request: Invalid query parameters (e.g., search term too short)
  • Network Errors: Connection issues or API downtime

Rate Limiting

The Chuck Norris API doesn't explicitly state rate limits, but as with any public API, it's good practice to implement reasonable request limits in your application.

API Details

Base URL
https://api.chucknorris.io
Authentication
None
Documentation
Official Docs

Endpoints

  • GET
    /jokes/random

    Retrieve a random chuck norris joke

  • GET
    /jokes/random?category={category}

    Retrieve a random chuck norris joke from a given category

    Parameters
    • category*
      string - The category to fetch a joke from (e.g., animal, career, celebrity)
  • GET
    /jokes/categories

    Retrieve all available categories

  • GET
    /jokes/search?query={query}

    Search for jokes

    Parameters
    • query*
      string - The search query (min 3, max 120 characters)