This document provides instructions on how to use the Dad Jokes API.
Retrieve a random dad joke from the database.
GET /api/v2/random
curl https://dadjokes.developersandbox.xyz/api/v2/random
{
"id": 1,
"entry_date": "2024-01-06T12:00:00Z",
"author": "John Doe",
"joke_text": "Why don't eggs tell jokes? They'd crack up!"
}
{
"message": "No jokes found in the database."
}
Submit a new dad joke to the database.
POST /api/v2/submit
Content-Type: application/json
{
"author": "Jane Doe",
"joke_text": "Why don't programmers like nature? It has too many bugs!"
}
curl -X POST -H "Content-Type: application/json" -d '{
"author": "Jane Doe",
"joke_text": "Why don't programmers like nature? It has too many bugs!"
}' https://dadjokes.developersandbox.xyz/api/v2/submit
{
"id": 2,
"entry_date": "2024-01-06T12:01:00Z",
"author": "Jane Doe",
"joke_text": "Why don't programmers like nature? It has too many bugs!"
}
The source code for this API can be found on GitHub: https://github.com/andrewthecodertx/go-dadjokes-api