Skip to content

breatheco-de/exercise-starwars-blog-fast-api

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

87 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

StarWars Blog API

It is recommended to develop this project together with the StarWars Blog Reading List, eventually that front-end will integrate with the API you are going to develop in this project and you will have a fully functional application with front-end and back-end.

Today we are going to build an API to manage a blog (The StarWars Blog), users of this blog will be able to list planets, characters, and add or remove favorites.

To allow users to do all this, we must follow these steps:

  1. Start by modeling the database: create a database and the necessary tables to store that information, you may have already done this in the StarWars DataModeling project in python/fastapi.
  2. Create your endpoints using fastAPI.
  3. Constantly test your endpoints with Postman.

🌱 How to start this project

Do not clone this repository because we are going to use a different template.

We recommend opening the fastAPI template using a development environment like Codespaces (recommended) or Gitpod. Alternatively, you can clone it on your local computer using the git clone command.

This is the repository you need to open or clone:

🐍 For Python/FastAPI:
https://github.com/4GeeksAcademy/fastapi-hello

⚠ If you work locally you must have a database and Python 3.7+ but if you use Codespaces or Gitpod everything is already installed.

The boilerplate has a README file with instructions on how to build an API. You can do this interactive tutorial first on how to build APIs with FastAPI.

👉 Please follow these steps on how to start a coding project.

💡 Important: Remember to save and upload your code to GitHub by creating a new repository, updating the remote (git remote set-url origin ) and uploading the code to your new repository using the add, commit and push commands from the git terminal.

📝 Instructions

Create an API connected to a database and implement the following endpoints (very similar to SWAPI.dev or SWAPI.tech):

  • [GET] /people List all people records in the database.
  • [GET] /people/{people_id} Show the information of a single character by its id.
  • [GET] /planets List all planet records in the database.
  • [GET] /planets/{planet_id} Show the information of a single planet by its id.

Additionally, we need to create the following endpoints so that we can have users and favorites in our blog:

  • [GET] /users List all blog users.
  • [GET] /users/favorites List all favorites that belong to the current user.
  • [POST] /favorite/planet/{planet_id} Add a new favorite planet to the current user with id = planet_id.
  • [POST] /favorite/people/{people_id} Add a new favorite character to the current user with id = people_id.
  • [DELETE] /favorite/planet/{planet_id} Remove a favorite planet with id = planet_id.
  • [DELETE] /favorite/people/{people_id} Remove a favorite character with id = people_id.
  • Your current API does not have an authentication system (yet), so the only way to create users is directly in the database.

Note: Here is an example in Postman: https://documenter.getpostman.com/view/2432393/TzRSgnTS#a4174b48-3fc8-46e3-bf82-19a08107666f

📖 Fundamentals

This exercise will allow you to practice the following skills and concepts:

  1. Building APIs using the REST standard (a.k.a: RESTful APIs).
  2. Building a database using the ORM called SQLAlchemy.
  3. Using and understanding database migration systems with Alembic.

😎 Feeling confident?

The following requirements are not necessary to successfully complete the project, but you can develop them to continue your learning if you feel confident enough.

+4 Create endpoints to add (POST), modify (PUT) and delete (DELETE) planets and people. This way, the entire database can be managed via API.

This and other projects are used to learn to code by students of 4Geeks Academy Coding Bootcamp conducted by Alejandro Sánchez and many other contributors. Learn more about our Programming Courses to become a Full Stack Developer, or our Data Science Bootcamp.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published