This project is a RESTful API developed with Flask that provides information about various cafes and their amenities. It supports operations for retrieving, adding, updating, and deleting cafe data.
- List all cafes.
- Get a random cafe.
- Search for a cafe by location or name.
- Add a new cafe.
- Update the price of coffee for a specific cafe.
- Delete a cafe entry (admin-restricted).
- Python
- Flask
- SQLAlchemy
- SQLite
To run this project, install it locally using pip:
$ pip install Flask
$ pip install Flask_SQLAlchemy
Method | URL | Description | Parameters | Response |
---|---|---|---|---|
GET | /random |
Get a random cafe | None | JSON object of a cafe |
GET | /all |
Get a list of all cafes | None | JSON list of cafes |
GET | /search |
Search for cafes by location or name | loc=[string] , name=[string] |
JSON object of a cafe |
POST | /add |
Add a new cafe | Form Data: name , cafe_url , img_url , loc , sockets , toilet , wifi , calls , seats , coffee_price |
Confirmation message |
PATCH | /update-price/<cafe_id> |
Update the coffee price of a cafe | URL Param: cafe_id , Arg: new_price |
Confirmation message |
DELETE | /report-closed/<cafe_id> |
Delete a cafe entry | URL Param: cafe_id , Arg: api-key |
Confirmation message or error |
Start the server:
$ python main.py
Utilize the endpoints via a browser or a tool like Postman to interact with the API.
Ali Jafarbeglou