An API and Library of Jokes.
Returns a random joke in this format:
{
"id": 229,
"type": "general",
"setup": "What do you call an alligator in a vest?",
"punchline": "An in-vest-igator!"
}
Returns an array of jokes with the length of {number}
.
[
{
"id": 20,
"type": "general",
"setup": "What do you call a laughing motorcycle?",
"punchline": "A Yamahahahaha."
},
{
"id": 272,
"type": "general",
"setup": "What lies atthe bottom of the ocean and twitches?",
"punchline": "A nervous wreck."
}
]
Returns an array with all the jokes whith the type {subject}
.
[
{
"id": 33,
"type": "programming",
"setup": "Which song would an exception sing?",
"punchline": "Can't catch me - Avicii"
},
{
"id": 28,
"type": "programming",
"setup": "To understand what recursion is...",
"punchline": "You must first understand what recursion is"
}
]
There are a lot more programming jokes than these, I don't add them because I don't want a huge readme.
Returns an array of the jokes whith the type {subject}
and the length
{number}
.
[
{
"id": 56,
"type": "programming",
"setup": "How do you check if a webpage is HTML5?",
"punchline": "Try it out on Internet Explorer"
}
]
Returns a joke whith the id {number}
.
{
"id": 425,
"type": "dad",
"setup": "Why don't eggs tell jokes?",
"punchline": "Because they would crack each other up."
}
Returns all the available jokes categories.
["general", "knock-knock", "programming", "anime", "food", "dad"]
Check the docs for language-specific wrappers, projects using this API and code snippets of usage.
import randomJoke, { randomJokeByType } from 'https://deno.land/x/joke/mod.ts';
console.log(randomJoke());
console.log(randomJokesByType('general'));
Check the docs to know all the exported functions and check the tests for more usage examples.
The first 300 Jokes comes from 15Dkatz/official_joke_api (At the moment of writting this, this project has 428 jokes.), the problem with that project is that its server is down, and it has not been updated for 2 years.
The other jokes were progressively added by contributors.
Submit a Pull Request, with your joke added to the data.ts. Make sure your joke is in this format:
{
"id": last joke id + 1,
"type": "programming",
"setup": "What's the best thing about a Boolean?",
"punchline": "Even if you're wrong, you're only off by a bit."
}
If you have an idea for a new endpoint, submit an Issue or a Pull Request.
This project is licensed under the MIT License.