Skip to main content
Python & FastAPI Interviews Coding P0 Medium

Build a keyset-paginated FastAPI endpoint with Depends

Design GET /items with cursor pagination, Pydantic response model, dependency-injected DB session, and 404/422 handling.

Official Reference

Model Answer & Explanation

Validate query params (limit: int = Query(20, ge=1, le=100), cursor: str | None = None), fetch limit + 1 rows ordered by (created_at DESC, id DESC) to detect has_more without a separate COUNT(*), encode the last row’s (created_at, id) into an opaque base64 cursor, and return {items, next_cursor}.

Follow-up Interview Question · How do you encode and validate an opaque cursor so clients can’t inject raw SQL or invalid types?

Module Context & References

Python & FastAPI · Practice questions & drills High-frequency coding, FastAPI, concurrency and testing exercises
Personal Notes · Markdown

Technologies & Interview Topics Covered

Switch between short-term interview tracks and long-term 80/20 engineering depth to practice JavaScript internals, React rendering and hooks, timed frontend machine coding UI challenges, MeetaPro FG300, Blind 75 & NeetCode 150 DSA patterns, Python & FastAPI APIs, PostgreSQL query optimization & MVCC, Redis caching, Applied AI RAG pipelines & evaluations, and distributed system design.