Task API is a FastAPI-based application for managing tasks. It allows users to perform CRUD (Create, Read, Update, Delete) operations on tasks. This API is protected by Firebase Authentication and provides endpoints for user registration, login, task creation, updating, deletion, and more.
- Overview
- Dependencies
- Getting Started
- API Endpoints
- Authentication
- Options, Head, and Trace Requests
This FastAPI application is designed for managing tasks with the following features:
- User registration and login using Firebase Authentication.
- Create, read, update, and delete tasks.
- Secure access to tasks based on user authentication.
- Swagger documentation and ReDoc for API reference.
The following libraries and services are used in this project:
- FastAPI: A modern, fast (high-performance) web framework for building APIs.
- Firebase Authentication: Used for user authentication.
- Firebase Firestore: A NoSQL cloud database for storing task data.
- Firebase Admin SDK: Used to interact with Firebase services.
- python-firebase: A Python library for interfacing with Firebase.
- python-dotenv: For managing environment variables.
- Clone this repository to your local machine.
- Create a Firebase project and configure your credentials.
- Set the required environment variables in a
.env
file. - Install the project dependencies using
pip install -r requirements.txt
. - Run the FastAPI application with
uvicorn main:app --reload
.
Make sure to replace FIREBASE_CREDENTIALS
and other necessary environment variables with your Firebase project configuration.
The API provides the following endpoints:
POST /register
: User registration.POST /login
: User login.GET /tasks
: Retrieve user-specific tasks.POST /task
: Create a new task.PUT /task/{task_id}
: Update a task.DELETE /task/{task_id}
: Delete a task.PATCH /task/{task_id}/complete
: Mark a task as completed.
For detailed request and response examples, refer to the Swagger Documentation, ReDoc, or the API endpoints section of the code.
User registration and login are required to access protected API endpoints. Firebase Authentication is used to securely manage user authentication. To register a new user, use the /register
endpoint, and for login, use the /login
endpoint. You will receive an access token for making authenticated requests to other endpoints.
The API also supports OPTIONS, HEAD, and TRACE requests:
OPTIONS /options
: List supported HTTP methods.HEAD /head
: Retrieve headers.TRACE /trace
: Trace HTTP request details.
These endpoints are primarily used for testing and exploring the available HTTP methods.
Note: Web browsers do not support TRACE requests. You can test this endpoint using cURL:
curl -v -X TRACE https://tasks-api-8-methods-bbf271afd2c6.herokuapp.com/trace