JokeAPI icon

JokeAPI

Récupère des blagues multilingues et filtrables depuis JokeAPI.

Overview

This node fetches random jokes from the JokeAPI service, allowing users to filter jokes by categories, language, type, and content safety. It is useful for automating the retrieval of humorous content in various languages and styles, which can be integrated into chatbots, social media posts, newsletters, or entertainment apps.

For example, you could use this node to:

  • Retrieve a programming joke in English to lighten up a developer team's daily standup.
  • Get a safe-mode French two-part joke excluding dark or explicit content for family-friendly newsletters.
  • Fetch a random Christmas-themed pun joke in Spanish for holiday greetings.

Properties

Name Meaning
Categories Select joke categories to include. If none selected, all categories are used by default. Options: Programming, Miscellaneous, Dark, Pun, Spooky, Christmas.
Exclude Categories Select joke categories to exclude from results. Same options as Categories.
Language Choose the language of the joke. Options: English (en), German (de), Spanish (es), French (fr), Portuguese (pt), Czech (cz).
Joke Type Select joke format: "Single" (one-liner) or "Two Part" (question and answer).
Safe Mode If true, excludes jokes flagged as NSFW, Religious, Political, Racist, Sexist, or Explicit.

Output

The node outputs JSON data representing the joke retrieved from the API. The structure depends on the joke type:

  • For Single jokes, the output includes a single text field with the joke.
  • For Two Part jokes, the output contains separate fields for the setup (question) and delivery (answer).

If an error occurs, the output will contain an error message describing the issue.

No binary data is produced by this node.

Dependencies

  • External API: JokeAPI
  • HTTP requests are made using Axios.
  • Optional API key credential support (not required for basic usage).
  • No special environment variables needed beyond standard n8n configuration.

Troubleshooting

  • Common issues:

    • Providing an invalid joke ID when using the "Get Joke by ID" operation will cause an error.
    • Selecting mutually exclusive categories in both inclusion and exclusion lists may result in no jokes returned.
    • Network connectivity problems or JokeAPI downtime will cause request failures.
  • Error messages:

    • "Joke ID is required for this operation." — Occurs if the joke ID parameter is missing when fetching by ID. Fix by providing a valid numeric joke ID.
    • "JokeAPI returned an error." — Generic error indicating the API responded with an error; check parameters and API status.
    • "Unknown operation: <operation>" — Indicates an unsupported operation was requested; verify the operation name.
  • To handle errors gracefully, enable the node's "Continue On Fail" option to process subsequent items even if one fails.

Links and References

Discussion