Documentation

Here you have detailed documentation of all available API functions. To get started, you can make the sample request for each endpoint, download an SDK, or run in Postman (see bottom of left navigation).

Search Jokes

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.

GET
https://api.humorapi.com/jokes/search

Headers

Response Headers:

  • Content-Type: application/json
  • X-API-Quota-Request: The number of points used by the request
  • X-API-Quota-Used: The number of points used in total today

Parameters

NameTypeExampleDescription
keywords string airplane A comma-separated list of words that must occur in the joke.
include-tags string animal A comma-separated list of tags the jokes should have.
exclude-tags string nsfw,dark A comma-separated list of tags the jokes must not have.
min-rating number 0 The minimum rating (0-10) of the jokes.
max-length number 140 The maximum length of the joke in letters.
offset number 0 The number of jokes to skip, between 0 and 1000.
number number 10 The number of jokes, between 0 and 10.
api-key string abcd1234 Your API key.
Example Request and Response
GET
https://api.humorapi.com/jokes/search?number=3&keywords=horse,man
{
    "jokes": [
        {
            "id": 35642,
            "joke": "A man walked into a cowboy bar and ordered a beer just as President Bush appeared on the television. After a few sips, he looked up at the television and mumbled, \"Now, there's the biggest horse's ass I've ever seen.\" A customer at the end of the bar quickly stood up, walked over to him, and decked him. A few minutes later, as the man was finishing his beer, Mrs. Bush appeared \n on the television. \"She's a horse's ass too,\" the man. This time, a customer at the other end of the bar quickly stood up, walked over \n to him, and knocked him off his stool. \"Damn it!\" the man said, climbing back up to the bar. \"This must be Bush country!\" \"Nope,\" the bartender replied. \"Horse country!\""
        },
        {
            "id": 39052,
            "joke": "The General went out to find that none of his G.I.s were there. One finally ran up, panting heavily.\"Sorry, sir! I can explain, you see I had a date and it ran a little late. I ran to the bus but missed it, I hailed a cab but it broke down, found a farm, bought a horse but it dropped dead, ran 10 miles, and now I`m here.\"The General was very skeptical about this explanation but at least he was here so he let the G.I. go. Moments later, eight more G.I.s came up to the general panting, he asked them why they were late.\"Sorry, sir! I had a date and it ran a little late, I ran to the bus but missed it, I hailed a cab but it broke down, found a farm, bought a horse but it dropped dead, ran 10 miles, and now I`m here.\"The General eyed them, feeling very skeptical but since he let the first guy go, he let them go, too. A ninth G.I. jogged up to the General, panting heavily.\"Sorry, sir! I had a date and it ran a little late, I ran to the bus but missed it, I hailed a cab but...\"\"Let me guess,\" the General interrupted, \"it broke down.\"\"No,\" said the G.I., \"there were so many dead horses in the road, it took forever to get around them.\""
        },
        {
            "id": 41701,
            "joke": "A man has a racehorse, never won a race. Man in disgust says, Horse, you win today or you pull a milk wagon tomorrow morning.\" The starting gate opens, the horses take-off, they move the gate away and there lays his horse asleep on the track. He kicks the horse and asks, \"WHY ARE YOU SLEEPING. The horse, half asleep says, \"I have to get up at three in the morning.\""
        }
    ],
    "available": 541
}

Quotas

Calling this endpoint requires
1 point

Random Joke

This endpoint is similar to the Search Jokes endpoint but you'll receive a random joke every time.

GET
https://api.humorapi.com/jokes/random

Headers

Response Headers:

  • Content-Type: application/json
  • X-API-Quota-Request: The number of points used by the request
  • X-API-Quota-Used: The number of points used in total today

Parameters

NameTypeExampleDescription
include-tags string animal A comma-separated list of tags the jokes should have.
exclude-tags string nsfw,dark A comma-separated list of tags the jokes must not have.
min-rating number 0 The minimum rating (0-10) of the jokes.
max-length number 140 The maximum length of the joke in letters.
api-key string abcd1234 Your API key.
Example Request and Response
GET
https://api.humorapi.com/jokes/random
{
    "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."
}

Quotas

Calling this endpoint requires
1 point

Create Joke

Use a large language model to create a joke for a certain topic or even multiple topics.

GET
https://api.humorapi.com/jokes/create

Headers

Response Headers:

  • Content-Type: application/json
  • X-API-Quota-Request: The number of points used by the request
  • X-API-Quota-Used: The number of points used in total today

Parameters

NameTypeExampleDescription
topics string airplane A comma-separated list of topics that the joke should be about.
max-length number 1000 The maximum length of the joke in letters.
api-key string abcd1234 Your API key.
Example Request and Response
GET
https://api.humorapi.com/jokes/create?topics=pirates
{
        "joke": "What's a pirate's least favorite exercise? The plank."
}

Quotas

Calling this endpoint requires
1 point

Analyze Joke

This endpoint analyzes and tags the joke.

POST
https://api.humorapi.com/jokes/analyze

Headers

Response Headers:

  • Content-Type: application/json
  • X-API-Quota-Request: The number of points used by the request
  • X-API-Quota-Used: The number of points used in total today
Example Request Body
POST
https://api.humorapi.com/jokes/analyze
What do you call a deer without eyes? No ideer.
Response
{
    "joke": "What do you call a deer without eyes? No ideer.",
    "tags": [
        "ANIMAL"
    ]
}

Quotas

Calling this endpoint requires
1 point

Submit Joke

Submit a joke to the database.

POST
https://api.humorapi.com/jokes

Headers

Response Headers:

  • Content-Type: application/json
  • X-API-Quota-Request: The number of points used by the request
  • X-API-Quota-Used: The number of points used in total today
Example Request Body
POST
https://api.humorapi.com/jokes
What do you call a deer without eyes? No ideer.
Response
{
    "joke": {
        "id": 52625,
        "joke": "What do you call a deer without eyes? No ideer.",
        "tags": [
            "ANIMAL"
        ]
    },
    "message": "Thanks for submitting the joke. We will evaluate the joke asap."
}

Quotas

Calling this endpoint requires
1 point

Upvote Joke

Upvote a joke that is liked by you or your users.

POST
https://api.humorapi.com/jokes/{id}/upvote

Headers

Response Headers:

  • Content-Type: application/json
  • X-API-Quota-Request: The number of points used by the request
  • X-API-Quota-Used: The number of points used in total today

Parameters

NameTypeExampleDescription
id number 123 The id of the joke to vote.
api-key string abcd1234 Your API key.
Example Request and Response
POST
https://api.humorapi.com/jokes/123/upvote
{
    "message": "Thanks for submitting an upvote."
}

Quotas

Calling this endpoint requires
1 point

Downvote Joke

Downvote a joke that you or your users don't like.

POST
https://api.humorapi.com/jokes/{id}/downvote

Headers

Response Headers:

  • Content-Type: application/json
  • X-API-Quota-Request: The number of points used by the request
  • X-API-Quota-Used: The number of points used in total today

Parameters

NameTypeExampleDescription
id number 123 The id of the joke to vote.
api-key string abcd1234 Your API key.
Example Request and Response
POST
https://api.humorapi.com/jokes/123/downvote
{
    "message": "Thanks for submitting a downvote."
}

Quotas

Calling this endpoint requires
1 point

Search Memes

With over 450,000 memes, you'll surely find something funny. You can even search for text within memes and filter by user ratings.

GET
https://api.humorapi.com/memes/search

Headers

Response Headers:

  • Content-Type: application/json
  • X-API-Quota-Request: The number of points used by the request
  • X-API-Quota-Used: The number of points used in total today

Parameters

NameTypeExampleDescription
keywords string airplane A comma-separated list of words that must occur in the meme.
keywords-in-image boolean true Whether the keywords must occur in the image.
media-type string image The media type (either 'image', 'video' or even specific format such as 'jpg', 'png', or 'gif').
min-rating number 0 The minimum rating (0-10) of the meme.
max-age-days number 30 The maximum age of the meme in days.
offset number 0 The number of memes to skip, between 0 and 1000.
number number 10 The number of memes, between 0 and 10.
api-key string abcd1234 Your API key.
Example Request and Response
GET
https://api.humorapi.com/memes/search?number=3&keywords=rocket
{
    "memes": [
        {
            "id": 6696,
            "url": "https://i.imgur.com/1rmAxUG.jpg",
            "type": "image/jpeg"
        },
        {
            "id": 6697,
            "url": "https://i.imgur.com/ELT8zMQ.jpg",
            "type": "image/jpeg"
        },
        {
            "id": 6698,
            "url": "https://i.imgur.com/8JTc5z3.jpg",
            "type": "image/jpeg"
        }
    ],
    "available": 32
}

Quotas

Calling this endpoint requires
1 point

Random Meme

Get a random meme out of over 450,000 memes and growing.

GET
https://api.humorapi.com/memes/random

Headers

Response Headers:

  • Content-Type: application/json
  • X-API-Quota-Request: The number of points used by the request
  • X-API-Quota-Used: The number of points used in total today

Parameters

NameTypeExampleDescription
keywords string airplane A comma-separated list of words that must occur in the meme.
keywords-in-image boolean true Whether the keywords must occur in the image.
media-type string image The media type (either 'image', 'video' or even specific format such as 'jpg', 'png', or 'gif').
min-rating number 0 The minimum rating (0-10) of the meme.
max-age-days number 30 The maximum age of the meme in days.
api-key string abcd1234 Your API key.
Example Request and Response
GET
https://api.humorapi.com/memes/random?keywords=rocket
{
    "id": 50561,
    "url": "https://preview.redd.it/hg0zn2mhjsh01.png?width=640&crop=smart&auto=webp&s=f19b0a87edfc6c71b35ec9aceb64799cd532ff59",
    "type": "image/png"
}

Quotas

Calling this endpoint requires
1 point

Upvote Meme

Upvote a meme that you or your users like.

POST
https://api.humorapi.com/memes/{id}/upvote

Headers

Response Headers:

  • Content-Type: application/json
  • X-API-Quota-Request: The number of points used by the request
  • X-API-Quota-Used: The number of points used in total today

Parameters

NameTypeExampleDescription
id number 123 The id of the meme to vote.
api-key string abcd1234 Your API key.
Example Request and Response
POST
https://api.humorapi.com/memes/123/upvote
{
    "message": "Thanks for submitting an upvote."
}

Quotas

Calling this endpoint requires
1 point

Downvote Meme

Downvote a meme that you or your users like.

POST
https://api.humorapi.com/memes/{id}/downvote

Headers

Response Headers:

  • Content-Type: application/json
  • X-API-Quota-Request: The number of points used by the request
  • X-API-Quota-Used: The number of points used in total today

Parameters

NameTypeExampleDescription
id number 123 The id of the meme to vote.
api-key string abcd1234 Your API key.
Example Request and Response
POST
https://api.humorapi.com/memes/123/downvote
{
    "message": "Thanks for submitting a downvote."
}

Quotas

Calling this endpoint requires
1 point

Search Gifs

Search through hundreds of thousands of gifs to match any reaction you want.

GET
https://api.humorapi.com/gif/search

Headers

Response Headers:

  • Content-Type: application/json
  • X-API-Quota-Request: The number of points used by the request
  • X-API-Quota-Used: The number of points used in total today

Parameters

NameTypeExampleDescription
query string dog A query to search for.
number number 10 The number of gifs, between 1 and 10.
api-key string abcd1234 Your API key.
Example Request and Response
GET
https://api.humorapi.com/gif/search?query=dog&number=3
{
    "images": [
        {
            "url": "https://static.klipy.com/ii/a15b48460c436e1e92c85ffc680932cc/3c/4c/2mJn9yWc.gif",
            "width": 640,
            "height": 610
        },
        {
            "url": "https://static.klipy.com/ii/2711dd8a75a85be822d136ec94899b3f/df/25/rVPMO3Km.gif",
            "width": 640,
            "height": 640
        },
        {
            "url": "https://static.klipy.com/ii/4e7bea9f7a3371424e6c16ebc93252fe/7b/87/eMP7ArRedjmII0YSb.gif",
            "width": 311,
            "height": 373
        }
    ]
}

Quotas

Calling this endpoint requires
1 point

Praise

Praise somebody for something.

GET
https://api.humorapi.com/praise

Headers

Response Headers:

  • Content-Type: application/json
  • X-API-Quota-Request: The number of points used by the request
  • X-API-Quota-Used: The number of points used in total today

Parameters

NameTypeExampleDescription
name string Alex The name of the person to be praised/insulted.
reason string You dropped the ball The reason the person is praised/insulted for.
api-key string abcd1234 Your API key.
Example Request and Response
GET
https://api.humorapi.com/praise?name=Alex&reason=you+did+it+again
{
    "text": "Bravo Alex, you mastermind, you did it again."
}

Quotas

Calling this endpoint requires
1 point

Insult

Insult somebody for something.

GET
https://api.humorapi.com/insult

Headers

Response Headers:

  • Content-Type: application/json
  • X-API-Quota-Request: The number of points used by the request
  • X-API-Quota-Used: The number of points used in total today

Parameters

NameTypeExampleDescription
name string Alex The name of the person to be praised/insulted.
reason string You dropped the ball The reason the person is praised/insulted for.
api-key string abcd1234 Your API key.
Example Request and Response
GET
https://api.humorapi.com/insult?name=Alex&reason=you+dropped+the+ball
{
    "text": "Holy moley, you dropped the ball Alex, you dingbat."
}

Quotas

Calling this endpoint requires
1 point

Rate Word

Rate a word on its funniness.

GET
https://api.humorapi.com/words/rate

Headers

Response Headers:

  • Content-Type: application/json
  • X-API-Quota-Request: The number of points used by the request
  • X-API-Quota-Used: The number of points used in total today

Parameters

NameTypeExampleDescription
word string cookie The word to be rated. A rating of 0 is low funniness and 1 is super funny.
api-key string abcd1234 Your API key.
Example Request and Response
GET
https://api.humorapi.com/words/rate?word=cookie
{
    "rating": 0.57
}

Quotas

Calling this endpoint requires
1 point

Generate Nonsense Word

Generate a funny sounding nonsense word.

GET
https://api.humorapi.com/words/nonsense/random

Headers

Response Headers:

  • Content-Type: application/json
  • X-API-Quota-Request: The number of points used by the request
  • X-API-Quota-Used: The number of points used in total today

Parameters

NameTypeExampleDescription
api-key string abcd1234 Your API key.
Example Request and Response
GET
https://api.humorapi.com/words/nonsense/random
{
    "word": "caboo",
    "rating": 0.41
}

Quotas

Calling this endpoint requires
1 point

Joke Categories

Every joke carries one or more tags. Use the tag values with include-tags and exclude-tags, for example include-tags=knock_knock or exclude-tags=nsfw,dark,racist,sexist,sexual for a family-friendly feed.

  • Clean clean
  • Animal animal
  • Food food
  • Sexual sexual
  • Knock Knock knock_knock
  • Sport sport
  • Blondes blondes
  • Law law
  • Nerdy nerdy
  • Relationship relationship
  • Deep Thoughts deep_thoughts
  • Dark dark
  • One Liner one_liner
  • Political political
  • Chuck Norris chuck_norris
  • Yo Momma yo_mama
  • NSFW nsfw
  • Religious religious
  • School school
  • Jewish jewish
  • Racist racist
  • Insults insults
  • Sexist sexist
  • Holiday holiday
  • Analogy analogy
  • Christmas christmas
  • Kids kids

Rate Limiting & Quotas

Each API plan comes with a daily quota of points. Every API call you make costs a certain amount of points. Usually, every request is
1 point
and
0.01 points
per result returned, but there are many exceptions. At the bottom of each endpoint description you will find information about the number of points required for that endpoint.

When you are on the free plan and your daily quota is used up, the API will respond with the error code 402 and no more calls can be made until your quota resets.

You have complete control over your quota by looking at your console dashboard and checking the API response headers that appear with every answer from the API. These response headers are:

  • X-API-Quota-Request: The number of points used by the request.
  • X-API-Quota-Used: The number of points used in total today. This number resets to zero at midnight UTC (click here to compare to your local time zone).
  • X-API-Quota-Left: The number of points left today (depends on your plan).

Rate Limiting

There is a limit of how many requests you can make per second. The limits depend on the plan you are on. If you try making more requests you will receive a 429 error.

  • Free: 60 requests in 1 minute
  • Jack: 2 requests per second
  • Jester: 5 requests per second
  • Joker: 10 requests per second

Authentication

To use the API you need an API key. You can get a free one by simply signing up here.

Once you have your API key, you have to put it in the request URL for every request you make like so ?api-key=YOUR-API-KEY.

Attention: Only the first query parameter is prefixed with a ? (question mark), all subsequent ones will be prefixed with a & (ampersand). That is how URLs work and nothing related to our API. Here's a full example with two parameters api-key and include-tags: https://api.humorapi.com/jokes/search?api-key=YOUR-API-KEY&include-tags=tag1,tag2.

Alternatively, you can put the API key in the request header as x-api-key.

Tutorial

Humor API is a jokes API application where you can access over 50,000 jokes in 27 categories. It also has a meme API feature where you can access over 450,000 memes. In this tutorial, we will look at getting jokes from specific tags.

The first thing to do is to create an account with Humor API. This is important because it is the only way to get an authentication key. You can find your key on your profile page. Next, we need to install the package.

Humor API console sign-up form for creating an account

Installation

On the SDK page, select an SDK library in the language of your choice. We will use Python for this tutorial. Open an editor and inspect the content of the library. README.md contains instructions on how to install the package using either git or setuptools.

Python SDK folder opened in a code editor README of the Humor API Python SDK with install instructions

The setup.py page contains the information and metadata needed for building, distributing and installing the open_client package which we will be using.

setup.py of the Humor API Python SDK

To install open_client using setup.py install, we need to install all relevant packages with pip, starting with python setuptools.

pip install setuptools
Terminal output of pip install setuptools

Then install the setup.py page

python setup.py install
Terminal output of python setup.py install Terminal output finishing the SDK installation

It loads all the dependencies for openapi-client and makes the package available for installation.

pip install openapi_client
Terminal output of pip install openapi_client

We will be needing other libraries like urllib3, requests, and pandas. Install those too with pip.

pip install urllib3
Terminal output of pip install urllib3
pip install requests
Terminal output of pip install requests
pip install pandas --user
Terminal output of pip install pandas

Interacting with the Jokes API

In the body of the editor, we will write the main code that allows us to interact and have access to the Jokes API. On the documentation page, there is detailed information on available API functions, endpoints, and response headers of each endpoint. We will use the 'search jokes' endpoint and include the needed tags.

First, we import the installed packages.

import openapi_client
import urllib3
import requests
import json
import pandas as pd

At this stage, we'll need the authentication key. The authentication key is added to the url of the api.

#defining our variables
url = 'https://api.humorapi.com/jokes/search?api-key=972aca79287xxxxxxxxxxxxxxxxxxx&include-tags=dark,relationship'
headers = {'content-type': 'application/json'}

The variable, url is the link to api.humor.com and it contains different parameters like the api key, keywords, tags, min-rating, max-length etc. In this case, we will use search_jokes endpoint, the api key and the tags of jokes we want, which are 'dark, law and relationship'.

Connection to the API will be made using urllib3 and request. The pool manager instance will handle the thread safety.

http = urllib3.PoolManager()

Then we make a request using request(). request() will return a HTTPResponse object.

http = urllib3.PoolManager()
req = http.request('GET', url, headers= headers)

print(type(req))

#<class 'urllib3.response.HTTPResponse'>

The request is made. We will view the output with a .data method.

print(req.data)
# req.data prints the jokes in text format
Raw bytes response of the search jokes request printed in Python

The output is in a text-like format, and its class is 'bytes'. It needs to be in JSON format so we can manipulate it using dictionary methods.

joke = json.loads(req.data.decode('UTF-8'))
print(joke)

print(type(joke))  #<class 'dict'>

We can check out the keys of the dictionary

print(joke.keys())

#dict_keys(['joke', 'available'])

On further examination, when we inspect the output for print(joke), joke key object is a list that contains two items - an id and joke as values.

Parsed JSON response with the jokes list in Python

We can represent this in a tabular form using pandas, with id and joke as column title.

We save a copy of the joke key to a new list

newj = joke['jokes']

And import it into a pandas dataframe

df = pd.DataFrame(newj)
print(df)

We get this output.

Jokes shown as a pandas DataFrame with id and joke columns

We can increase the number of jokes to get a more tabular feel. In the url, add a parameter, number, and set the value to 6.

url = 'https://api.humorapi.com/jokes/search?api-key=972aca7928764655af7xxxxxxxxxxx&number=6&include-tags=dark,law,relationship'

Run the program again.

Pandas DataFrame with six jokes

Accessing Humor API's jokes through the jokes api is quite a straightforward process and this tutorial shows how to do it from start to finish. The entire process can be run on any editor and console or notebook environment.