Deficit-API is a Django-based RESTful API designed to track and manage dietary intake, specifically focusing on caloric intake and expenditure. It allows users to maintain a log of foods consumed and exercises performed to manage their caloric deficit effectively.
- The Frontend is hosted using Netlify on MotiDivya Deficit Web App
- This API is hosted live using pythonanywhere to MotiDivya Deficit API
- Food Management: Users can add, update, and delete food items along with their caloric values and units.
- Exercise Tracking: Allows users to log their physical activities along with calories burned.
- Caloric Deficit Calculation: Automatically calculates daily caloric deficits based on food intake and exercise.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
What things you need to install the software:
- Python 3.x
- Django
- Django Rest Framework
A step-by-step series of examples that tell you how to get a development environment running:
-
Clone the repository:
git clone https://github.com/divyesh1099/Deficit-API.git
-
Install required packages:
pip install -r requirements.txt
-
Migrate the database:
python manage.py migrate
-
Run the server:
python manage.py runserver
Here's a summary of the API endpoints for managing user-added foods and exercises, formatted in a tabular view. This table assumes you are running the Django server locally and using the default development URL (http://127.0.0.1:8000/). Adjust as necessary for your actual environment, especially when deployed:
| Method | API Endpoint | Body | Headers | Description |
|---|---|---|---|---|
| POST | /userfoods/ |
{ "food": 1, "amount": 100 } |
Authorization: Token <your_token> Content-Type: application/json |
Create a new user food entry. |
| GET | /userfoods/ |
None | Authorization: Token <your_token> |
Retrieve a list of all food entries for the authenticated user. |
| GET | /userfoods/<int:id>/ |
None | Authorization: Token <your_token> |
Retrieve a specific user food entry by its ID. |
| PUT | /userfoods/<int:id>/ |
{ "food": 1, "amount": 150 } |
Authorization: Token <your_token> Content-Type: application/json |
Update an entire specific user food entry. |
| PATCH | /userfoods/<int:id>/ |
{ "amount": 120 } |
Authorization: Token <your_token> Content-Type: application/json |
Partially update a specific user food entry. |
| DELETE | /userfoods/<int:id>/ |
None | Authorization: Token <your_token> |
Delete a specific user food entry. |
| Method | API Endpoint | Body | Headers | Description |
|---|---|---|---|---|
| POST | /userexercises/ |
{ "exercise": 1, "duration": 30 } |
Authorization: Token <your_token> Content-Type: application/json |
Create a new user exercise entry. |
| GET | /userexercises/ |
None | Authorization: Token <your_token> |
Retrieve a list of all exercise entries for the authenticated user. |
| GET | /userexercises/<int:id>/ |
None | Authorization: Token <your_token> |
Retrieve a specific user exercise entry by its ID. |
| PUT | /userexercises/<int:id>/ |
{ "exercise": 1, "duration": 45 } |
Authorization: Token <your_token> Content-Type: application/json |
Update an entire specific user exercise entry. |
| PATCH | /userexercises/<int:id>/ |
{ "duration": 25 } |
Authorization: Token <your_token> Content-Type: application/json |
Partially update a specific user exercise entry. |
| DELETE | /userexercises/<int:id>/ |
None | Authorization: Token <your_token> |
Delete a specific user exercise entry. |
Notes:
- Replace
<int:id>with the actual ID of the user food entry you want to interact with. - Replace
<your_token>with the actual authentication token of the logged-in user. - The
foodvalue in the body should be the ID of an existing food in your database. - For
Authorization, you might need to replace'Token'with'Bearer'or another prefix depending on your authentication setup. - The actual URL path may vary depending on your project's
urls.pyconfiguration. - This table assumes you are using token-based authentication. If you are using a different method, the
Authorizationheader may vary. - The
Content-Type: application/jsonheader is important when sending a body payload; it tells the server to expect JSON data.
Instructions on how to deploy the project on a live system like PythonAnywhere:
- Set up your PythonAnywhere account and web app.
- Upload your project files or clone your repository.
- Set up your virtual environment and install dependencies.
- Configure static and media files.
- Reload your web app.
Detailed instructions are available on PythonAnywhere Help.
- Django - The web framework used
- Django Rest Framework - Toolkit for building Web APIs
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
- Divyesh Nandlal Vishwakarma - Initial work - LinkedIn Divyesh Vishwakarma
This project is licensed under the MIT License - see the LICENSE file for details.
- Divyesh Vishwakarma's Body that said, ITS TIME TO FEEL GOOD BABY.
- Moti❤️.