{"id":19329980,"url":"https://github.com/asynq-io/fastapi-views","last_synced_at":"2026-04-08T10:00:49.490Z","repository":{"id":248821256,"uuid":"829450488","full_name":"asynq-io/fastapi-views","owner":"asynq-io","description":"FastAPI Class Views and utilities","archived":false,"fork":false,"pushed_at":"2026-03-24T06:14:22.000Z","size":1019,"stargazers_count":23,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-28T21:26:37.329Z","etag":null,"topics":["api","asyncio","fastapi","python","rest"],"latest_commit_sha":null,"homepage":"https://asynq-io.github.io/fastapi-views/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/asynq-io.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-07-16T13:00:06.000Z","updated_at":"2026-03-20T08:34:35.000Z","dependencies_parsed_at":"2026-01-06T17:01:16.028Z","dependency_job_id":null,"html_url":"https://github.com/asynq-io/fastapi-views","commit_stats":null,"previous_names":["asynq-io/fastapi-views"],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/asynq-io/fastapi-views","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asynq-io%2Ffastapi-views","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asynq-io%2Ffastapi-views/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asynq-io%2Ffastapi-views/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asynq-io%2Ffastapi-views/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/asynq-io","download_url":"https://codeload.github.com/asynq-io/fastapi-views/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asynq-io%2Ffastapi-views/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31549900,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-07T16:28:08.000Z","status":"online","status_checked_at":"2026-04-08T02:00:06.127Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","asyncio","fastapi","python","rest"],"created_at":"2024-11-10T02:33:00.443Z","updated_at":"2026-04-08T10:00:49.473Z","avatar_url":"https://github.com/asynq-io.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fastapi-views\n\n![Tests](https://github.com/asynq-io/fastapi-views/workflows/Tests/badge.svg)\n![Build](https://github.com/asynq-io/fastapi-views/workflows/Publish/badge.svg)\n![License](https://img.shields.io/github/license/asynq-io/fastapi-views)\n![Mypy](https://img.shields.io/badge/mypy-checked-blue)\n[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v1.json)](https://github.com/charliermarsh/ruff)\n[![Pydantic v2](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/pydantic/pydantic/main/docs/badge/v2.json)](https://docs.pydantic.dev/latest/contributing/#badges)\n[![security: bandit](https://img.shields.io/badge/security-bandit-yellow.svg)](https://github.com/PyCQA/bandit)\n![Python](https://img.shields.io/pypi/pyversions/fastapi-views)\n![Format](https://img.shields.io/pypi/format/fastapi-views)\n![PyPi](https://img.shields.io/pypi/v/fastapi-views)\n\n**Class-based views, CRUD utilities, and production-ready patterns for FastAPI.**\n\nFastAPI Views brings Django REST Framework-style class-based views to FastAPI — without giving up type safety or dependency injection. Define a full CRUD resource by inheriting one class; routes, status codes, and OpenAPI docs are wired up automatically.\n\n## Features\n\n- **Class-based views** — `View`, `APIView`, `ViewSet`, and `GenericViewSet` at three levels of abstraction; mix-in only the actions you need\n- **Full CRUD in one class** — `list`, `create`, `retrieve`, `update`, `partial_update`, `destroy` with correct HTTP semantics out of the box (`201 Created`, `204 No Content`, `Location` header, etc.)\n- **Generic views with the repository pattern** — plug in any data source (SQLAlchemy, Motor, plain dicts) via a simple protocol; no ORM dependency\n- **DRF-style filters** — `ModelFilter`, `OrderingFilter`, `SearchFilter`, `PaginationFilter`, `TokenPaginationFilter`, `FieldsFilter`, and a combined `Filter` class; built-in SQLAlchemy and Python object resolvers\n- **RFC 9457 Problem Details** — every error response is machine-readable; built-in classes for the most common cases; custom errors auto-register in the OpenAPI spec\n- **Fast Pydantic v2 serialization** — `TypeAdapter` cached per schema type avoids the double validation/model instantiation that FastAPI does by default, reducing per-request overhead\n- **Server-Sent Events** — `ServerSideEventsAPIView` and `@sse_route` handle framing, content-type, and Pydantic validation automatically\n- **Async and sync support** — every class ships an `Async` and a synchronous variant; sync endpoints run in a thread pool\n- **One-call setup** — `configure_app(app)` registers error handlers, Prometheus middleware, and OpenTelemetry instrumentation\n- **Prometheus metrics** — `/metrics` endpoint with request count, latency histogram, and in-flight requests (optional extra)\n- **OpenTelemetry tracing** — `correlation_id` injected into every error response for easy trace correlation (optional extra)\n- **Readable OpenAPI operation IDs** — `list_item`, `create_item`, `retrieve_item` instead of FastAPI's long path-derived defaults\n- **CLI** — export a static `openapi.json` / `openapi.yaml` without starting a server\n\n---\nDocumentation: https://asynq-io.github.io/fastapi-views/\n\nRepository: https://github.com/asynq-io/fastapi-views\n\n---\n\n## Installation\n\n```shell\npip install fastapi-views\n```\n\n## Optional dependencies\nAvaliable extensions: `uvloop`, `prometheus`, `uvicorn`, `opentelemetry`, `cli`\n\n```shell\npip install 'fastapi-views[all]'\n```\n\n## Quick start\n\n```python\nfrom typing import ClassVar, Optional\nfrom uuid import UUID\n\nfrom fastapi import FastAPI\nfrom pydantic import BaseModel\n\nfrom fastapi_views import ViewRouter, configure_app\nfrom fastapi_views.views.viewsets import AsyncAPIViewSet\n\n\nclass ItemSchema(BaseModel):\n    id: UUID\n    name: str\n    price: int\n\n\nclass ItemViewSet(AsyncAPIViewSet):\n    api_component_name = \"Item\"\n    response_schema = ItemSchema\n\n    # In-memory store — swap for a real repository in production\n    items: ClassVar[dict[UUID, ItemSchema]] = {}\n\n    async def list(self) -\u003e list[ItemSchema]:\n        return list(self.items.values())\n\n    async def create(self, item: ItemSchema) -\u003e ItemSchema:\n        self.items[item.id] = item\n        return item\n\n    async def retrieve(self, id: UUID) -\u003e Optional[ItemSchema]:\n        return self.items.get(id)\n\n    async def update(self, id: UUID, item: ItemSchema) -\u003e ItemSchema:\n        self.items[id] = item\n        return item\n\n    async def destroy(self, id: UUID) -\u003e None:\n        self.items.pop(id, None)\n\n\nrouter = ViewRouter(prefix=\"/items\")\nrouter.register_view(ItemViewSet)\n\napp = FastAPI(title=\"My API\")\napp.include_router(router)\n\nconfigure_app(app)\n```\n\nThis registers the following routes automatically:\n\n| Method | Path | Action | Status code |\n|--------|------|--------|-------------|\n| `GET` | `/items` | `list` | 200 |\n| `POST` | `/items` | `create` | 201 |\n| `GET` | `/items/{id}` | `retrieve` | 200 |\n| `PUT` | `/items/{id}` | `update` | 200 |\n| `DELETE` | `/items/{id}` | `destroy` | 204 |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasynq-io%2Ffastapi-views","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasynq-io%2Ffastapi-views","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasynq-io%2Ffastapi-views/lists"}