Welcome to the Media Management API! This FastAPI application allows you to manage media items and their associated timestamps securely. The API supports user authentication and role-based access control, enabling different functionalities for admin and regular users.
- User Authentication: Secure login and token-based access.
- CRUD Operations: Create, Read, Update, and Delete media items.
- Role-Based Access Control: Admins can manage media and timestamps.
- SQLite Database: Simple and efficient data storage.
To get started, clone this repository and install the required packages.
git clone https://github.com/Ankitjarwall/TimeStamps
cd media-management-api
python -m venv venv
source venv/bin/activate # On Windows use `venv\Scripts\activate`
pip install fastapi[all] sqlalchemy passlib python-jose
uvicorn main:app --reload
After running the application, you can access the API at http://127.0.0.1:8000
.
You can find the interactive API documentation at http://127.0.0.1:8000/docs
.
To use the protected endpoints, you'll need to log in to get an access token. Use the /token
endpoint to authenticate.
POST /token
Content-Type: application/x-www-form-urlencoded
username=admin&password=adminpassword
{
"access_token": "your_access_token",
"token_type": "bearer"
}
Here are the main endpoints available in the API:
-
Add Media
POST /media/
- Requires admin role.
-
Get Media by ID
GET /media/{media_id}
-
Delete Media
DELETE /media/{media_id}
- Requires admin role.
-
Get All Media
GET /media/?limit=10
media_id
: Unique identifier for the media (string).title
: Title of the media (string).timestamps
: List of associated timestamps.
type
: Type of the timestamp (string).start_time
: Start time in "HH:MM:SS" format.end_time
: End time in "HH:MM:SS" format.
- Database: The application uses an SQLite database (
media.db
). Ensure you have write access to the directory. - Security: Change the
SECRET_KEY
in the code before deploying to production.
Contributions are welcome! Please create a pull request for any enhancements or bug fixes.
### Notes
- Replace `yourusername` and `your_email@example.com` with your actual GitHub username and email.
- Adjust the API documentation and any other details according to your project specifics as needed.