{"id":27876897,"url":"https://github.com/ethauvin/jokeapi","last_synced_at":"2025-05-05T02:53:38.643Z","repository":{"id":60479242,"uuid":"540337144","full_name":"ethauvin/jokeapi","owner":"ethauvin","description":"Retrieve jokes from Sv443's JokeAPI","archived":false,"fork":false,"pushed_at":"2025-04-26T02:33:03.000Z","size":576,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-26T03:38:55.357Z","etag":null,"topics":["android","java","joke","jokeapi","jokes","jokes-api","kotlin"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ethauvin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-09-23T07:57:43.000Z","updated_at":"2025-04-26T02:33:07.000Z","dependencies_parsed_at":"2023-11-24T03:21:09.603Z","dependency_job_id":"b6a4d2b5-86c6-44bb-a45f-b01e13d74563","html_url":"https://github.com/ethauvin/jokeapi","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethauvin%2Fjokeapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethauvin%2Fjokeapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethauvin%2Fjokeapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ethauvin%2Fjokeapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ethauvin","download_url":"https://codeload.github.com/ethauvin/jokeapi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252429954,"owners_count":21746571,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","java","joke","jokeapi","jokes","jokes-api","kotlin"],"created_at":"2025-05-05T02:53:38.130Z","updated_at":"2025-05-05T02:53:38.629Z","avatar_url":"https://github.com/ethauvin.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![License (3-Clause BSD)](https://img.shields.io/badge/license-BSD%203--Clause-blue.svg?style=flat-square)](https://opensource.org/licenses/BSD-3-Clause)\n[![Kotlin](https://img.shields.io/badge/kotlin-2.1.20-7f52ff)](https://kotlinlang.org/)\n[![bld](https://img.shields.io/badge/2.2.1-FA9052?label=bld\u0026labelColor=2392FF)](https://rife2.com/bld)\n[![Release](https://img.shields.io/github/release/ethauvin/jokeapi.svg)](https://github.com/ethauvin/jokeapi/releases/latest)\n[![Maven Central](https://img.shields.io/maven-central/v/net.thauvin.erik/jokeapi?color=blue)](https://central.sonatype.com/artifact/net.thauvin.erik/jokeapi)\n[![Nexus Snapshot](https://img.shields.io/nexus/s/net.thauvin.erik/jokeapi?label=snapshot\u0026server=https%3A%2F%2Foss.sonatype.org%2F)](https://oss.sonatype.org/content/repositories/snapshots/net/thauvin/erik/jokeapi/)\n\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=ethauvin_jokeapi\u0026metric=alert_status)](https://sonarcloud.io/dashboard?id=ethauvin_jokeapi)\n[![GitHub CI](https://github.com/ethauvin/jokeapi/actions/workflows/bld.yml/badge.svg)](https://github.com/ethauvin/jokeapi/actions/workflows/bld.yml)\n[![CircleCI](https://circleci.com/gh/ethauvin/jokeapi/tree/master.svg?style=shield)](https://circleci.com/gh/ethauvin/jokeapi/tree/master)\n\n# JokeAPI for Kotlin, Java and Android\n\nA simple library to retrieve jokes from [Sv443's JokeAPI](https://v2.jokeapi.dev/).\n\n## Examples (TL;DR)\n\n```kotlin\nimport net.thauvin.erik.jokeapi.joke\n\nval joke = joke()\nval safe = joke(safe = true)\nval pun = joke(categories = setOf(Category.PUN))\n```\nThe parameters match the [joke endpoint](https://v2.jokeapi.dev/#joke-endpoint).\n\nA `Joke` class instance is returned, matching the [response](https://v2.jokeapi.dev/joke/Any?type=single):\n\n```kotlin\ndata class Joke(\n    val category: Category,\n    val type: Type,\n    val joke: List\u003cString\u003e,\n    val flags: Set\u003cFlag\u003e,\n    val id: Int,\n    val safe: Boolean,\n    val lang: Language\n)\n```\n- View more [examples](https://github.com/ethauvin/jokeapi/blob/master/src/test/kotlin/net/thauvin/erik/jokeapi/GetJokeTest.kt#L64)...\n\nTo retrieve multiple jokes:\n\n```kotlin\nval frenchJokes = jokes(amount = 2, type = Type.TWOPART, lang = Language.FR)\nfrenchJokes.forEach {\n    println(it.joke.joinToString(\"\\n\"))\n    println(\"-\".repeat(46))\n}\n```\n\n- View more [examples](https://github.com/ethauvin/jokeapi/blob/master/src/test/kotlin/net/thauvin/erik/jokeapi/GetJokesTest.kt#L52)...\n\n\nIf an error occurs, a `JokeException` is thrown, matching the [JokeAPI errors](https://sv443.net/jokeapi/v2/#errors):\n\n```kotlin\nclass JokeException(\n    val internalError: Boolean,\n    val code: Int,\n    message: String,\n    val causedBy: List\u003cString\u003e,\n    val additionalInfo: String,\n    val timestamp: Long,\n    cause: Throwable? = null\n) : Exception(message, cause)\n```\n\nIf an HTTP error occurs an `HttpErrorException` is thrown, with its message and cause matching the [JokeAPI status codes](https://sv443.net/jokeapi/v2/#status-codes):\n\n```kotlin\nclass HttpErrorException(\n    val statusCode: Int,\n    message: String,\n    cause: Throwable? = null\n) : IOException(message, cause)\n```\n- View more [examples](https://github.com/ethauvin/jokeapi/blob/master/src/test/kotlin/net/thauvin/erik/jokeapi/ExceptionsTest.kt#L57)...\n\n## Java\n\nTo make it easier to use the library with Java, a configuration builder is available:\n\n```java\nvar config = new JokeConfig.Builder()\n        .type(Type.SINGLE)\n        .safe(true)\n        .build();\nvar joke = JokeApi.joke(config);\njoke.getJoke().forEach(System.out::println);\n```\n\n## bld\n\nTo use with [bld](https://rife2.com/bld), include the following dependency in your build file:\n\n```java\nrepositories = List.of(MAVEN_CENTRAL, SONATYPE_SNAPSHOTS_LEGACY);\n\nscope(compile)\n    .include(dependency(\"net.thauvin.erik\", \"jokeapi\", \"1.0.0\"));\n```\nBe sure to use the [bld Kotlin extension](https://github.com/rife2/bld-kotlin) in your project.\n\n## Gradle, Maven, etc.\nTo use with [Gradle](https://gradle.org/), include the following dependency in your build file:\n\n```gradle\nrepositories {\n    mavenCentral()\n    maven { url = uri(\"https://oss.sonatype.org/content/repositories/snapshots\") } // only needed for SNAPSHOT\n}\n\ndependencies {\n    implementation(\"net.thauvin.erik:jokeapi:1.0.0\")\n}\n```\n\nInstructions for using with Maven, Ivy, etc. can be found on [Maven Central](https://central.sonatype.com/artifact/net.thauvin.erik/jokeapi).\n\n## Raw Jokes\n\nYou can also retrieve one or more raw (unprocessed) jokes in all [supported formats](https://jokeapi.dev/#format-param).\n\nFor example for YAML:\n```kotlin\nvar jokes = getRawJokes(format = Format.YAML, idRange = IdRange(22))\nprintln(jokes.data)\n```\n\n```yaml\nerror: false\ncategory: \"Programming\"\ntype: \"single\"\njoke: \"If Bill Gates had a dime for every time Windows crashed ... Oh wait, he does.\"\nflags:\n  nsfw: false\n  religious: false\n  political: false\n  racist: false\n  sexist: false\n  explicit: false\nid: 22\nsafe: true\nlang: \"en\"\n```\n\n- View more [examples](https://github.com/ethauvin/jokeapi/blob/master/src/test/kotlin/net/thauvin/erik/jokeapi/GetRawJokesTest.kt#L46)...\n\n## Extending\n\nA generic `apiCall()` function is available to access other [JokeAPI endpoints](https://v2.jokeapi.dev/#endpoints). \n\nFor example to retrieve the French [language code](https://v2.jokeapi.dev/#langcode-endpoint):\n\n```kotlin\nval response = JokeApi.apiCall(\n    endPoint = \"langcode\",\n    path = \"french\",\n    params = mapOf(Parameter.FORMAT to Format.YAML.value)\n)\nif (response.statusCode == 200) {\n    println(response.data)\n}\n```\n\n```yaml\nerror: false\ncode: \"fr\"\n```\n- View more [examples](https://github.com/ethauvin/jokeapi/blob/master/src/test/kotlin/net/thauvin/erik/jokeapi/ApiCallTest.kt#L48)...\n\n## Contributing\n\nIf you want to contribute to this project, all you have to do is clone the GitHub\nrepository:\n\n```console\ngit clone git@github.com:ethauvin/jokeapi.git\n```\n\nThen use [bld](https://rife2.com/bld) to build:\n\n```console\ncd jokeapi\n./bld compile\n```\n\nThe project has an [IntelliJ IDEA](https://www.jetbrains.com/idea/) project structure. You can just open it after all\nthe dependencies were downloaded and peruse the code.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fethauvin%2Fjokeapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fethauvin%2Fjokeapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fethauvin%2Fjokeapi/lists"}