This repo contains various examples for fast Api
Implement basic Create, Read, Update, Delete (CRUD) operations for a simple resource like Item or User.
Create endpoints that combine path and query parameters, e.g., /search/items?name=book&price=20
.
Accept structured JSON data using Pydantic models, such as creating a product with fields like name, price, and category.
Add custom validation logic in your Pydantic models, such as ensuring a string has a minimum length or a number is within a range.
Use FastAPI’s dependency injection system to share reusable logic, such as database connections or authentication tokens.
Work with nested data models. For example, an Order might have a list of Items.
Define response models to control the structure of your API responses.
Create custom exception classes and handlers to return user-friendly error messages.
Implement JWT-based authentication, allowing users to log in and access protected routes.
Add background processing using FastAPI’s BackgroundTasks, e.g., sending an email after user registration.
Create an endpoint to handle file uploads, such as uploading a profile picture.
Build a WebSocket endpoint for real-time communication, such as a chat application.
Implement rate limiting for your API to prevent abuse, e.g., limit requests to 10 per minute.
Connect to a relational database (e.g., PostgreSQL, SQLite) using SQLAlchemy or Tortoise ORM. Build a resource like BlogPost with persistent storage.
Add pagination and filtering to a list endpoint, e.g., fetching 10 users per page or filtering by username.
Testing
: Write unit tests and integration tests for your endpoints using pytest.
OAuth2 Login
: Allow users to authenticate via third-party services like Google or GitHub.
API Versioning
: Implement API versioning (e.g., /v1/resource and /v2/resource).
Caching
: Use caching mechanisms to improve performance, such as Redis.
Async Tasks
: Integrate Celery or FastAPI’s async capabilities for heavy background jobs.