> For the complete documentation index, see [llms.txt](https://docs.night-api.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.night-api.com/joke/jokes/aleatoire.md).

# Random

## Random joke

<mark style="color:blue;">`GET`</mark> `https://api.night-api.com/jokes`

Génère une blague aléatoirement.

#### Query Parameters

| Name     | Type   | Description                                            |
| -------- | ------ | ------------------------------------------------------ |
| disallow | string | To avoid the generation of certain categories of jokes |

#### Headers

| Name                                            | Type   | Description  |
| ----------------------------------------------- | ------ | ------------ |
| authorization<mark style="color:red;">\*</mark> | String | Your API key |

{% tabs %}
{% tab title="200 Random joke find." %}

```javascript
{
    "status": 200,
    "content": {
        "id": 44,
        "type": "global",
        "blague": "Que dit un canard quand il va aux toilettes ?",
        "reponse": "Je vais au petit coin."
    }
}
```

{% endtab %}

{% tab title="400 Bad disallow query" %}

```javascript
{ 
    status: 400, 
    error: "Bad disallow query provided"
}
```

{% endtab %}
{% endtabs %}

**Lists of available categories:**

* global
* dev
* dark
* limit
* beauf
* blondes

<br>

```javascript
const axios = require("axios");

axios.get('https://api.night-api.com/jokes', {
    headers: {
        authorization: "API token"
    }
})
.then(function (response) {
    console.log(response.data);
})
```

\
Or with the NPM module

<pre class="language-javascript"><code class="lang-javascript">const { NightAPI } = require('night-api');
<strong>const api = new NightAPI('YOUR_API_KEY');
</strong>
const blague = await api.jokes.random(); // Return: Promise
</code></pre>

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

```javascript
const { NightAPI } = require('night-api');
const api = new NightAPI('YOUR_API_KEY');

const blague = await api.jokes.random({
  disallow: ['dark', 'limit']
}); // Return: Promise
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.night-api.com/joke/jokes/aleatoire.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
