This is essentially an upgrade of my previous waifu list REST API. There are numerous differences in this project, which will be highlighted in the Built With section. That being said, may I present the new and improved Waifu List REST API!
To get started locally, clone the repo and install the necessary dependencies. Then:
- Go to settings.py, set DEBUG=False for local deployment
- cd waifu_list
- python manage.py runserver
python==3.8.0
Django==4.1.2
djangorestframework==3.14.0
Pillow==9.2.0
psycopg2==2.9.4
python-dotenv==0.21.0
supabase==0.6.0
Given a waifu ID or name, return the waifu entry.
- Endpoint: https://charles-waifu-list.azurewebsites.net/api
- "id" and/or "name" required
BASE = "https://charles-waifu-list.azurewebsites.net/"
query = {
"name": "Lynn Wiles"
}
response = requests.get(BASE + "api", params=query)
print(response.json())
# {'id': 1, 'name': 'Lynn Wiles', 'anime': 'Pulse', 'rank': 1, 'description': 'My ideal girl', 'image': 'lynn_wiles.png', 'created_at': '2022-10-08T17:31:32.100908Z', 'updated_at': '2022-10-08T17:31:32.100908Z'}
Given all necessary fields, create a new waifu entry.
- Endpoint: https://charles-waifu-list.azurewebsites.net/api
- "name", "anime", "rank", "description", "image" required
BASE = "https://charles-waifu-list.azurewebsites.net/"
query = {
"name": "Makise Kurisu",
"anime": "Steins;Gate",
"rank": 2,
"description": "The assistant",
"image": "makise_kurisu.png"
}
response = requests.post(BASE + "api", json=query)
print(response.json())
# {'id': 2, 'name': 'Makise Kurisu', 'anime': 'Steins;Gate', 'rank': 2, 'description': 'The assistant', 'image': 'makise_kurisu.png', 'created_at': '2022-10-08T20:30:22.072971Z', 'updated_at': '2022-10-08T22:17:17.188822Z'}
Given a waifu ID or name, along with the fields to be changed, update the waifu entry.
- Endpoint: https://charles-waifu-list.azurewebsites.net/api
- "id" and/or "name" required
BASE = "https://charles-waifu-list.azurewebsites.net/"
query = {
"name": "Makise Kurisu",
"description": "Zombie girl"
}
response = requests.put(BASE + "api", json=query)
print(response.json())
# {'id': 2, 'name': 'Makise Kurisu', 'anime': 'Steins;Gate', 'rank': 2, 'description': 'Zombie girl', 'image': 'makise_kurisu.png', 'created_at': '2022-10-08T20:30:22.072971Z', 'updated_at': '2022-10-08T22:17:17.188822Z'}
Given a waifu ID or name, delete the waifu entry.
- Endpoint: https://charles-waifu-list.azurewebsites.net/api
- "id" and/or "name" required
BASE = "https://charles-waifu-list.azurewebsites.net/"
query = {
"name": "Makise Kurisu",
"description": "Zombie girl"
}
response = requests.delete(BASE + "api", json=query)
print(response.json())
# {'message': 'Waifu successfully deleted.'}
Returns all waifus in the database. No fields required.
BASE = "https://charles-waifu-list.azurewebsites.net/"
response = requests.get(BASE + "api/all", json=query)
print(response.json())
# [{'id': 1, 'name': 'Lynn Wiles', 'anime': 'Pulse', 'rank': 1, 'description': 'My ideal girl', 'image': 'lynn_wiles.png', 'created_at': '2022-10-08T17:31:32.100908Z', 'updated_at': '2022-10-08T17:31:32.100908Z'}, {'id': 2, 'name': 'Makise Kurisu', 'anime': 'Steins;Gate', 'rank': 2, 'description': 'Zombie girl', 'image': 'makise_kurisu.png', 'created_at': '2022-10-08T20:30:22.072971Z', 'updated_at': '2022-10-08T20:30:22.072971Z'}]
Deletes all waifus in the database. No fields required.
BASE = "https://charles-waifu-list.azurewebsites.net/"
response = requests.delete(BASE + "api/all", json=query)
print(response.json())
# {'message': 'All waifus successfully deleted.'}
I switched from using Flask to Django as I got the hang of REST APIs and back end development. I was absolutely blown away with how beautifully Django handles database integrations, caching, and authentication. Django, along with its beautiful integration with Supabase, form the foundation of the back end. Tables that would usually be stored in a local SQLite database are now directly integrated with Supabase, which includes Django's authentication, saved models, permissions, logs, etc.
I upgraded from a locally-hosted SQLite database to using a cloud-based PostgreSQL database provider, known as Supabase. I learned how to use Supabase during my summer internship at Content Turbine, and decided to use it as they allow for easy integration of migrations from Django.
Previously, I used Heroku to host all my projects, including my previous REST API. Then I switched to using AWS Elastic Beanstalk, until I realized that it doesn't provide the back end domain name with SSL certification. This was a problem, as all front end hosting services now require requests to be HTTPS, not HTTP. Finally, I switched to deploying on Microsoft Azure.
Once the front end is up and running, and an authentication page is available, I will add a check for authorized users in the endpoints. Supabase and Django make this super easy.
Django also has Redis integration, which I will look into in the future. This will help in case I get famous one day and lots of people check out my waifu list.
This project is licensed under the MIT License - see the LICENSE file for details.