A simple API built using the Echo framework in Golang.
- Getting started introduces you to the operations offered by the API.
- API calls gives you examples of those operations
type: identifier of group/type of joke
| # | Type |
|---|---|
| 1 | General |
| 2 | Knock-Knock |
| 3 | Programming |
| Endpoint | What it does |
|---|---|
GET /random |
Returns a joke object that contains a setup, punchline, type and id |
GET /random/:n |
Returns an array with up to 44 joke objects. |
GET /joke/:id |
Returns a joke object with a specific id. |
POST /new |
Provided a setup, punchline and type it will insert the joke into the db. |
DELETE /remove/:id |
Remove a joke with the given id |
UPDATE /update/:id |
Provided a new setup or punchline or type it will update the joke with the given id. |
This API supports a data response in JSON format.
{
"id": 43,
"type": "general",
"punchline": "To prove that he was framed!",
"setup": "Why did the burglar hang his mugshot on the wall?"
}count: number of jokes to be fetched
/random/2
[
{
"id": 8,
"type": "general",
"punchline": "To get to the other slide.",
"setup": "Why did the kid cross the playground?"
},
{
"id": 40,
"type": "general",
"punchline": "Lots of training",
"setup": "How do locomotives know where they're going?"
}
]id: unique identifier for a joke
/joke/1
[
{
"id": 1,
"type": "general",
"setup": "What did the fish say when it hit the wall?",
"punchline": "Dam."
}
]Post request body:
{
"setup": "this is a test",
"punchline": "this is a funny test",
"type": "test"
}Response
{
"responseMsg": "Success",
"statusCode": 200,
"joke": {
"id": 134,
"setup": "this is a test",
"punchline": "this is a funny test",
"type": "test"
}
}/remove/3
{
"statusCode": 200,
"message": "Delete operation successful!"
}/update/3
Request body
{
"type": "general",
"punchline": "Guilty",
"setup": "Do I enjoy making courthouse puns?"
}Response
{
"responseMsg": "Success",
"statusCode": 200,
"joke": {
"id": 3,
"type": "general",
"punchline": "Guilty",
"setup": "Do I enjoy making courthouse puns?"
}
}Click here to check out my other projects