I followed the first 11 hours of the FreeCodeCamp API development tutorial to learn about building APIs with Python. This repository contains my work, which may differ slightly from the tutorial.
Some functions used in the tutorial no longer exist, so I adapted parts of the code while maintaining the original function signatures and outputs. If you're looking for alternative approaches or inspiration beyond the tutorial, you can explore my implementations here.
- Postman - API testing and development tool.
- PostgreSQL - Relational database management system.
- FastAPI - Web framework for building APIs with Python.
- SQLAlchemy - SQL toolkit and Object-Relational Mapping (ORM) library.
- Alembic - Lightweight database migration tool for use with SQLAlchemy.
- CRUD Operations - Implementation of Create, Read, Update, Delete operations.
Here’s the README content for running the project locally:
First, clone this repository using the following command:
git clone https://github.com/AffesRoua/Python-API-Development--updated-version---FreeCodeCamp.git
Move into the project directory:
cd Python-API-Development--updated-version---FreeCodeCamp
Install FastAPI using the [all]
flag:
pip install fastapi[all]
From the project directory, run the following command:
uvicorn main:app --reload
You can now access the API documentation through the following link:
To use this API, you will need a PostgreSQL database. After creating a database, create a .env
file in the project folder and add the following environment variables:
DATABASE_HOSTNAME = localhost
DATABASE_PORT = 5432
DATABASE_PASSWORD = your_database_password
DATABASE_NAME = your_database_name
DATABASE_USERNAME = your_database_username
SECRET_KEY = 09d25e094faa2556c818166b7a99f6f0f4c3b88e8d3e7 # Replace this with a secure key
ALGORITHM = HS256
ACCESS_TOKEN_EXPIRE_MINUTES = 60
Note: The
SECRET_KEY
provided above is a placeholder. You should generate a secure key for production use. Check the FastAPI documentation for guidance on generating aSECRET_KEY
.
This should help set up and run the FastAPI project locally with ease.