All kinds of jokes of different types
beauf
blondes
disallow
string
To avoid the generation of certain categories of jokes
authorization*
String
Your API key
{
"status": 200,
"content": {
"id": 44,
"type": "global",
"blague": "Que dit un canard quand il va aux toilettes ?",
"reponse": "Je vais au petit coin."
}
}{
status: 400,
error: "Bad disallow query provided"
}const axios = require("axios");
axios.get('https://api.night-api.com/jokes', {
headers: {
authorization: "API token"
}
})
.then(function (response) {
console.log(response.data);
})const { NightAPI } = require('night-api');
const api = new NightAPI('YOUR_API_KEY');
const blague = await api.jokes.random(); // Return: Promiseconst { NightAPI } = require('night-api');
const api = new NightAPI('YOUR_API_KEY');
const blague = await api.jokes.random({
disallow: ['dark', 'limit']
}); // Return: Promisetype*
string
Type of jokes to get (global, beauf, dev, limit, dark)
authorization*
String
Your API key
{
"status": 200,
"content": {
"id": 44,
"type": "global",
"blague": "Que dit un canard quand il va aux toilettes ?",
{
"status": 400,
"error": "Bad type provided"
}Lists of available categories:
global
dev
dark
limit
beauf
blondes
Or with the NPM module
const axios = require("axios");
axios.get('https://api.night-api.com/jokes/global', {
headers: {
authorization: "API token"
}
})
.then(function (response) {
console.log(response.data);
})const { NightAPI } = require('night-api');
const api = new NightAPI('YOUR_API_KEY');
const blague = await api.jokes.byCategory('dev'); // Return: PromiseBasic information to know before using the Jokes API
This API requires an API key to be sent along with your requests: Get yours by creating an account
id*
number
ID de la blague à récupérer (Entre 1 et 900)
authorization*
String
Your API key
{
"status": 200,
"content": {
"id": 44,
"type": "global",
"blague": "Que dit un canard quand il va aux toilettes ?",
"reponse": "Je vais au petit coin."
}
}{
status: 400,
error: "Bad ID provided",
}Different methods exist to have jokes, currently there are three and here they are:
Random Jokes: You can only choose which category of joke you do not want to have
Jokes by category: You will receive only the jokes of which you indicated the category
Jokes by ID: You will receive the jokes of which you indicate the ID
Here is an example of what each method returns
const axios = require("axios");
axios.get('https://api.night-api.com/jokes/44', {
headers: {
authorization: "API token"
}
})
.then(function (response) {
console.log(response.data);
})const { NightAPI } = require('night-api');
const api = new NightAPI('YOUR_API_KEY');
const blague = await api.jokes.byID(50); // Return: Promise{
"status": 200, //The status allows to know if the joke was found or not
"content": {
"id": 44, // The unique identifier
"type": "global", // The category of the joke
"blague": "Que dit un canard quand il va aux toilettes ?", // The joke
"reponse": "Je vais au petit coin." // The answer
}
}