sachasi / joke

😜 Random Joke API and Library for Deno

Home Page:https://joke.deno.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Joke 😜

GitMoji License: MIT Total Lines Of Code CI

An API and Library of Jokes.

API

GET /

https://joke.deno.dev

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!"
}

GET /{number}

https://joke.deno.dev/2

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."
	}
]

GET /type/{subject}

https://joke.deno.dev/type/programming

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.

GET /type/{subject}/{number}

https://joke.deno.dev/type/programming/1

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"
	}
]

GET /id/{number}

https://joke.deno.dev/id/425

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."
}

GET /categories/all

https://joke.deno.dev/categories/all

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.

Library

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.

How the Jokes were collected

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.

Contributing

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.

License

This project is licensed under the MIT License.

About

😜 Random Joke API and Library for Deno

https://joke.deno.dev

License:MIT License


Languages

Language:TypeScript 100.0%