API tutorial
Build a real coffee-shop API in your browser: design the contract, then make it documented, versioned, secure and fast, and learn when to use GraphQL or gRPC instead.
Course contents
REST Foundations
- Introduction to APIs — Learn what an API is, how a client and a server talk through requests and responses, and why every API is a contract. Break one and fix it in your browser.
- HTTP Basics — Read every line of a real HTTP request and response: the method, path, query string, headers and JSON body, and why a missing Content-Type breaks a request.
- HTTP Methods — Learn GET, POST, PUT, PATCH and DELETE, what safe and idempotent mean, and how an Idempotency-Key stops a retried payment from charging twice.
- REST API Design and URL Naming — Turn action-style endpoints into clean REST resource URLs, nest related resources, and add filtering, sorting and capped pagination with the query string.
- HTTP Status Codes and Error Handling — Make every reply tell the truth: choose the right status code, stop hiding errors inside 200 OK, and send errors as Problem Details (RFC 9457).
- Request Validation and DTOs — Stop bad data at the door: use request and response DTOs, block over-posting, validate every field, and return every error as a validation problem.
- Building a CRUD API — Build create, read, update and delete endpoints for the menu and orders, guard status changes with 409, and move logic into services.
- API Documentation with OpenAPI — Describe your API in an OpenAPI document, serve it from ASP.NET Core, and use it to list endpoints, lint the design, contract-test responses and generate clients.
Production-Ready APIs
- API Versioning — Change an API without breaking its clients: spot breaking changes, serve /v1 and /v2 side by side, and retire old versions with Deprecation and Sunset headers.
- API Authentication — Make the API ask who is calling: protect endpoints with API keys, read and validate JWT bearer tokens, and answer 401 with WWW-Authenticate.
- API Authorization and Security — Check on every request that the caller is allowed to do this: own the record, have the role, carry the scope.
- API Performance and Caching — Make your API fast by not repeating work: fix N+1 queries, answer repeat visits with 304, and tell caches what they may keep.
- Rate Limiting and Resilience — Protect your API from too much traffic with rate limits and 429 Too Many Requests, and make clients cope with slow or failing services using retries and backoff.
- API Monitoring and Logging — Use structured logs, correlation ids, health checks and RED metrics to see what your API is doing and find bugs fast.
- API Testing — Write automated unit and integration tests that check status, headers and body on every change, so a fixed bug never comes back.
- API Gateway — Put one front door in front of your services so auth, limits, routing and header rules happen once, in one place.
Beyond REST
- GraphQL — Let the client ask for exactly the fields it needs, in one request, with a GraphQL query.
- gRPC — Let services talk fast with small binary protobuf messages and a strict .proto contract.
- REST vs GraphQL vs gRPC — Start with REST, and pick GraphQL, gRPC, webhooks or Server-Sent Events only when you have a clear reason.
- Capstone Project: Loyalty Points API — Build a complete Loyalty Points API for Brew & Bytes: validated, retry-safe, authorized, versioned, documented and monitored.
Reference
- API Cheat Sheet — One page with the methods, URL rules, error shape, headers and side-by-side C# and Hono snippets you reach for every day.
- HTTP Status Codes and Headers — Every status code and header used in the course, with what it means, when to send it and a one-line C# and Hono example.
- API Error Reference — Real error messages you will meet while building APIs, what causes each one, how to fix it and which lesson explains it.
- API Glossary — Every term from the course, A to Z, each explained in one or two plain sentences.