Self-paced

Explore our extensive collection of courses designed to help you master various subjects and skills. Whether you're a beginner or an advanced learner, there's something here for everyone.

Bootcamp

Learn live

Join us for our free workshops, webinars, and other events to learn more about our programs and get started on your journey to becoming a developer.

Upcoming live events

Learning library

For all the self-taught geeks out there, here is our content library with most of the learning materials we have produced throughout the years.

It makes sense to start learning by reading and watching videos about fundamentals and how things work.

Search from all Lessons


Login

Start interactive tutorial

← Back to Projects

Build a StarWars REST API

Difficulty

  • easy

Average duration

8 hrs

Technologies

  • REST

  • Python

    Node

    Flask

Difficulty

  • easy

Average duration

8 hrs

Technologies

🌱 How to start this project

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:

1🐍 For Python/FastAPI: 2https://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.

Sign up and get access to solution files and videos for free

We will use it to give you access to your account.
Already have an account? Login here.

By signing up, you agree to the Terms and conditions and Privacy policy.

Difficulty

  • easy

Average duration

8 hrs

Technologies

Difficulty

  • easy

Average duration

8 hrs

Technologies

Difficulty

  • easy

Average duration

8 hrs

Technologies

Difficulty

  • easy

Average duration

8 hrs

Technologies

Sign up and get access to solution files and videos for free

We will use it to give you access to your account.
Already have an account? Login here.

By signing up, you agree to the Terms and conditions and Privacy policy.

Difficulty

  • easy

Average duration

8 hrs

Technologies

Difficulty

  • easy

Average duration

8 hrs

Technologies