FastSQS
A FastAPI-style router for AWS SQS on Lambda
Pydantic routing · dependency injection · middleware · native partial batch failure
Documentation · Quickstart · Changelog · Source · Issues
FastSQS turns an SQS-triggered Lambda into a typed, declarative app. You write
handlers for pydantic event models; FastSQS parses each record, routes it,
validates it, runs your middleware, and returns the batchItemFailures SQS
expects, so failed messages are redelivered and dead-lettered by the queue's
own redrive policy, not by bespoke in-app code.
Features
- FastAPI-style routing:
@app.route(OrderCreated)dispatches by a payload discriminator (default key"type"). - Pydantic validation: handlers receive a validated
SQSEventmodel; bad messages become clean batch failures. - Dependency injection: declare
Depends(...)params (powered byfast-depends); no@injectneeded. - Typed
Context:ctx.message_id,ctx.queue_type, and more as typed attributes; arbitrary scratch inctx.state. - Middleware:
before/afterhooks with balanced unwind (resources acquired inbeforeare always released). - Partial batch failure: native
ReportBatchItemFailuresfor standard and FIFO queues. - FIFO-aware: queue type is inferred from the event-source ARN; per-group ordering with a configurable failure mode.
- EventBridge Pipes ready:
app.handleraccepts both the Lambda{"Records": [...]}envelope and a bare list of records. - Shape detection:
is_sqs_event(event)lets one Lambda multiplex SQS and non-SQS (e.g. API Gateway) events. - In-process test client: drive your app with synthetic events, no AWS required.
- Typed: ships
py.typed; full editor and mypy support.
Install
pip install fastsqs
Requires Python 3.10+. Depends on pydantic>=2 and fast-depends>=3,<4.
Quick start
from fastsqs import FastSQS, SQSEvent
app = FastSQS() # queue type auto-detected from the event-source ARN
class OrderCreated(SQSEvent):
order_id: str
amount: int
@app.route(OrderCreated)
async def handle_order(msg: OrderCreated):
print("processing", msg.order_id, msg.amount)
# raising marks this record as failed -> SQS redelivers it
# Lambda entry point (set as the function handler):
def handler(event, context):
return app.handler(event, context)
A message routes by its discriminator value ("type" by default), matched to
the event model's name in snake_case, so {"type": "order_created", ...} routes
to OrderCreated. Field names accept both snake_case and their camelCase
aliases via Pydantic alias generation.
Why fastsqs
Reach for fastsqs when a queue carries many message types and you would
otherwise branch by hand in one large handler. It gives you correct
ReportBatchItemFailures together with the FastAPI model on top: route by type,
validate with pydantic, inject dependencies, and read a typed Context. For a
single trivial handler with no validation, a plain boto3 loop is still fine.
Documentation
Full documentation, including guides, concepts, and the API reference: fastsqs.github.io
- Quickstart
- Guide — routing, dependency injection, middleware, FIFO, testing
- Concepts — how routing, the batch lifecycle, and partial batch failure work
- API Reference
Contributing
Issues and pull requests are welcome. See CONTRIBUTING.md for dev setup, and the Code of Conduct. Open an issue to discuss anything non-trivial first.
License
MIT. See LICENSE.
Metadata
Release files for fastsqs 1.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| fastsqs-1.1.5.tar.gz | 73.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fastsqs-1.1.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 101.4 kB
Release files / fastsqs-1.1.5.tar.gz
| Download URL | fastsqs-1.1.5.tar.gz |
|---|---|
| Size | 73.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3ec43c9b2deb3c28c4d4c4b11231fb4058bfb44d9a1e37ccfd04fac31cfa834e
|
|
BLAKE2b-256 checksum How to use checksums |
787de4b1ed3b240634713272f667817f1d6532477e7495dcfe96331edfa07345
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 13, 2026.
Transparency logRelease files / fastsqs-1.1.5-py3-none-any.whl
| Download URL | fastsqs-1.1.5-py3-none-any.whl |
|---|---|
| Size | 27.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2ab1298020c056a4dca0ac738eb68e26cdc935e67f268bc6a9c4d2b516538a43
|
|
BLAKE2b-256 checksum How to use checksums |
b1aa6d056606449fb51dd9706f6b6ac246e256b15975d31acb883706b6fa9bbf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 13, 2026.
Transparency log