# 1. Clone the repo
git clone https://github.com/yourusername/free-jokes-api.git
cd free-jokes-api
# 2. Install required Python packages
pip install -r requirements.txt
# 3. Run the Flask app
python app.py
# Access it at:
# http://localhost:5000/jokesA simple and fun Flask-based API that lets users view and add jokes.
Deployed live at 👉 https://free-jokes-api.onrender.com
- ✅ GET & POST endpoints
- ✅ JSON response format
- ✅ Rate-limited: 10 requests per minute per IP
- ✅ Easy deployment (Render-ready)
- ✅ In-memory joke storage
Returns all available jokes:
📌 Example:
curl https://free-jokes-api.onrender.com/jokes📥 Sample Response:
{
"jokes": [
{
"id": "J001",
"setup": "Why do programmers prefer dark mode?",
"punchline": "Because light attracts bugs!"
},
...
]
}Add a new joke. Only punchline is required.
📌 Example:
curl -X POST https://free-jokes-api.onrender.com/jokes \
-H "Content-Type: application/json" \
-d '{"setup": "Why did the tomato blush?", "punchline": "Because it saw the salad dressing."}'📥 Sample Response:
{
"message": "New joke added"
}To prevent spam, each IP is limited to:
🔁 10 requests per minute
git clone https://github.com/yourusername/free-jokes-api.git
cd free-jokes-apipip install -r requirements.txtpython app.pyGo to: http://localhost:5000/jokes
- Push to GitHub
- Go to https://render.com
- Create New Web Service
- Fill:
| Setting | Value |
|---|---|
| Build Command | pip install -r requirements.txt |
| Start Command | python app.py |
| Runtime | Python 3.x |
✅ Done! Render gives you a public link.
free-jokes-api/
├── app.py # Flask API logic
├── requirements.txt # Python packages
├── Procfile # Render start command
└── runtime.txt # Python version
- Flask
- flask-limiter
- gunicorn
Install with:
pip install -r requirements.txtMIT License — use it freely!