FastAPI Python Tutorial: Build an Analytics API from Scratch

preview_player
Показать описание
FastAPI Python Tutorial: Build an Analytics API from Scratch

Own your own data pipeline and built an Analytics API from scratch in this tutorial. We'll go step-by-step building a production-ready API microservice so you can harness time-series data to analyze traffic of any web application.

🕹️ Key Tech:
- Python
- FastAPI
- SQLModel + SQLAlchemy
- TimescaleDB
- Docker

🔗 Links & References

👉 Topics Covered:
✅ Development Environment Setup - Install Python 3, create virtual environments, and set up your workspace properly. All from scratch.
✅ FastAPI Fundamentals - Build your first API endpoints in minutes with Python basics.
✅ Containers with Docker & Docker Compose - Create optimized containers for both development and production environments
✅ Data Schemas with Pydantic - ensure valid incoming and outgoing data using the powerful Pydantic for serialization and validation.
✅ Use SQLModel to connect FastAPI to PostgreSQL with type-safe database operations based on Pydantic and SQLAlchemy.
✅ Time Series Optimization - Transform regular postgres tables into Timescale hypertables for efficient time-based queries and support massive data ingestion.
✅ Advanced Data Aggregation - Implement time bucket queries that analyze patterns across different time intervals
✅ Production Deployment - Deploy your API to Railway in minutes with public and private connections
✅ TimescaleDB Cloud Integration - Connect to managed database services optimized for time series workloads and saving time and headache managing production databases
✅ Secure your API and data with private networking
✅ And more

Chapters
00:00:00 Welcome
00:03:21 Demo
00:06:45 Tools
00:10:31 Setup Development Environment
00:12:15 Download & Install Python 3
00:15:40 Create a Python Virtual Environment
00:20:24 Install Python Packages
00:27:53 FastAPI Hello World
00:33:42 Docker Desktop & Docker Compose
00:44:04 Production Dockerfile for FastAPI
00:52:47 Build & Run FastAPI Container
00:57:54 Development Mode with Docker Compose
01:11:36 Section Wrap Up
01:14:27 Routing & Data Validation
01:16:51 Our First API Endpoint
01:21:11 FastAPI Routing Module
01:26:03 Verify API Endpoint
01:29:21 Basic Data Types
01:37:10 List Data Types
01:41:41 POST Method to Send our API Data
01:51:47 Incoming Data Validation with Pydantic Schemas
01:57:56 Optional Values with Pydantic
02:04:30 Section Wrap Up
02:06:13 Storing Data with SQLModel
02:07:48 Postgres or TimescaleDB with Docker Compose
02:16:39 Load Environment Variables with Python
02:24:07 Pydantic to SQLModel
02:26:35 First SQL Table with SQLModel
02:33:50 Create Database Tables with FastAPI Lifespan
02:40:44 Database Connection Issues
02:45:59 Store Data using SQLModel Sessions
02:51:48 SQLModel Query for List View
02:57:01 Detail Lookup via SQLModel
03:01:50 Update Data with SQLModel
03:05:30 Adding a Datetime Field
03:10:39 Updated At Timestamp Field
03:14:12 Section Wrap Up
03:15:30 Time Series Data in Postgres
03:17:33 SQLModel to TimescaleModel
03:22:04 Creating Hypertables
03:25:33 Chunks & Retention in Hypertables
03:30:56 Verify Hypertables with PopSQL
03:36:34 SQLModel Queries in Notebooks
03:42:06 Aggregate Data with Time Buckets
03:52:46 Time Bucket Aggregations with FastAPI & Timescale
04:01:08 Web Traffic Data and More Aggregations
04:12:43 Section Wrap Up
04:14:02 Deploy
04:15:04 Add CORS to FastAPI
04:17:17 Fork the Analytics FastAPI Project
04:20:34 First Deploy on Railway
04:22:35 Provision Database on Timescale Cloud & Deploy
04:28:35 Test Data to Production Endpoint
04:30:17 Analytics API with Private Networking
04:41:41 Section Wrap Up
04:43:14 Thank you
Рекомендации по теме
Комментарии
Автор

Thanks for watching! Code & Chapters linked 👇

Chapters:
00:00:00 Welcome
00:03:21 Demo
00:06:45 Tools
00:10:31 Setup Development Environment
00:12:15 Download & Install Python 3
00:15:40 Create a Python Virtual Environment
00:20:24 Install Python Packages
00:27:53 FastAPI Hello World
00:33:42 Docker Desktop & Docker Compose
00:44:04 Production Dockerfile for FastAPI
00:52:47 Build & Run FastAPI Container
00:57:54 Development Mode with Docker Compose
01:11:36 Section Wrap Up
01:14:27 Routing & Data Validation
01:16:51 Our First API Endpoint
01:21:11 FastAPI Routing Module
01:26:03 Verify API Endpoint
01:29:21 Basic Data Types
01:37:10 List Data Types
01:41:41 POST Method to Send our API Data
01:51:47 Incoming Data Validation with Pydantic Schemas
01:57:56 Optional Values with Pydantic
02:04:30 Section Wrap Up
02:06:13 Storing Data with SQLModel
02:07:48 Postgres or TimescaleDB with Docker Compose
02:16:39 Load Environment Variables with Python
02:24:07 Pydantic to SQLModel
02:26:35 First SQL Table with SQLModel
02:33:50 Create Database Tables with FastAPI Lifespan
02:40:44 Database Connection Issues
02:45:59 Store Data using SQLModel Sessions
02:51:48 SQLModel Query for List View
02:57:01 Detail Lookup via SQLModel
03:01:50 Update Data with SQLModel
03:05:30 Adding a Datetime Field
03:10:39 Updated At Timestamp Field
03:14:12 Section Wrap Up
03:15:30 Time Series Data in Postgres
03:17:33 SQLModel to TimescaleModel
03:22:04 Creating Hypertables
03:25:33 Chunks & Retention in Hypertables
03:30:56 Verify Hypertables with PopSQL
03:36:34 SQLModel Queries in Notebooks
03:42:06 Aggregate Data with Time Buckets
03:52:46 Time Bucket Aggregations with FastAPI & Timescale
04:01:08 Web Traffic Data and More Aggregations
04:12:43 Section Wrap Up
04:14:02 Deploy
04:15:04 Add CORS to FastAPI
04:17:17 Fork the Analytics FastAPI Project
04:20:34 First Deploy on Railway
04:22:35 Provision Database on Timescale Cloud & Deploy
04:28:35 Test Data to Production Endpoint
04:30:17 Analytics API with Private Networking
04:41:41 Section Wrap Up
04:43:14 Thank you

CodingEntrepreneurs
Автор

I know these type of videos don't get the views they deserve and barely any monetary benefit but a big thank you for helping the community

MetrucTon
Автор

My english is not perfect, but Brother, your pronunciation is PERFECLY CLEAR for me. Thanks Bro. You doing GREAT job.

habib_sultan
Автор

The part of the video is when he introduces to docker just after setting up the FastAPI. I've seen many videos where people introduce it ate the end of the project. this is very kind of standard video. The hat's of to you

rohitrathod
Автор

You're still one of the best online teachers in the field of software development, Justin. I've been following you for 8 years now.

youneshenni
Автор

Woow 4 hours of tutorial, respect! thanks man!

nksyakirin
Автор

Wow, I finished the first 1:14 hrs, very informative, and educational at the same time, thank you. I'm looking forward to finish this tutorial

AndreAndraos
Автор

Excellent job, Justin!
Very helpful and informative for me! 🔥

romangaranin
Автор

❤❤ Justin, you are truly a legend! 🙌 The way you break down complex topics like FastAPI and Docker into easy-to-follow, hands-on tutorials is simply amazing. This kind of high-quality, free content is a game-changer for aspiring developers worldwide. Huge respect for your dedication and generosity in sharing your knowledge! 🚀🔥

nikhilsoni
Автор

That's an ultimate fast API tutorial. Thanks for making this. Love your tutorials

muhammadadilnaeem
Автор

Get this man the best play button that exists !!! ❤🎉😊

gaganchaudhary
Автор

Man, what beautiful content! Thanks for your dedication and excellent way of teaching!

francosbenitez
Автор

Thank you very much for this masterpiece. This is a game changer

abrahamngetich
Автор

🔥🔥🔥 Will be back once I am done with this, thanks

geoffreyngugi
Автор

Thank you for the really detailed tutorial. Appreciate it!

gustavojuantorena
Автор

Thank you so much! I was really looking for this 🙂

shivthedev
Автор

I just love railway makes it so easy to deploy applications

JacobSean-iytl
Автор

Thank you for posting this. Really really helpful tutorial.

nileshgarg
Автор

Thanks for the tutorial! I already know Django. I finally completed the FastAPI tutorial as well, which took 2 days to finish. I watched this video and implemented it on my own too. I’m thinking of deploying it on a VPS Linux server, which is another thing I need to learn. Could you create a tutorial on how to deploy it on a VPS Linux server using Docker?

nextgodlevel
Автор

Disclaimer - FastAPI and Docker parts yes, how he's dealing with data is not what you'll ever see. And if you see it done like in this video then run as fast as you can from that company.

Mahj
visit shbcf.ru