A REST API for managing playlists
So the last 24 hours were spent on a code-sprint and this is the end product.
I built a Django REST API for retrieving and updating data to a PostgreSQL database of the backend of a music app that wishes to manage playlists and songs.
You can find the codebase on my github
A Django based REST API for managing songs and playlists, along with a graphical management interface
- Django Framework
- Django REST Framework
- SQLite(for development)
- PostgreSQL(for production)
- Create virtual environment using vne/virtualenv/etc using Python3.8
- Activate virtual environment in terminal
- Install dependencies by running ‘pip install -r requirements.txt’
- Run ‘python manage.py makemigrations’
- Run ‘python manage.py migrate’
- Run ‘python manage.py runserver’. The app should now be running locally at 127.0.0.1:8000 or localhost:8000
Using the app
- Go to the Admin Page (http://127.0.0.1:8000/admin/) and login as admin with the details below to to create new users/groups/manage database of app.
- The admin username is admin and password is testing321
- You can either use the Management Interface(after logging in as admin) or teh REST API(after creating a account and logging in) in order to view and update the songs/artists/albums/playlists information.
- The Management Interface at http://127.0.0.1:8000/admin/backend/ can be used to graphically add new users or update the music database of the app. You can use it to add new songs/artists/albums/playlists.
- The REST API at http://127.0.0.1:8000/api/api-home/ can be used to access the app and query its data using GET/POST requests and retrieving/updating data in API/JSON format.
- Home Page: http://127.0.0.1:8000/
- Admin Page: http://127.0.0.1:8000/admin/
- Register: http://127.0.0.1:8000/register/
- Login: http://127.0.0.1:8000/login/
- Access Management Interface: http://127.0.0.1:8000/admin/backend/
- Add/retrieve songs using Management Interface: http://127.0.0.1:8000/admin/backend/song/
- Add/retrieve artists using Management Interface: http://127.0.0.1:8000/admin/backend/artist/
- Add/retrieve albums using Management Interface: http://127.0.0.1:8000/admin/backend/album/
- Add/retrieve playlists using Management Interface: http://127.0.0.1:8000/admin/backend/playlist/
- Accessing REST API: http://127.0.0.1:8000/api/api-home/
- Add/retrieve songs using REST API: http://127.0.0.1:8000/api/songs/songs/
- Add/retrieve artists using REST API: http://127.0.0.1:8000/api/artists/artists/
- Add/retrieve albums using REST API: http://127.0.0.1:8000/api/albums/albums/
- Add/retrieve playlists using REST API: http://127.0.0.1:8000:api/playlists/playlists/
You can send GET requests with or without creating an account and logging in. Although, you have to create an account and be logged in in order to send POST requests.
I have included some test data for demonstration’s sake. I hope you appreciate my fine taste for music.
I have exported all of the SQL code from all the major migrations that I have made and stored it in /SQL directory in order to maintain database integrity.
Set DEBUG = True in setting.py of the backend app to view detailed logs and errors messages
If you find any bugs or if you think you can improve this implementation in any manner, please fork and create a pull request!
This is still a work in progress. I plan on dedicating more time for this in the future.