{"id":18439175,"url":"https://github.com/wsh032/fastapi-proxy-lib","last_synced_at":"2025-04-06T22:06:26.191Z","repository":{"id":207044869,"uuid":"715911610","full_name":"WSH032/fastapi-proxy-lib","owner":"WSH032","description":"HTTP/WebSocket proxy for starlette/FastAPI","archived":false,"fork":false,"pushed_at":"2025-03-25T15:25:41.000Z","size":231,"stargazers_count":39,"open_issues_count":5,"forks_count":9,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-25T15:36:15.595Z","etag":null,"topics":["asgi","fastapi","forward-proxy","gateway","http","httpx","httpx-ws","proxy","reverse-proxy","starlette","websocket"],"latest_commit_sha":null,"homepage":"https://wsh032.github.io/fastapi-proxy-lib/","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/WSH032.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","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}},"created_at":"2023-11-08T04:38:36.000Z","updated_at":"2025-03-25T15:25:43.000Z","dependencies_parsed_at":"2024-02-05T20:37:31.258Z","dependency_job_id":"1d4d63b0-2b38-4352-92d9-8c52315b7b1a","html_url":"https://github.com/WSH032/fastapi-proxy-lib","commit_stats":{"total_commits":50,"total_committers":3,"mean_commits":"16.666666666666668","dds":0.28,"last_synced_commit":"a45086a6019234a6880cee99fe323ce0b04e3c97"},"previous_names":["wsh032/fastapi-proxy","wsh032/fastapi-proxy-lib"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WSH032%2Ffastapi-proxy-lib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WSH032%2Ffastapi-proxy-lib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WSH032%2Ffastapi-proxy-lib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WSH032%2Ffastapi-proxy-lib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WSH032","download_url":"https://codeload.github.com/WSH032/fastapi-proxy-lib/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247557767,"owners_count":20958047,"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":["asgi","fastapi","forward-proxy","gateway","http","httpx","httpx-ws","proxy","reverse-proxy","starlette","websocket"],"created_at":"2024-11-06T06:23:39.096Z","updated_at":"2025-04-06T22:06:26.174Z","avatar_url":"https://github.com/WSH032.png","language":"Python","readme":"\u003c!-- The content will be also use in `docs/index.md` by `pymdownx.snippets` --\u003e\n\u003c!-- Do not use any **relative link** and  **GitHub-specific syntax** ！--\u003e\n\u003c!-- Do not rename or move the file --\u003e\n\n# FastAPI Proxy Lib\n\n\u003cp align=\"center\"\u003e\n    \u003cem\u003eHTTP/WebSocket proxy for starlette/FastAPI\u003c/em\u003e\n\u003c/p\u003e\n\n| | |\n| - | - |\n| CI/CD   | [![CI: lint-test]][CI: lint-test#link] [![pre-commit.ci status]][pre-commit.ci status#link] \u003cbr\u003e [![CI: docs]][CI: docs#link] [![CI: publish]][CI: publish#link]  |\n| Code    | [![codecov]][codecov#link] [![Code style: black]][Code style: black#link] [![Ruff]][Ruff#link] [![Checked with pyright]][Checked with pyright#link] |\n| Package | [![PyPI - Version]][PyPI#link] [![PyPI - Downloads]][PyPI#link] [![PyPI - Python Version]][PyPI#link] |\n| Meta    | [![Hatch project]][Hatch project#link] [![GitHub License]][GitHub License#link] |\n\n---\n\nDocumentation: \u003chttps://wsh032.github.io/fastapi-proxy-lib/\u003e\n\nSource Code: \u003chttps://github.com/WSH032/fastapi-proxy-lib/\u003e\n\n---\n\n## Features\n\n- [X] **Out of the box !** [Helper functions](#quick-start) to get FastAPI `app`/`router` for proxy conveniently.\n- [x] **Only `Starlette` is required** for it to work ([`FastAPI` is optional](#installation)).\n- [x] Support both **HTTP** and **WebSocket** proxy.\n    - [x] Supports all HTTP methods (`GET`, `POST`, etc.)\n- [x] Support both **reverse** proxy and **forward** proxy.\n- [x] **Transparently** and **losslessly** handle all proxy requests,\n    Including **HTTP headers**, **cookies**, **query parameters**, **body**, etc.\n- [x] Asynchronous streaming transfer, support **file proxy**.\n- [x] `fastapi-proxy-lib` value [privacy security](https://wsh032.github.io/fastapi-proxy-lib/Usage/Security/).\n\n### other features\n\n- [x] Strict linting and strict-mode Pyright type checking.\n- [x] **100%** [Type Completeness](https://microsoft.github.io/pyright/#/typed-libraries?id=type-completeness), [Code coverage of **over 95%**][codecov#link].\n- [x] Forced keep-alive connections, minimizing proxy latency.\n- [x] Handle errors as gracefully as possible.\n    - `fastapi-proxy-lib` has a well-designed mechanism behind the scenes to handle exceptional websocket disconnections for you.\n    - `fastapi-proxy-lib` will exit as gracefully as possible.\n\n### `FastAPI Proxy Lib` stands on the shoulders of giants\n\n- [httpx](https://github.com/encode/httpx) for HTTP proxy\n- [httpx-ws](https://github.com/frankie567/httpx-ws) for WebSocket proxy\n\nSo, it perfectly supports all features of [httpx.AsyncClient](https://www.python-httpx.org/advanced/#client-instances), you can even use your custom `AsyncClient`, [`Transport`](https://www.python-httpx.org/advanced/#custom-transports).\n\nSee [Advanced Usage](https://wsh032.github.io/fastapi-proxy-lib/Usage/Advanced/) for more details.\n\n\u003e except `cookies` and `base_url` arguments, which are taken over by `fastapi-proxy-lib`\n\n## Installation\n\n\u003e !!! note\n\u003e\n\u003e     We follow semantic versioning.\u003cbr\u003e\n\u003e     This is a young project, and before 1.0.0, there may be changes in the API (we try to avoid that).\u003cbr\u003e\n\u003e     We will release security updates at any time, please try to keep the version updated, instead of pinning to the old version.\u003cbr\u003e\n\u003e     pin to `major version` is recommended.\u003cbr\u003e\n\u003e     visit our `CHANGELOG.md` for more info.\n\n```shell\npip install fastapi-proxy-lib[standard]\n```\n\nPerhaps you've noticed that we're installing `fastapi-proxy-lib[standard]` instead of `fastapi-proxy-lib`. The difference is:\n\n- The former will install `FastAPI` at the same time.\n- The latter installs only the basic dependencies for `fastapi-proxy-lib`.\n\nIf you **only need to use this library with Starlette**, you only need to install the latter.\n\n## Quick start\n\nWith the helper functions, get the FastAPI proxy server app is very convenient and out of the box:\n\n```python\nfrom fastapi_proxy_lib.fastapi.app import reverse_http_app\n\napp = reverse_http_app(base_url=\"http://www.example.com/foo/\")\n```\n\nThat's all! Now, you can launch the proxy server with `uvicorn`:\n\n```shell\nuvicorn main:app  --host 127.0.0.1 --port 8000\n```\n\nThen, visit `http://127.0.0.1:8000/bar?baz=1`, you will get the response from `http://www.example.com/foo/bar?baz=1`.\n\n**[Continue, please visit to our documentation 📚 for more details](https://wsh032.github.io/fastapi-proxy-lib/)**:\n\n- support for `FastAPI router`\n- only `Starlette` dependency\n- `WebSocket` proxy\n\n## development\n\n- If you find any issues, please don't hesitate to [open an issue](https://github.com/WSH032/fastapi-proxy-lib/issues).\n- If you need assistance, feel free to [start a discussion](https://github.com/WSH032/fastapi-proxy-lib/discussions).\n- Follow our `CONTRIBUTING.md`, [PR Welcome!](https://github.com/WSH032/fastapi-proxy-lib/pulls)\n- Security 😰❗: We value any security vulnerabilities, [please report to us privately](https://github.com/WSH032/fastapi-proxy-lib/security), pretty appreciated for that.\n\nEnglish is not the native language of the author (me), so if you find any areas for improvement in the documentation, your feedback is welcome.\n\nIf you think this project helpful, consider giving it a star ![GitHub Repo stars](https://img.shields.io/github/stars/wsh032/fastapi-proxy-lib?style=social), which makes me happy. :smile:\n\n## Refers\n\n[Can fastapi proxy another site as a response to the request?](https://github.com/tiangolo/fastapi/discussions/7382)\n\n## License\n\nThis project is licensed under the terms of the *Apache License 2.0*.\n\n\u003c!-- link --\u003e\n\n\u003c!-- ci/cd --\u003e\n[CI: lint-test]: https://github.com/WSH032/fastapi-proxy-lib/actions/workflows/lint-test.yml/badge.svg\n[CI: lint-test#link]: https://github.com/WSH032/fastapi-proxy-lib/actions/workflows/lint-test.yml\n[CI: docs]: https://github.com/WSH032/fastapi-proxy-lib/actions/workflows/docs.yml/badge.svg\n[CI: docs#link]: https://github.com/WSH032/fastapi-proxy-lib/actions/workflows/docs.yml\n[CI: publish]: https://github.com/WSH032/fastapi-proxy-lib/actions/workflows/publish.yml/badge.svg\n[CI: publish#link]: https://github.com/WSH032/fastapi-proxy-lib/actions/workflows/publish.yml\n[pre-commit.ci status]: https://results.pre-commit.ci/badge/github/WSH032/fastapi-proxy-lib/main.svg\n[pre-commit.ci status#link]: https://results.pre-commit.ci/latest/github/WSH032/fastapi-proxy-lib/main\n\u003c!-- code --\u003e\n[Code style: black]: https://img.shields.io/badge/code%20style-black-000000.svg\n[Code style: black#link]: https://github.com/psf/black\n[GitHub License]: https://img.shields.io/github/license/WSH032/fastapi-proxy-lib?color=9400d3\n[GitHub License#link]: https://github.com/WSH032/fastapi-proxy-lib/blob/main/LICENSE\n[Ruff]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json\n[Ruff#link]: https://github.com/astral-sh/ruff\n[Checked with pyright]: https://microsoft.github.io/pyright/img/pyright_badge.svg\n[Checked with pyright#link]: https://microsoft.github.io/pyright\n\u003c!-- package --\u003e\n[PyPI - Version]: https://img.shields.io/pypi/v/fastapi-proxy-lib?logo=pypi\u0026label=PyPI\u0026logoColor=gold\n[PyPI - Downloads]: https://img.shields.io/pypi/dm/fastapi-proxy-lib?color=blue\u0026label=Downloads\u0026logo=pypi\u0026logoColor=gold\n[PyPI - Python Version]: https://img.shields.io/pypi/pyversions/fastapi-proxy-lib?logo=python\u0026label=Python\u0026logoColor=gold\n[PyPI#link]: https://pypi.org/project/fastapi-proxy-lib\n\u003c!-- meta --\u003e\n[Hatch project]: https://img.shields.io/badge/%F0%9F%A5%9A-Hatch-4051b5.svg\n[Hatch project#link]: https://github.com/pypa/hatch\n[codecov]: https://codecov.io/gh/WSH032/fastapi-proxy-lib/graph/badge.svg?token=62QQU06E8X\n[codecov#link]: https://codecov.io/gh/WSH032/fastapi-proxy-lib\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwsh032%2Ffastapi-proxy-lib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwsh032%2Ffastapi-proxy-lib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwsh032%2Ffastapi-proxy-lib/lists"}