Source Code here: DAD JOKES API
Getting Started
Welcome to the Dad Jokes API! This service allows you to retrieve random dad jokes and submit your own.
The API is hosted at dadjokes.developersandbox.xyz
.
Get a Random Joke
To retrieve a random dad joke, send a GET request to the following endpoint:
GET https://dadjokes.developersandbox.xyz/api/v1/random
Example Response:
{
"id": 42,
"entry_date": "2024-01-17",
"author": "DadMaster3000",
"joke_text": "Why don't eggs tell jokes? They'd crack up!"
}
Submit a New Joke
To submit a new dad joke, send a POST request to the following endpoint:
POST https://dadjokes.developersandbox.xyz/api/v1/submit
Request Body:
{
"author": "YourName",
"joke_text": "Your hilarious dad joke goes here"
}
Example using curl:
curl -X POST \
https://dadjokes.developersandbox.xyz/api/v1/submit \
-H "Content-Type: application/json" \
-d '{"author": "YourName", "joke_text": "Why did the scarecrow win an award? Because he was outstanding in his field!"}'
Response Codes
- 200 OK: Successfully retrieved a random joke
- 201 Created: Successfully submitted a new joke
- 400 Bad Request: Invalid request body
- 500 Internal Server Error: Server-side error