Skip to content
~/bermudev/blog
Go back

Building a Dog Shelter API with Flask and Python

Table of contents

Open Table of contents

Project background

One of the first projects I did when I started in the world of backend development was an API for a dog shelter using Django REST Framework, it is one of my first projects and although I remember it fondly I have learned a lot since then.

So I thought, why not try doing something similar using another framework? This way I can take the opportunity to dive more into API development, learn about a different framework and revisit an old project that I’m so close to.

That’s how I came to the idea of redoing the project using Flask framework, as this framework was unknown to me until now.

Flask logo

Without further ado, I present the new Dog Shelter API in Flask:

What does the API do?

Here’s a short list explaining what this Flask, updated version of the API does:

Flask resources and technologies used

Some of the Flask tools used for the creation of this API are:

Database design

This is the final design of the project database, I have expanded the original idea and modified some fields with the suggestions of some dog-loving friends. It does not include the user part for login.

DB design

Endpoints

The API has the following endpoints for each table, those marked with πŸ”’ require valid authentication and DELETE methods need admin rights:

MethodEndpointDescription
GET/api/user/{id}Retrieve details of a specific user by ID
POST/api/register/Add a new user to the shelter database
POST/api/login/Login to the API using the username and password
POST πŸ”’/api/logout/Logout from the API
POST πŸ”’/api/refresh/Get a new token from the API
DELETE πŸ”’πŸ›‘οΈ/api/user/{id}Delete an user from the shelter database
MethodEndpointDescription
GET/api/dogs/Retrieve a list of all dogs available for adoption
GET/api/dogs/{id}Retrieve details of a specific dog by ID
POST πŸ”’/api/dogs/Add a new dog to the shelter database
PUT πŸ”’/api/dogs/{id}Update information for a specific dog by ID
DELETE πŸ”’πŸ›‘οΈ/api/dogs/{id}Remove a specific dog from the shelter database
MethodEndpointDescription
GET/api/adoptions/Retrieve a list of all adoption records
GET/api/adoptions/{id}Retrieve details of a specific adoption by ID
POST πŸ”’/api/adoptions/Add a new adoption record to the database
PUT πŸ”’/api/adoptions/{id}Update information for a specific adoption by ID
DELETE πŸ”’πŸ›‘οΈ/api/adoptions/{id}Remove a specific adoption record from the database
MethodEndpointDescription
GET/api/vaccinesRetrieve a list of all vaccines for a specific dog
GET/api/vaccines/{id}Retrieve details of a specific vaccine for a specific dog
POST πŸ”’/api/vaccinesAdd a new vaccine for a specific dog
PUT πŸ”’/api/vaccines/{id}Update information for a specific vaccine for a specific dog
DELETE πŸ”’πŸ›‘οΈ/api/vaccines/{id}Remove a specific vaccine for a specific dog
MethodEndpointDescription
GET/api/healthRetrieve health information for a specific dog
GET/api/health/{id}Retrieve details of a specific health issue for a specific dog
POST πŸ”’/api/healthAdd a new health issue for a specific dog
PUT πŸ”’/api/health/{id}Update information for a specific health issue for a specific dog
DELETE πŸ”’πŸ›‘οΈ/api/health/{id}Remove a specific health issue for a specific dog

Although it is not a big project nor has great complexity, it has helped me to put into practice the theoretical knowledge about Flask and to be able to grow more in other frameworks besides Django, which is still my preferred one.


Share this post on:

Previous Post
My Personal Setup for the Terminal
Next Post
Pandas for Data Analisys