https://github.com/adriangb/xpresso
A composable Python ASGI web framework
Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (16.5%) to scientific vocabulary
Keywords
Keywords from Contributors
Repository
A composable Python ASGI web framework
Basic Info
- Host: GitHub
- Owner: adriangb
- License: mit
- Language: Python
- Default Branch: main
- Homepage: https://xpresso-api.dev/
- Size: 6.46 MB
Statistics
- Stars: 180
- Watchers: 6
- Forks: 5
- Open Issues: 16
- Releases: 98
Topics
Metadata Files
README.md
Xpresso is an ASGI web framework built on top of Starlette, Pydantic and di, with heavy inspiration from FastAPI.
Some of the standout features are:
- ASGI support for high performance (within the context of Python web frameworks)
- OpenAPI documentation generation
- Automatic parsing and validation of request bodies and parameters, with hooks for custom extractors
- Full support for OpenAPI parameter serialization
- Highly typed and tested codebase with great IDE support
- A powerful dependency injection system, backed by di
Requirements
Python 3.7+
Installation
shell
pip install xpresso
You'll also want to install an ASGI server, such as Uvicorn.
shell
pip install uvicorn
Example
Create a file named example.py:
```python from pydantic import BaseModel from xpresso import App, Path, FromPath, FromQuery
class Item(BaseModel): item_id: int name: str
async def readitem(itemid: FromPath[int], name: FromQuery[str]) -> Item: return Item(itemid=itemid, name=name)
app = App( routes=[ Path( "/items/{itemid}", get=readitem, ) ] ) ```
Run the application:
shell
uvicorn example:app
Navigate to http://127.0.0.1:8000/items/123?name=foobarbaz in your browser. You will get the following JSON response:
json
{"item_id":123,"name":"foobarbaz"}
Now navigate to http://127.0.0.1:8000/docs to poke around the interactive Swagger UI documentation:

For more examples, tutorials and reference materials, see our documentation.
Inspiration and relationship to other frameworks
Xpresso is mainly inspired by FastAPI. FastAPI pioneered several ideas that are core to Xpresso's approach:
- Leverage Pydantic for JSON parsing, validation and schema generation.
- Leverage Starlette for routing and other low level web framework functionality.
- Provide a simple but powerful dependency injection system.
- Use that dependency injection system to provide extraction of request bodies, forms, query parameters, etc.
Xpresso takes these ideas and refines them by:
- Decoupling the dependency injection system from the request/response cycle, leading to an overall much more flexible and powerful dependency injection system, packaged up as the standalone di library.
- Decoupling the framework from Pydantic by using
Annotated(PEP 593) instead of default values (param: FromQuery[str]instead ofparam: str = Query(...)). - Middleware on Routers so that you can use generic ASGI middleware in a routing-aware manner (for example, installing profiling middleware on only some paths without using regex matching).
- Support for lifespans on any Router or mounted App
- dependency injection into the application lifespan and support for multiple dependency scopes.
- Formalizing the framework for extracting parameters and bodies from requests into the Binder API so that 3rd party extensions can do anything the framework does.
- Support for customizing parameter and form serialization.
- Better performance by implementing dependency resolution in Rust, executing dependencies concurrently and controlling threading of sync dependencies on a per-dependency basis.
Inspiration to FastAPI
When I originally concieved Xpresso I wasn't sure what the goal was. I didn't necessarily want to replace FastAPI, I know how much work open source is and was not and am not willing to commit to something like that. So I always thought of the project more as a testing ground for interesting ideas for ASGI web frameworks in general and FastAPI in particular.
I am happy to report that in this sense it has been a smash hit. In the time since writing the above differences: - Starlette added support for middleware on routers. - The ASGI spec, Starlette and FastAPI added support for returning data from lifespans, which I think may be an even better idea than dependency scopes. - FastAPI added support for PEP593 annotations, taking direct inspiration from Xpresso's approach. - I've established a strong working relationship with Sebastián, FastAPI's author, and I foresee more ideas from Xpresso leaking into FastAPI in some way or another.
So where does that leave Xpresso? It's going to stay around, but it's less likely to become a stable production ready framework: it can provide more value to the community as an exprimental proving ground for ideas than as yet another "production ready" web framework.
Owner
- Name: Adrian Garcia Badaracco
- Login: adriangb
- Kind: user
- Location: Chicago, IL
- Repositories: 172
- Profile: https://github.com/adriangb
GitHub Events
Total
- Watch event: 7
- Fork event: 1
Last Year
- Watch event: 7
- Fork event: 1
Committers
Last synced: 9 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Adrian Garcia Badaracco | 1****b | 265 |
| Daniel Townsend | d****n@d****k | 4 |
| dependabot[bot] | 4****] | 1 |
| Yasser Tahiri | y****9@g****m | 1 |
| Thomas Grainger | t****n@g****m | 1 |
| Marcelo Trylesinski | m****e@g****m | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 25
- Total pull requests: 75
- Average time to close issues: 26 days
- Average time to close pull requests: 2 days
- Total issue authors: 3
- Total pull request authors: 5
- Average comments per issue: 2.92
- Average comments per pull request: 0.95
- Merged pull requests: 63
- Bot issues: 0
- Bot pull requests: 3
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- adriangb (21)
- dantownsend (3)
- Iniversalstudio (1)
Pull Request Authors
- adriangb (67)
- dantownsend (3)
- dependabot[bot] (3)
- yezz123 (1)
- Kludex (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- pypi 340 last-month
- Total dependent packages: 0
- Total dependent repositories: 46
- Total versions: 100
- Total maintainers: 1
pypi.org: xpresso
A developer centric, performant Python web framework
- Homepage: https://github.com/adriangb/xpresso
- Documentation: https://www.xpresso-api.dev
- License: MIT
-
Latest release: 0.46.0
published about 3 years ago
Rankings
Maintainers (1)
Dependencies
- asgi-lifespan 1.0.1 develop
- asgiref 3.5.2 develop
- async-generator 1.10 develop
- atomicwrites 1.4.1 develop
- attrs 22.1.0 develop
- black 22.6.0 develop
- certifi 2022.6.15 develop
- cffi 1.15.1 develop
- cfgv 3.3.1 develop
- charset-normalizer 2.1.0 develop
- click 8.1.3 develop
- colorama 0.4.5 develop
- coverage 6.4.3 develop
- distlib 0.3.5 develop
- fastapi 0.79.0 develop
- filelock 3.7.1 develop
- flake8 3.9.2 develop
- ghp-import 2.1.0 develop
- gunicorn 20.1.0 develop
- h11 0.12.0 develop
- httpcore 0.15.0 develop
- httptools 0.2.0 develop
- httpx 0.23.0 develop
- identify 2.5.2 develop
- importlib-metadata 4.12.0 develop
- iniconfig 1.1.1 develop
- isort 5.10.1 develop
- jinja2 3.1.2 develop
- markdown 3.3.7 develop
- markupsafe 2.1.1 develop
- mccabe 0.6.1 develop
- mergedeep 1.3.4 develop
- mike 1.1.2 develop
- mkdocs 1.3.1 develop
- mkdocs-material 8.3.9 develop
- mkdocs-material-extensions 1.0.3 develop
- msgpack 1.0.4 develop
- mypy 0.971 develop
- mypy-extensions 0.4.3 develop
- nodeenv 1.7.0 develop
- outcome 1.2.0 develop
- packaging 21.3 develop
- pathspec 0.9.0 develop
- platformdirs 2.5.2 develop
- pluggy 1.0.0 develop
- pre-commit 2.20.0 develop
- py 1.11.0 develop
- pycodestyle 2.7.0 develop
- pycparser 2.21 develop
- pyflakes 2.3.1 develop
- pygments 2.12.0 develop
- pyinstrument 4.2.0 develop
- pymdown-extensions 9.5 develop
- pyparsing 3.0.9 develop
- pytest 6.2.5 develop
- pytest-cov 3.0.0 develop
- pytest-sugar 0.9.5 develop
- python-dateutil 2.8.2 develop
- python-dotenv 0.20.0 develop
- python-multipart 0.0.5 develop
- pyyaml 6.0 develop
- pyyaml-env-tag 0.1 develop
- requests 2.28.1 develop
- rfc3986 1.5.0 develop
- six 1.16.0 develop
- sortedcontainers 2.4.0 develop
- termcolor 1.1.0 develop
- toml 0.10.2 develop
- tomli 2.0.1 develop
- trio 0.19.0 develop
- typed-ast 1.5.4 develop
- urllib3 1.26.11 develop
- uvicorn 0.15.0 develop
- uvloop 0.16.0 develop
- verspec 0.1.0 develop
- virtualenv 20.16.2 develop
- watchdog 2.1.9 develop
- watchgod 0.8.2 develop
- websockets 10.3 develop
- zipp 3.8.1 develop
- anyio 3.6.1
- di 0.70.0
- graphlib2 0.4.6
- idna 3.3
- pydantic 1.9.1
- sniffio 1.2.0
- starlette 0.19.1
- typing-extensions 4.3.0
- asgi-lifespan ~1 develop
- black ~22 develop
- coverage ~6 develop
- fastapi >=0.75.0 develop
- flake8 ~3 develop
- gunicorn ^20.1.0 develop
- httpx >=0.23.0 develop
- isort ~5 develop
- mike ~1 develop
- mkdocs ~1 develop
- mkdocs-material ~8 develop
- msgpack ^1.0.3 develop
- mypy >=v0.930 develop
- pre-commit ~2 develop
- pyinstrument ^4.1.1 develop
- pytest ~6 develop
- pytest-cov ~3 develop
- pytest-sugar ~0 develop
- python-multipart ~0 develop
- requests ~2 develop
- trio ^0.19.0 develop
- uvicorn ^0.15.0 develop
- anyio >=3.4.0,<5
- di >=0.70.0
- pydantic ^1.9.0
- python >=3.7,<4
- starlette >=0.17.1,<1
- typing-extensions >=3
- actions/checkout v2 composite
- actions/setup-python v2 composite
- codecov/codecov-action v2.1.0 composite
- ncipollo/release-action v1 composite
- snok/install-poetry v1.3.1 composite
