{"id":22731320,"url":"https://github.com/sno2/dad_jokes","last_synced_at":"2026-06-06T15:01:35.357Z","repository":{"id":57675424,"uuid":"306356019","full_name":"sno2/dad_jokes","owner":"sno2","description":"A simple Deno API wrapper for the icanhazdadjoke Dad Joke Api","archived":false,"fork":false,"pushed_at":"2020-10-22T14:48:08.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-05-18T06:53:00.572Z","etag":null,"topics":["api","api-wrapper","dadjokes","deno","deno-module","hacktoberfest"],"latest_commit_sha":null,"homepage":"https://deno.land/x/dad_jokes","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sno2.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-10-22T14:02:16.000Z","updated_at":"2020-10-25T04:41:26.000Z","dependencies_parsed_at":"2022-09-26T16:40:12.487Z","dependency_job_id":null,"html_url":"https://github.com/sno2/dad_jokes","commit_stats":null,"previous_names":["codingcarter/dad_jokes"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/sno2/dad_jokes","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sno2%2Fdad_jokes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sno2%2Fdad_jokes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sno2%2Fdad_jokes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sno2%2Fdad_jokes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sno2","download_url":"https://codeload.github.com/sno2/dad_jokes/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sno2%2Fdad_jokes/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33881107,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-03T02:00:06.370Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["api","api-wrapper","dadjokes","deno","deno-module","hacktoberfest"],"created_at":"2024-12-10T19:21:26.807Z","updated_at":"2026-06-06T15:01:35.308Z","avatar_url":"https://github.com/sno2.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dad_jokes\n\nA simple API wrapper for the icanhazdadjoke Dad Jokes API!\n\n## Prelude\n\nAlthough I wish that I had been able to setup this using typescript interfaces or for all of the responses, I was not able to due to Typescript not running at run-time. Therefore, I have opted for a class solution which allows Typescript to help us with null-checking and other useful features.\n\n## Getting Started\n\nTo use the module, first import whatever functions/classes you want to use via the following code:\n\n```ts\nimport { setDadJokesUserAgent } from \"https://deno.land/x/dad_jokes/mod.ts\";\n```\n\nAs you can see, we have a function to set the `User-Agent` head of all requests. This is very important as it allows the icanhazdadjoke api maintainers to prevent spam. At the top of every single program that you are using the api functions, remember to include `setDadJokesUserAgent(\"dad_jokes module testing\")`. Obviously, you should put whatever your project is for or the name of the project inside of the function parameters. An important thing to note is that you need to run the file with the `--allow-net` flag, as we are sending network requests via the fetch api.\n\n## Usage\n\nNow that you know how to get started with this module, let's start to dive into all of the functions that it allows you to use. Let's start with the `getRandomJoke` function. It doesn't have any parameters and returns a `JokeResponse` class. Here is an example of the usage:\n\n```ts\nimport {\n  setDadJokesUserAgent,\n  getRandomJoke,\n} from \"https://deno.land/x/dad_jokes/mod.ts\";\n\nsetDadJokesUserAgent(\"dad_jokes module testing\");\n\nconsole.log(await getRandomJoke());\n```\n\nAnd the console output would look something like this:\n\n```console\nJokeResponse {\n  id: \"VDYgib2T7wc\",\n  joke: \"When you have a bladder infection, urine trouble.\",\n  status: 200,\n  message: undefined\n}\n```\n\nAs you can see, we have a `JokeResponse` `id`, `joke`, `status`, and `message`. The `message` would have the value of the `message` that was sent with the response if present. Because there wasn't an error, it's just `undefined`.\n\nWe can also fetch a joke based upon it's `id`. Here's an example:\n\n```ts\nimport {\n  setDadJokesUserAgent,\n  getJoke,\n} from \"https://deno.land/x/dad_jokes/mod.ts\";\n\nsetDadJokesUserAgent(\"dad_jokes module testing\");\n\nconsole.log(await getJoke(\"VDYgib2T7wc\"));\n```\n\nWe used the same of the `JokeResponse` that we had gotten before, therefore the console should show the same exact thing as above:\n\n```console\nJokeResponse {\n  id: \"VDYgib2T7wc\",\n  joke: \"When you have a bladder infection, urine trouble.\",\n  status: 200,\n  message: undefined\n}\n```\n\nAlso, you are able to get a random joke for slack messages via the `getRandomSlackJoke` function:\n\n```ts\nimport {\n  setDadJokesUserAgent,\n  getRandomSlackJoke,\n} from \"https://deno.land/x/dad_jokes/mod.ts\";\n\nsetDadJokesUserAgent(\"dad_jokes module testing\");\n\nconsole.log(await getRandomSlackJoke());\n```\n\nWith the following output:\n\n```console\nSlackJokeResponse {\n  attachments: [\n    {\n      fallback: \"Astronomers got tired watching the moon go around the earth for 24 hours. They decided to call it a ...\",\n      footer: \"\u003chttps://icanhazdadjoke.com/j/Qusrcahiib|permalink\u003e - \u003chttps://icanhazdadjoke.com|icanhazdadjoke.com...\",\n      text: \"Astronomers got tired watching the moon go around the earth for 24 hours. They decided to call it a ...\"\n    }\n  ],\n  response_type: \"in_channel\",\n  username: \"icanhazdadjoke\"\n}\n```\n\nFinally, the last api-oriented function is the `getSearchedJokes` function that can take up to 3 parameters, but only requires one. The parameters are the search term (`string`), the paginated page to go to (`number`), and the limit of jokes to show per page (`number`), respectively. Here is an example usage of the `getSearchedJokes` function:\n\n```ts\nimport {\n  setDadJokesUserAgent,\n  getSearchedJokes,\n} from \"https://deno.land/x/dad_jokes/mod.ts\";\n\nsetDadJokesUserAgent(\"dad_jokes module testing\");\n\nconsole.log(await getSearchedJokes(\"mountains\"));\n```\n\nThe output would be the following:\n\n```console\nSearchedJokesResponse {\n  status: 200,\n  message: undefined,\n  current_page: 1,\n  limit: 20,\n  next_page: 1,\n  results: [ { id: \"UKeiNeVnrc\", joke: \"Mountains aren't just funny, they are hill areas\" } ],\n  search_term: \"mountains\",\n  total_jokes: 1,\n  total_pages: 1\n}\n```\n\nAs you can tell, we have all of our jokes within the `results` `array`, and the other options are direct children of the `SearchedJokesResponse` object.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsno2%2Fdad_jokes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsno2%2Fdad_jokes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsno2%2Fdad_jokes/lists"}