FastAPI & REST APIs
Build production-grade REST APIs with FastAPI and Python. HTTP fundamentals, CRUD, database integration, API design best practices, and full pytest test coverage.
What you'll learn
FastAPI & REST APIs is organized into 7 focused modules. By the end you'll be comfortable with:
- HTTP Fundamentals
- FastAPI Basics
- CRUD Operations
- Database Integration
- Advanced FastAPI
- API Design Best Practices
- API Testing with pytest
Course curriculum
33 lessons across 7 modules. Lessons marked Free preview are readable without an account.
Module 1. HTTP Fundamentals
Understand the request-response cycle, HTTP methods, status codes, and JSON — the building blocks of every web API.
- 10mThe Request-Response CycleFree preview
Understand how every HTTP API conversation works — from client to server and back.
- 10mHTTP MethodsFree preview
Learn how GET, POST, PUT, PATCH, and DELETE map to CRUD operations on your API resources.
- 10mStatus Codes and Headers
Master the most important HTTP status codes and headers your API will use daily.
- 10mJSON and Query Parameters
Work with JSON request bodies and query parameters — the two ways clients send data to your API.
- 8mREST Principles
Understand the REST constraints that make APIs predictable, scalable, and universally understandable.
Module 2. FastAPI Basics
Build your first FastAPI application with path operations, Pydantic models, and automatic docs.
- 10mYour First FastAPI App
Install FastAPI, write your first route, and run a live API in minutes.
- 12mPydantic Request and Response Models
Use Pydantic models to validate request bodies and shape API responses automatically.
- 12mQuery Parameters and Dependency Injection
Declare query parameters with type hints and use FastAPI's dependency injection for reusable logic.
- 10mError Handling with HTTPException
Return meaningful error responses using HTTPException and custom exception handlers.
- 8mOpenAPI and Automatic Documentation
Understand how FastAPI generates OpenAPI specs and use the Swagger UI to test your API.
Module 3. CRUD Operations
Build complete Create, Read, Update, Delete operations with proper status codes and error handling.
- 12mGET: List and Item Endpoints
Build GET endpoints that return paginated collections and individual resources by ID.
- 12mPOST: Creating Resources
Build POST endpoints that validate input, create resources, and return the correct 201 status.
- 12mPUT and PATCH: Updating Resources
Implement full replacement (PUT) and partial update (PATCH) with proper validation.
- 10mDELETE and Response Patterns
Implement DELETE endpoints and establish consistent response patterns across your API.
- 8mIn-Memory Store Patterns
Use in-memory dicts to prototype your API before connecting a real database.
Module 4. Database Integration
Connect FastAPI to PostgreSQL using SQLAlchemy — replace the in-memory store with a real database.
- 12mSQLAlchemy Session Setup
Configure SQLAlchemy to connect FastAPI to PostgreSQL with a proper session dependency.
- 12mCRUD with SQLAlchemy
Replace in-memory dict operations with real SQLAlchemy database queries.
- 10mDatabase Error Handling
Handle common database errors — unique constraints, not-found, and connection issues — gracefully.
- 12mSQLAlchemy Relationships
Define one-to-many and many-to-many relationships between models and query across them.
- 10mA Complete FastAPI + DB Route
Put it all together — a production-ready FastAPI route connected to PostgreSQL.
Module 5. Advanced FastAPI
Background tasks, middleware, file uploads, pagination, and production project structure.
- 10mBackground Tasks and Middleware
Run tasks after the response (emails, notifications) and add cross-cutting logic with middleware.
- 10mFile Uploads and Pagination
Handle file uploads with UploadFile and implement cursor-based or offset pagination.
- 8mProduction Project Structure
Organise a FastAPI project with routers, CRUD layers, and configuration for production deployment.
- 8mRate Limiting and Performance Tips
Protect your API from abuse with rate limiting and improve performance with async endpoints.
Module 6. API Design Best Practices
Design APIs that are intuitive, versioned, documented, and consistent — the skills that separate junior from senior engineers.
- 10mNaming Conventions and Versioning
Apply consistent REST naming conventions and version your API for long-term compatibility.
- 10mAPI Documentation Standards
Write self-documenting APIs with rich OpenAPI specs that frontend teams and third-party developers love.
- 10mFiltering, Sorting, and Searching
Design query parameters for filtering, sorting, and full-text search in list endpoints.
- 8mAPI Design Review and Checklist
Review an API design with a professional checklist — catch problems before they reach production.
Module 7. API Testing with pytest
Write comprehensive API tests using FastAPI's TestClient, pytest fixtures, and test database patterns.
- 12mFastAPI TestClient
Use FastAPI's built-in TestClient to write HTTP-level tests without a running server.
- 12mTest Database Fixtures
Set up an isolated test database that's created fresh for each test and torn down after.
- 10mTesting Complete CRUD Flows
Write end-to-end tests that cover create, read, update, and delete flows with data assertions.
- 10mFixtures and Parametrize
Use pytest fixtures for test setup and parametrize to test many cases without code duplication.
- 10mTest Coverage and Running in CI
Measure test coverage with pytest-cov and run your test suite automatically in GitHub Actions CI.
Frequently asked questions
- Is the FastAPI & REST APIs course free?
- You can preview lessons for free with no account. Full access to this Pro course is included with a Kodion Pro subscription.
- Do I need prior programming experience?
- This is a intermediate course, so you'll get the most from it if you're already comfortable with the basics of programming.
- How long does FastAPI & REST APIs take to complete?
- It's 33 lessons across 7 modules, roughly 6 hours of hands-on learning. You can go entirely at your own pace.
- What will I learn?
- You'll work through HTTP Fundamentals, FastAPI Basics, CRUD Operations, and more, building real, applied skills through interactive lessons and coding challenges.
- Can I get help if I'm stuck?
- Yes. Kodion's built-in AI tutor gives instant, context-aware hints and explanations right inside each lesson as you code.
Ready to start FastAPI & REST APIs?
Create a free account to track progress, earn XP, and get instant help from the AI tutor as you code.
Create your free account