Welcome to the Italian Jokes API! This API allows you to retrieve jokes about Italians. You can try out the deployed application at https://italian-jokes.vercel.app/. Feel free to interact with the API, and fetch jokes based on different subtypes.
Welcome to the Italian Jokes API, a simple API that allows you to retrieve jokes about Italians. This API provides various endpoints to fetch jokes based on different subtypes, such as one-liners, observational, stereotypes, wordplay, and long jokes.
To retrieve a joke, you can make a GET request to the following endpoint:
GET /api/jokes
You can also specify a subtype to fetch jokes of a specific type by appending the subtype
query parameter to the endpoint. The available subtypes include:
- All
- One-liner
- Observational
- Stereotype
- Wordplay
- Long
Example request to fetch jokes of the "One-liner" subtype:
GET /api/jokes?subtype=One-liner
The API responds with a JSON object containing the joke details, including the ID, joke text, type, and subtype.
To run the Italian Jokes API locally, follow these steps:
-
Clone the repository:
git clone https://github.com/your-username/italian-jokes-api.git
-
Install the required dependencies:
npm install
-
Start the server:
npm start
The API will be available at http://localhost:3000/api/jokes.
To access the collection of Italian jokes, you need to create the jokes.json file. Follow these additional instructions:
-
Navigate to the root folder of the project.
-
Create a new file named jokes.json.
-
Open the jokes.json file in a text editor.
-
Copy and paste the following jokes in the specified format:
[ { "id": 1, "joke": "Why did the Mafia cross the road? Forget about it.", "type": "Italian", "subtype": "One-liner" }, { "id": 2, "joke": "How does every Italian joke start? By looking over your shoulder.", "type": "Italian", "subtype": "Observational" }, // Add more jokes following the same format... ]
-
Save the jokes.json file.
Each joke in the jokes.json file should be in the following format:
{
"id": "[ID_NUMBER]",
"joke": "[JOKE_TEXT]",
"type": "[JOKE_TYPE]",
"subtype": "[JOKE_SUBTYPE]"
}
- [ID_NUMBER] represents the unique identifier for the joke (e.g., 1, 2, 3, ...).
- [JOKE_TEXT] is the actual joke text.
- [JOKE_TYPE] represents the type of joke (e.g., Italian, English, Puns, etc.).
- [JOKE_SUBTYPE] indicates the subtype of the joke (e.g., All, One-liner, Observational, Stereotype, Wordplay, Long).
Feel free to add more jokes following the same format. Make sure to separate each joke with a comma (,) except for the last one.
That's it! You have successfully set up and created the jokes.json file. You can now run the Italian Jokes API locally and access the jokes through the provided endpoint.
Contributions are welcome! If you have any improvements or suggestions for the Italian Jokes API, feel free to submit a pull request.
This project is licensed under the MIT License.
Built by Daniel Bliss.