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


LoginGet Started

Register to 4Geeks

← 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 (about StarWars). Users on this blog will be able to list planets, list characters, and create or remove favorites.

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

  1. Start by modeling the database: Create a database and the tables needed to store that information. You may have already done this when you did the StarWars Data Modeling project in python/flask or node/express.
  2. Build your endpoints using Flask or Express (depending on your cohort's main language).
  3. Constantly test your endpoints with Postman.

🌱 How to start this project

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

We recommend opening the flask template or the express.js template using a provisioning tool like Codespaces (recommended) or Gitpod. Alternatively, you can clone it on your local computer using the git clone command.

These are the repositories you need to open or clone:

1🐍 For Python/Flask: 2https://github.com/4GeeksAcademy/flask-rest-hello 3 4πŸ‘©πŸ½β€πŸ’» For Node/Express.js: 5https://github.com/4GeeksAcademy/expressjs-rest-hello

⚠ You will need to have a database installed and Node.js or Python 3.7+ installed if you do it locally, but all of that is already installed on Codespaces or Gitpod.

The boilerplate's README files have a video on how to start and complete your API.

🐍 For Python: There is an interactive tutorial on how to build a Flask API, it's a similar process, but instead of tasks, here you will be dealing with people and planets.

πŸ‘‰ 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 <your new url>), and uploading the code to your new repository using the add, commit and push commands from the git terminal.

πŸ“ Instructions

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

  • [GET] /people Get a list of all the people in the database.
  • [GET] /people/<int:people_id> Get one single person's information.
  • [GET] /planets Get a list of all the planets in the database.
  • [GET] /planets/<int:planet_id> Get one single planet's information.

Additionally, create the following endpoints to allow your StarWars blog to have users and favorites:

  • [GET] /users Get a list of all the blog post users.
  • [GET] /users/favorites Get all the favorites that belong to the current user.
  • [POST] /favorite/planet/<int:planet_id> Add a new favorite planet to the current user with the planet id = planet_id.
  • [POST] /favorite/people/<int:people_id> Add new favorite people to the current user with the people id = people_id.
  • [DELETE] /favorite/planet/<int:planet_id> Delete a favorite planet with the id = planet_id.
  • [DELETE] /favorite/people/<int:people_id> Delete a favorite people with the id = people_id.
  • Your current API does not have an authentication system (yet), which is why the only way to create users is directly on the database using the Flask admin.

Note: here is a sample API in Postman: https://documenter.getpostman.com/view/2432393/TzRSgnTS#a4174b48-3fc8-46e3-bf82-19a08107666f

πŸ“– Fundamentals

This exercise will make you practice the following fundamentals:

  1. Building an RESTful API using one of the most popular libraries, Python Flask or Express.js.
  2. Building a database with the ORM called SQLAlchemy or TypeORM
  3. Database Migrations using the migration system Alembic or the native migration system from TypeORM.

😎 Feeling confident?

The following requirements are not necessary to successfully complete this project, but you would like to try coding them if you feel like challenging yourself ☺️

+4 Create also endpoints to add (POST), update (PUT), and delete (DELETE) planets and people. That way all the database information can be managed using the API instead of having to rely on the Flask admin to create the planets and people.

This and many other projects are built by students as part of the 4Geeks Academy Coding Bootcamp by Alejandro Sanchez and many other contributors. Find out more about our Full Stack Developer Course, and Data Science Bootcamp.

Signup and get access to similar projects

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

Signup and get access to similar projects

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