← Back to Projects
API-to-SQLite CLI Tool
Pull data from a public API on a schedule, store it in SQLite, and serve it through a small FastAPI app.
What you'll learn
- Calling REST APIs with
httpxorrequests - Designing a simple SQLite schema
- Building a CLI that does something useful on every run
- Exposing data through FastAPI endpoints
Architecture
CLI (Python)
→ fetch data from public API
→ clean / validate (Pydantic)
→ insert into SQLite
→ FastAPI reads SQLite and serves /endpoints
Steps
- Pick a public API (OpenWeatherMap, GitHub, a news API)
- Design your SQLite table — keep it minimal: id, timestamp, relevant fields, source
- Write a CLI using
clickorargparse:python fetch.py --source github --repo owner/name - On each run: fetch, validate with Pydantic, upsert into SQLite
- Build 2–3 FastAPI endpoints that query SQLite:
/latest,/history,/search?q= - Add basic error handling: API down → retry once, then log and exit
- Write a short README explaining what it does and how to run it