{"id":16105093,"url":"https://github.com/uriyyo/fastapi-filters","last_synced_at":"2025-03-16T08:32:32.960Z","repository":{"id":65269555,"uuid":"587759334","full_name":"uriyyo/fastapi-filters","owner":"uriyyo","description":"FastAPI filters🍸","archived":false,"fork":false,"pushed_at":"2024-04-12T04:02:54.000Z","size":1440,"stargazers_count":46,"open_issues_count":3,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-12T12:01:48.118Z","etag":null,"topics":["fastapi","fastapi-filters","fastapi-sqlalchemy","filters"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/uriyyo.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}},"created_at":"2023-01-11T14:19:40.000Z","updated_at":"2024-04-15T05:39:41.241Z","dependencies_parsed_at":"2024-01-03T04:46:42.602Z","dependency_job_id":"af3648af-ce6f-4dd0-8b36-f0007011aee9","html_url":"https://github.com/uriyyo/fastapi-filters","commit_stats":{"total_commits":57,"total_committers":2,"mean_commits":28.5,"dds":"0.45614035087719296","last_synced_commit":"2e6260a20c3459c2a253b41c2b545f24fe892e85"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uriyyo%2Ffastapi-filters","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uriyyo%2Ffastapi-filters/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uriyyo%2Ffastapi-filters/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uriyyo%2Ffastapi-filters/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/uriyyo","download_url":"https://codeload.github.com/uriyyo/fastapi-filters/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243806071,"owners_count":20350775,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["fastapi","fastapi-filters","fastapi-sqlalchemy","filters"],"created_at":"2024-10-09T19:08:23.133Z","updated_at":"2025-03-16T08:32:32.638Z","avatar_url":"https://github.com/uriyyo.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n\u003cimg alt=\"logo\" src=\"https://raw.githubusercontent.com/uriyyo/fastapi-filters/main/logo.png\"\u003e\n\u003c/h1\u003e\n\n\u003cdiv align=\"center\"\u003e\n\u003cimg alt=\"license\" src=\"https://img.shields.io/badge/License-MIT-lightgrey\"\u003e\n\u003cimg alt=\"test\" src=\"https://github.com/uriyyo/fastapi-filters/workflows/Test/badge.svg\"\u003e\n\u003cimg alt=\"codecov\" src=\"https://codecov.io/gh/uriyyo/fastapi-filters/branch/main/graph/badge.svg?token=QqIqDQ7FZi\"\u003e\n\u003ca href=\"https://pepy.tech/project/fastapi-filters\"\u003e\u003cimg alt=\"downloads\" src=\"https://pepy.tech/badge/fastapi-filters\"\u003e\u003c/a\u003e\n\u003ca href=\"https://pypi.org/project/fastapi-filters\"\u003e\u003cimg alt=\"pypi\" src=\"https://img.shields.io/pypi/v/fastapi-filters\"\u003e\u003c/a\u003e\n\u003cimg alt=\"black\" src=\"https://img.shields.io/badge/code%20style-black-000000.svg\"\u003e\n\u003c/div\u003e\n\n## Introduction\n\n`fastapi-filters` is a library that provides filtering/sorting feature for [FastAPI](https://fastapi.tiangolo.com/)\napplications.\n\n----\n\n## Installation\n\n```bash\npip install fastapi-filters\n```\n\n## Quickstart\n\nTo create filters you need either define them manually using `create_filters` function or automatically generate them\nbased on model using `create_filters_from_model` function.\n\n```py\nfrom typing import List\n\nfrom fastapi import FastAPI, Depends\nfrom pydantic import BaseModel, Field\n\n# import all you need from fastapi-filters\nfrom fastapi_filters import create_filters, create_filters_from_model, FilterValues\n\napp = FastAPI()  # create FastAPI app\n\n\nclass UserOut(BaseModel):  # define your model\n    name: str = Field(..., example=\"Steve\")\n    surname: str = Field(..., example=\"Rogers\")\n    age: int = Field(..., example=102)\n\n\n@app.get(\"/users\")\nasync def get_users_manual_filters(\n    # manually define filters\n    filters: FilterValues = Depends(create_filters(name=str, surname=str, age=int)),\n) -\u003e List[UserOut]:\n    pass\n\n\n@app.get(\"/users\")\nasync def get_users_auto_filters(\n    # or automatically generate filters from pydantic model\n    filters: FilterValues = Depends(create_filters_from_model(UserOut)),\n) -\u003e List[UserOut]:\n    pass\n```\n\nCurrently, `fastapi-filters` supports `SQLAlchemy` integration.\n\n```py\nfrom fastapi_filters.ext.sqlalchemy import apply_filters\n\n\n@app.get(\"/users\")\nasync def get_users(\n    db: AsyncSession = Depends(get_db),\n    filters: FilterValues = Depends(create_filters_from_model(UserOut)),\n) -\u003e List[UserOut]:\n    query = apply_filters(select(UserOut), filters)\n    return (await db.scalars(query)).all()\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Furiyyo%2Ffastapi-filters","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Furiyyo%2Ffastapi-filters","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Furiyyo%2Ffastapi-filters/lists"}