😂 jokeapi 😂

🚨 Note: due to the different types of humor, JokeAPI contains a wide variety of jokes, of which some are very offensive. They can be filtered out using the blacklistFlags or safe-mode parameters, but use this API at your own risk!

Dart client for JokeAPI.

jokeapi Uptime / 7 Days

Get various jokes from JokeAPI without any API token, membership, registration or payment.

Usage

import 'package:jokeapi/jokeapi.dart';

void main() async {
  final jokeApi = JokeApi();

  Joke joke;
  joke = await jokeApi.getJoke(type: JokeType.single);
  print('Single Joke:');
  printJoke(joke);
  joke = await jokeApi.getJoke(type: JokeType.twoPart);
  print('Two-part Joke:');
  printJoke(joke);
}

Future<void> printJoke(Joke joke) async {
  print('Let me tell you a joke!');
  switch (joke.content) {
    case SingleJoke(:var joke):
      print(joke);
    case TwoPartJoke(:var setup, :var delivery):
      print(setup);
      print(delivery);
  }
  print('Did you get it?');
}

Planned Features

  • Error handling
  • Automate API generation
  • x Supported endpoints
    • x v2.jokeapi.dev/joke/[Category/-ies]
    • v2.jokeapi.dev/info
    • x v2.jokeapi.dev/categories
    • v2.jokeapi.dev/langcode/[Language]
    • v2.jokeapi.dev/languages
    • x v2.jokeapi.dev/flags
    • v2.jokeapi.dev/formats
    • v2.jokeapi.dev/ping
    • v2.jokeapi.dev/endpoints
    • v2.jokeapi.dev/submit

Support

Buy Me A Coffee

Libraries

jokeapi