This is a music app API that allows users to authenticate and manage their songs. It is built using FastAPI and PostgreSQL. This backend is for the frontend available here.
- Python 3.8 or higher
- PostgreSQL
- Cloudinary account
-
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts\activate`
-
Install the dependencies:
pip install -r requirements.txt
-
Create a
.env
file in the root directory and add the following environment variables:DATABASE_URL=postgresql://user:password@localhost/dbname JWT_SECRET_KEY=secret CLOUDINARY_CLOUD_NAME=cloud_name CLOUDINARY_API_KEY=api_key CLOUDINARY_API_SECRET=api_secret
-
Ensure PostgreSQL is running.
-
Start the server:
fastapi dev main.py
- Description: Register a new user.
- Body Parameters:
name
(string, required): The user's full name.email
(string, required): The user's email address.password
(string, required): The user's password.
- Description: Login a user.
- Body Parameters:
email
(string, required): The user's email address.password
(string, required): The user's password.
- Description: Get the current user profile.
- Headers:
Authorization
: Bearer<token>
- Description: Upload a new song.
- Headers:
Authorization
: Bearer<token>
- Form Parameters:
song
(file, required): The audio file of the song.thumbnail
(file, required): The thumbnail image for the song.artist
(string, required): The artist's name.song_name
(string, required): The name of the song.hex_code
(string, required): Color code associated with the song.
- Description: Get a list of all songs.
- Headers:
Authorization
: Bearer<token>
- Description: Favorite or unfavorite a song.
- Headers:
Authorization
: Bearer<token>
- Body Parameters:
song_id
(string, required): The ID of the song to favorite/unfavorite.
- Description: Get the list of favorite songs for the current user.
- Headers:
Authorization
: Bearer<token>