Registry / web-framework / blacksheep

blacksheep

JSON →
library2.6.3pypypi✓ verified 89d ago

A fast ASGI web framework for building asynchronous web applications in Python, featuring automatic OpenAPI documentation generation, dependency injection, and built-in HTTP client. Current version 2.6.2, supporting Python 3.10+. Active development with monthly releases on GitHub.

pip install blacksheep
INSTALL
IMPORT
SIG · BLACKSHEEP
B
blacksheep
web-frameworkpythonv2.6.3
Install
3.5s avg
Import
392ms
Disk
44MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v2.6.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.394s · 44.7MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 3.5s · import 0.390s · 49MB
44MB installed
● package 44MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Application
✓ from blacksheep import Application
✗ from blacksheep.server import Application
In v2.x, Application is directly exposed from the top-level package. Using blacksheep.server was deprecated.
Request
✓ from blacksheep import Request
✗ from blacksheep.server import Request
Request and Response are top-level exports since v2.0.
Response
✓ from blacksheep import Response
get
✓ from blacksheep.server.routing import get
✗ from blacksheep import get
Route decorators are in routing module, not top-level.
Router
✓ from blacksheep.server.routing import Router
✗ from blacksheep.routing import Router
Router is under blacksheep.server.routing.
Inject
✓ from blacksheep.server.di import Inject
✗ from blacksheep import Inject
DI tools are in the blacksheep.server.di submodule.

Minimal BlackSheep app with a single route. Run with uvicorn or hypercorn.

from blacksheep import Application, Request, Response from blacksheep.server.routing import get app = Application() @get('/') async def home(request: Request) -> str: return 'Hello, World!' # Run using: uvicorn main:app
Debug
Known issues
breakingIn v2.0+, the Application class no longer takes an 'app' parameter (previously used for wsgi). Use Application() directly.
fix
Remove any arguments from Application instantiation.
affects: >=2.0.0
breakingThe 'server' module was reorganized in v2.0. Most classes moved out of blacksheep.server to top-level. Importing from blacksheep.server for Request/Response/Application may fail.
fix
Update imports to top-level: from blacksheep import Request, Response, Application.
affects: >=2.0.0
gotchaRoute handlers must be async functions. Using synchronous functions will cause a runtime error or unexpected behavior.
fix
Define all handlers with async def.
affects: all
gotchaWhen using the built-in HTTP client, ensure the event loop is running. Instantiating blacksheep.client.Client outside an async context may cause deadlocks.
fix
Create the client inside an async function or use await client.open_async().
affects: all
deprecatedThe 'auth_mode' parameter in JWTBearerAuthentication is deprecated since v2.4.3. Use 'scheme' instead.
fix
Replace auth_mode=... with scheme=... in JWTBearerAuthentication constructor.
affects: >=2.4.3
Errors
Common errors & fixes
ImportError: cannot import name 'Application' from 'blacksheep'
Installed version is older than v2.0 or import path changed.
fix
Upgrade to latest: pip install --upgrade blacksheep. If still failing, use from blacksheep.server import Application for older versions.
TypeError: 'function' object is not subscriptable
Using synchronous handler or missing proper route decorator parentheses.
fix
Ensure handler is async and use @get('/') with parentheses, not @get('/') without calling.
RuntimeError: You must use `await` on the request body methods
Calling Request methods like .json() or .form() without await inside async handler.
fix
Use await request.json() or await request.form().
Upgrade
Version history
2.6.3latest on PyPI · released Jun 4, 2026
Audit
Dependencies
httptoolsrequiredHTTP parsing
urllib3requiredHTTP client backend
blacksheep-jwtoptionalJWT authentication
pyjwtoptionalJWT encoding/decoding
Agent activity
15 hits · last 30 days
node
14
OpenAI (training)
1
Resources
blacksheep — pip install blacksheep · libregistry