All pages
Powered by GitBook
1 of 4

Loading...

Loading...

Loading...

Loading...

Random

All kinds of jokes of different types

Random joke

GET https://api.night-api.com/jokes

Génère une blague aléatoirement.

Query Parameters

Name
Type
Description

Headers

Name
Type
Description

Lists of available categories:

  • global

  • dev

  • dark

  • limit

Or with the NPM module

With this method, you can specify certain categories that you do not want to receive.

Category

Choose which Category of joke you would like to have

Joke by Category

GET https://api.night-api.com/jokes/:type

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: Promise
    const { NightAPI } = require('night-api');
    const api = new NightAPI('YOUR_API_KEY');
    
    const blague = await api.jokes.random({
      disallow: ['dark', 'limit']
    }); // Return: Promise
    Path Parameters
    Name
    Type
    Description

    type*

    string

    Type of jokes to get (global, beauf, dev, limit, dark)

    Headers

    Name
    Type
    Description

    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: Promise
    "reponse": "Je vais au petit coin."
    }
    }

    ID

    Choose a specific joke by its ID

    Blague par ID

    GET https://api.night-api.com/jokes/:id

    Path Parameters

    Name
    Type
    Description

    Headers

    Name
    Type
    Description

    Or with the NPM module

    Jokes

    Basic 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

    All jokes are only available in french for the moment. Sorry for the inconvenience.

    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", 
    }
    We are hard working for create a translation

    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

    🎲Random
    📋Category
    🆔ID
    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
        }
    }