FastAPI Python Tutorial: Build an Analytics API from Scratch
CodingEntrepreneurs
@codingentrepreneursAbout
Learn, Build, and Earn. Coding Entrepreneurs is here to help you learn the skills you need to build the projects you want. Learn by doing everything we do step-by-step. Practical and hands-on. Let's do this. đŊ Code: https://github.com/codingforentrepreneurs đ Enroll. Learn to code. Launch your project: https://cfe.sh/enroll đ
Video Description
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 - Course Code: https://github.com/codingforentrepreneurs/analytics-api - Sign up for Timescale with my link: https://tsdb.co/justin-api-1 - pip install timescaledb-python: https://github.com/jmitchel3/timescaledb-python - Railway Templates: fastapicontainer.com & jupytercontainer.com - FastAPI https://fastapi.tiangolo.com/ - SQLModel: sqlmodel.tiangolo.com/ đ 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
API Development Must-Haves
AI-recommended products based on this video

MT7601 USB Adapter USB Antenna, Computer Adapter USB Adapter with Integrated Antenna for Windows Desktop Laptop

TP-Link USB Bluetooth Adapter for PC, 4.0 Bluetooth Dongle Receiver (UB400) - Support Windows 11/10/8.1/8/7/XP for Desktop, Laptop, Mouse, Keyboard, Printers, Headsets, Speakers, PS4/ Xbox Controllers

10Gtek USB WiFi Adapter, for PC, AC600M USB WiFi Dongle 802.11ac Wireless Network Adapter with Dual Band 2.4GHz/5Ghz for Desktop Laptop Support Windows 10/8/7/XP, MAC OS, Linux etc

BrosTrend 1200Mbps USB WiFi Adapter for Windows 11/10/8/7/XP of PC Desktop Laptop, Dual Band 5GHz 867Mbps, 2.4GHz 300Mbps, USB 3.0, Network Card WLAN

KINGRACK 4 Step Ladder, Sturdy Steel Step Stool with Tool Platform, Safe-Lock, Handrail, Anti-Slip Wide Pedals, Pass 800lbs Load Testing, Folding Portable Ladder for Multi-Purpose, Home Kitchen, Black Global Recycled Standard

KINGRACK 4 Step Ladder, Sturdy Steel Step Stool with Tool Platform, Safe-Lock, Handrail, Anti-Slip Wide Pedals, Pass 800lbs Load Testing, Folding Portable Ladder for Multi-Purpose, Home Kitchen, Black Global Recycled Standard

Ketone Test Strips, 50pcs Urinalysis Keto Test Strip Accurate Urine Dip Stick Testing Ketosis Home Urinalysis Tester Kit for Testing Body Urine Ketosis Levels

18 in 1 Drinking Water Test Kit,125 Strips Water Chemical Testing for Home Tap and Well Water, Accurate Testing for Chlorine,Nitrate, Lead, Hardness, Fluoride, Iron, Copper, pH & More

AAwipes Aquarium Ammonia Test Strips 8-in-1 |100 Strips | Quick & Accurate Water Testing for Freshwater & Saltwater Tanks -Test pH, Carbonate, Alkalinity, Hardness, Chlorine, Nitrite, etc. (K02-100)



















