### Fetch Random Dad Joke for Slack
Source: https://icanhazdadjoke.com/api
Get a random dad joke formatted specifically for Slack messages. This endpoint always returns JSON.
```bash
$ curl https://icanhazdadjoke.com/slack
{
"attachments": [
{
"fallback": "What kind of magic do cows believe in? MOODOO.",
"footer": " - ",
"text": "What kind of magic do cows believe in? MOODOO."
}
],
"response_type": "in_channel",
"username": "icanhazdadjoke"
}
```
--------------------------------
### Set Custom User-Agent for API Requests
Source: https://icanhazdadjoke.com/api
When using the API, set a custom User-Agent header. This helps monitor API usage and identify potential issues. Include your library/website name and a contact URL/email.
```bash
curl -H "User-Agent: My Library (https://github.com/username/repo)" https://icanhazdadjoke.com/
```
--------------------------------
### Search Dad Jokes (JSON)
Source: https://icanhazdadjoke.com/api
Use this endpoint to search for dad jokes and receive results in JSON format. Optional query parameters include 'page', 'limit', and 'term'.
```bash
$ curl -H "Accept: application/json" https://icanhazdadjoke.com/search
```
```json
{
"current_page": 1,
"limit": 20,
"next_page": 2,
"previous_page": 1,
"results": [
{
"id": "M7wPC5wPKBd",
"joke": "Did you hear the one about the guy with the broken hearing aid? Neither did he."
},
{
"id": "MRZ0LJtHQCd",
"joke": "What do you call a fly without wings? A walk."
},
...
{
"id": "usrcaMuszd",
"joke": "What's the worst thing about ancient history class? The teachers tend to Babylon."
}
],
"search_term": "",
"status": 200,
"total_jokes": 307,
"total_pages": 15
}
```
--------------------------------
### Fetch Dad Joke as Image
Source: https://icanhazdadjoke.com/api
Retrieve a dad joke as an image. Append '.png' to the joke ID in the URL.
```html
```
--------------------------------
### Fetch Specific Dad Joke as JSON
Source: https://icanhazdadjoke.com/api
Retrieve a specific dad joke by its ID in JSON format. Include the joke ID in the URL and set the 'Accept: application/json' header.
```bash
$ curl -H "Accept: application/json" https://icanhazdadjoke.com/j/R7UfaahVfFd
{
"id": "R7UfaahVfFd",
"joke": "My dog used to chase people on a bike a lot. It got so bad I had to take his bike away.",
"status": 200
}
```
--------------------------------
### Fetch a dad joke as an image
Source: https://icanhazdadjoke.com/api
Retrieves a specific dad joke rendered as a PNG image.
```APIDOC
## GET /j/{joke_id}.png
### Description
Fetches a dad joke as a PNG image.
### Method
GET
### Endpoint
https://icanhazdadjoke.com/j/.png
### Parameters
#### Path Parameters
- **joke_id** (string) - Required - The unique identifier of the joke to fetch.
```
--------------------------------
### Fetch Random Dad Joke as JSON
Source: https://icanhazdadjoke.com/api
Retrieve a random dad joke formatted as JSON. Ensure you set the 'Accept: application/json' header for this response type.
```bash
$ curl -H "Accept: application/json" https://icanhazdadjoke.com/
{
"id": "R7UfaahVfFd",
"joke": "My dog used to chase people on a bike a lot. It got so bad I had to take his bike away.",
"status": 200
}
```
--------------------------------
### Search Dad Jokes by Term (JSON)
Source: https://icanhazdadjoke.com/api
Perform a search for dad jokes containing a specific term, receiving results in JSON format. Ensure the 'Accept' header is set to 'application/json'.
```bash
$ curl -H "Accept: application/json" "https://icanhazdadjoke.com/search?term=hipster"
```
```json
{
"current_page": 1,
"limit": 20,
"next_page": 1,
"previous_page": 1,
"results": [
{
"id": "GlGBIY0wAAd",
"joke": "How much does a hipster weigh? An instagram."
},
{
"id": "xc21Lmbxcib",
"joke": "How did the hipster burn the roof of his mouth? He ate the pizza before it was cool."
}
],
"search_term": "hipster",
"status": 200,
"total_jokes": 2,
"total_pages": 1
}
```
--------------------------------
### Fetch Specific Dad Joke as Plain Text
Source: https://icanhazdadjoke.com/api
Retrieve a specific dad joke by its ID as plain text. Use the joke ID in the URL and set the 'Accept: text/plain' header.
```bash
$ curl -H "Accept: text/plain" https://icanhazdadjoke.com/j/R7UfaahVfFd
My dog used to chase people on a bike a lot. It got so bad I had to take his bike away.
```
--------------------------------
### GraphQL Endpoint
Source: https://icanhazdadjoke.com/api
Access jokes and their details through a GraphQL interface. You can query for a specific joke by providing a search term.
```APIDOC
## GraphQL
### Description
Provides a GraphQL endpoint to query for jokes.
### Endpoint
https://icanhazdadjoke.com/graphql
### Schema
```graphql
schema {
query Query
}
type Query {
joke(query: String): Joke
}
type Joke {
id ID
joke String
permalink String
}
```
### Request Example
```bash
$ curl -X POST -d '{"query": "query { joke {id joke permalink } }"}' -H "Content-Type: application/json" https://icanhazdadjoke.com/graphql
```
### Response Example
```json
{
"data": {
"joke": {
"id": "1DQZDY0gVnb",
"joke": "What is a centipedes's favorite Beatle song? I want to hold your hand, hand, hand, hand...",
"permalink": "https://icanhazdadjoke.com/j/1DQZDY0gVnb"
}
}
}
```
```
--------------------------------
### Search Dad Jokes (Text)
Source: https://icanhazdadjoke.com/api
Retrieve dad jokes as plain text using this endpoint. This is useful for simple integrations where JSON parsing is not required.
```bash
$ curl -H "Accept: text/plain" https://icanhazdadjoke.com/search
```
```text
Did you hear the one about the guy with the broken hearing aid? Neither did he.
What do you call a fly without wings? A walk.
When my wife told me to stop impersonating a flamingo, I had to put my foot down.
What do you call someone with no nose? Nobody knows.
What time did the man go to the dentist? Tooth hurt-y.
Why can’t you hear a pterodactyl go to the bathroom? The p is silent.
How many optometrists does it take to change a light bulb? 1 or 2? 1... or 2?
I was thinking about moving to Moscow but there is no point Russian into things.
Why does Waldo only wear stripes? Because he doesn't want to be spotted.
Do you know where you can get chicken broth in bulk? The stock market.
I used to work for a soft drink can crusher. It was soda pressing.
A ghost walks into a bar and asks for a glass of vodka but the bar tender says, “sorry we don’t serve spirits”
I went to the zoo the other day, there was only one dog in it. It was a shitzu.
I gave all my dead batteries away today, free of charge.
Why are skeletons so calm? Because nothing gets under their skin.
There’s a new type of broom out, it’s sweeping the nation.
Why don’t seagulls fly over the bay? Because then they’d be bay-gulls!
What did celery say when he broke up with his girlfriend? She wasn't right for me, so I really don't carrot all.
Q: What’s 50 Cent’s name in Zimbabwe? A: 400 Million Dollars.
What's the worst thing about ancient history class? The teachers tend to Babylon.
```
--------------------------------
### GraphQL Query for Dad Joke
Source: https://icanhazdadjoke.com/api
Query the GraphQL endpoint to retrieve a dad joke, including its ID, joke text, and permalink. The request must be a POST with a JSON body containing the GraphQL query.
```bash
$ curl -X POST -d '{"query": "query { joke {id joke permalink } }"}' -H "Content-Type: application/json" https://icanhazdadjoke.com/graphql
```
```json
{
"data": {
"joke": {
"id": "1DQZDY0gVnb",
"joke": "What is a centipedes's favorite Beatle song? I want to hold your hand, hand, hand, hand...",
"permalink": "https://icanhazdadjoke.com/j/1DQZDY0gVnb"
}
}
}
```
--------------------------------
### Fetch Random Dad Joke as Plain Text
Source: https://icanhazdadjoke.com/api
Retrieve a random dad joke as plain text. Use the 'Accept: text/plain' header for this format.
```bash
$ curl -H "Accept: text/plain" https://icanhazdadjoke.com/
My dog used to chase people on a bike a lot. It got so bad I had to take his bike away.
```
--------------------------------
### Fetch a random dad joke
Source: https://icanhazdadjoke.com/api
Retrieves a random dad joke from the API. The response format can be specified using the 'Accept' header.
```APIDOC
## GET /
### Description
Fetches a random dad joke.
### Method
GET
### Endpoint
https://icanhazdadjoke.com/
### Parameters
#### Headers
- **Accept** (string) - Optional - Specifies the desired response format. Accepted values: `text/html` (default), `application/json`, `text/plain`.
### Request Example
```bash
curl -H "Accept: application/json" https://icanhazdadjoke.com/
```
### Response
#### Success Response (200)
- **id** (string) - The unique identifier for the joke.
- **joke** (string) - The dad joke text.
- **status** (integer) - The HTTP status code.
```
--------------------------------
### Search for Dad Jokes
Source: https://icanhazdadjoke.com/api
This endpoint allows you to search for dad jokes using various query parameters. You can specify the page number, the number of results per page, and a search term. The results can be returned in JSON or plain text format.
```APIDOC
## GET /search
### Description
Searches for dad jokes with optional pagination and search term filtering.
### Method
GET
### Endpoint
https://icanhazdadjoke.com/search
### Parameters
#### Query Parameters
- **page** (integer) - Optional - Which page of results to fetch (default: 1)
- **limit** (integer) - Optional - Number of results to return per page (default: 20, max: 30)
- **term** (string) - Optional - Search term to use (default: list all jokes)
### Request Example
```bash
$ curl -H "Accept: application/json" "https://icanhazdadjoke.com/search?term=hipster"
```
### Response
#### Success Response (200)
- **current_page** (integer) - The current page number of the results.
- **limit** (integer) - The number of results per page.
- **next_page** (integer) - The next page number, or null if on the last page.
- **previous_page** (integer) - The previous page number, or null if on the first page.
- **results** (array) - A list of joke objects, each containing 'id' and 'joke'.
- **search_term** (string) - The search term used for the query.
- **status** (integer) - The HTTP status code of the response.
- **total_jokes** (integer) - The total number of jokes matching the search term.
- **total_pages** (integer) - The total number of pages available for the given search.
#### Response Example (JSON)
```json
{
"current_page": 1,
"limit": 20,
"next_page": 2,
"previous_page": 1,
"results": [
{
"id": "M7wPC5wPKBd",
"joke": "Did you hear the one about the guy with the broken hearing aid? Neither did he."
},
{
"id": "MRZ0LJtHQCd",
"joke": "What do you call a fly without wings? A walk."
}
],
"search_term": "",
"status": 200,
"total_jokes": 307,
"total_pages": 15
}
```
#### Response Example (Text)
```text
Did you hear the one about the guy with the broken hearing aid? Neither did he.
What do you call a fly without wings? A walk.
```
```
--------------------------------
### Fetch a random dad joke as a Slack message
Source: https://icanhazdadjoke.com/api
Retrieves a random dad joke formatted specifically for Slack messages. This endpoint always returns JSON.
```APIDOC
## GET /slack
### Description
Fetches a random dad joke formatted for Slack messages.
### Method
GET
### Endpoint
https://icanhazdadjoke.com/slack
### Response
#### Success Response (200)
- **attachments** (array) - An array containing a single attachment object with joke details.
- **fallback** (string) - A fallback string for notifications.
- **footer** (string) - Footer text.
- **text** (string) - The joke text.
- **response_type** (string) - Indicates the type of response, typically "in_channel".
- **username** (string) - The username for the bot, typically "icanhazdadjoke".
```
--------------------------------
### Fetch a specific dad joke
Source: https://icanhazdadjoke.com/api
Retrieves a specific dad joke using its unique ID. The response format can be specified using the 'Accept' header.
```APIDOC
## GET /j/{joke_id}
### Description
Fetches a specific dad joke by its ID.
### Method
GET
### Endpoint
https://icanhazdadjoke.com/j/
### Parameters
#### Path Parameters
- **joke_id** (string) - Required - The unique identifier of the joke to fetch.
#### Headers
- **Accept** (string) - Optional - Specifies the desired response format. Accepted values: `text/html`, `application/json`, `text/plain`.
### Request Example
```bash
curl -H "Accept: application/json" https://icanhazdadjoke.com/j/R7UfaahVfFd
```
### Response
#### Success Response (200)
- **id** (string) - The unique identifier for the joke.
- **joke** (string) - The dad joke text.
- **status** (integer) - The HTTP status code.
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.