Skip to main content

The Connect logo

Connect for Python

PyPI version License Slack

Connect is the easiest way to build modern APIs.

Docs • API reference • Example • New to Connect?

Why Connect?

Building an API usually means writing the same types at least twice: once on the server, and once in every client. Connect makes this simple - define your API schema using Protobuf, and Connect generates type-safe server stubs and idiomatic client libraries in every major language, including for your frontend. All that's left to write is your business logic, in plain Python.

Connect already works with your current tech stack:

  • Connect is built on top of HTTP and speaks both Protobuf and JSON, so curl works out of the box.
  • It interoperates seamlessly with gRPC and gRPC-Web, and supports streaming as a first-class feature.
  • It runs on WSGI/ASGI. Build Connect APIs alongside your current API framework - all in the same app.

Features

  • Servers: WSGI and ASGI-ready (including trio), use with any compatible server
  • Clients: Lightweight sync and async clients, backed by pyqwest
  • Protocols: Supports Connect, gRPC, and gRPC-Web (HTTP/1.1 and HTTP/2)
  • Type safety: Fully type-annotated generated code
  • Streaming: Full support for server, client, and bidirectional streaming
  • Compression: Built-in support for gzip, brotli, and zstd
  • Middleware: Server- and client-side interceptors for telemetry, logging, etc.
  • Compliant: Verified using the official Connect conformance test suite

Getting started

Install the runtime library:

uv add connectrpc

For codegen, install buf and create buf.gen.yaml:

version: v2
plugins:
  - remote: buf.build/bufbuild/py
    out: gen
  - remote: buf.build/connectrpc/py
    out: gen
Local plugin setup

The example above uses a Buf-hosted plugin server. To generate code entirely locally, install the relevant plugins:

uv add --dev protoc-gen-py protoc-gen-connectrpc

Now edit your buf.gen.yaml:

version: v2
plugins:
  - local: .venv/bin/protoc-gen-py
    out: gen
  - local: .venv/bin/protoc-gen-connectrpc
    out: gen
Compatibility with google-protobuf

Connect defaults to targeting protobuf-py as the Protocol Buffers implementation, but it also supports Google's Protocol Buffers for Python. Pass protobuf=google to the codegen plugin to use it.

version: v2
plugins:
  - remote: buf.build/protocolbuffers/python
    out: .
  - remote: buf.build/protocolbuffers/pyi
    out: .
  - remote: buf.build/connectrpc/py
    out: .
    opt: protobuf=google

If configuring a client for JSON codec, make sure to pass connectrpc.compat.google_protobuf_json_codec instead of connectrpc.codec.proto_json_codec.

Usage

A basic Connect server is easy to set up. Just import the stubs, subclass the generated service, and serve:

from connectrpc.request import RequestContext
from your_service_pb import HelloRequest, HelloResponse
from your_service_connect import HelloService, HelloServiceASGIApplication


class MyHelloService(HelloService):
    async def say_hello(
        self, request: HelloRequest, ctx: RequestContext
    ) -> HelloResponse:
        return HelloResponse(message=f"Hello, {request.name}!")


# Create ASGI app
app = HelloServiceASGIApplication(MyHelloService())

# Run with any ASGI server, e.g. uvicorn:
# uvicorn server:app --port 8080

Client libraries are automatically generated for you. Here's what the async client looks like:

from your_service_pb import HelloRequest, HelloResponse
from your_service_connect import HelloServiceClient


async def main():
    # Create async client
    async with HelloServiceClient("https://api.example.com") as client:
        response = await client.say_hello(HelloRequest(name="World"))
        print(response.message)  # "Hello, World!"

And the sync client:

from your_service_pb import HelloRequest
from your_service_connect import HelloServiceClientSync


def main():
    # Create sync client
    with HelloServiceClientSync("https://api.example.com") as client:
        response = client.say_hello(HelloRequest(name="World"))
        print(response.message)  # "Hello, World!"


if __name__ == "__main__":
    main()

Check out the docs for more detailed usage.

  • Streaming: Connect supports server-side, client-side, and bidirectional streaming.
  • Interceptors: Set up middleware for logging, observability, and metrics.
  • Other languages: Generate clients for use in other languages.

Metadata

Release files for connectrpc 0.13.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for connectrpc 0.13.0
File Size Uploaded Provenance Actions
connectrpc-0.13.0.tar.gz 61.2 kB With provenance Details for connectrpc-0.13.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for connectrpc 0.13.0
File Interpreter ABI Platform Actions
connectrpc-0.13.0-py3-none-any.whl Python 3 none any Details for connectrpc-0.13.0-py3-none-any.whl

Total release size: 137.3 kB

Release files / connectrpc-0.13.0.tar.gz

Download URL connectrpc-0.13.0.tar.gz
Size 61.2 kB
Tags Source
SHA-256 checksum
How to use checksums
999d39d016a5bfaceefdbe943b9cfd669dfdf54efb8ccb0c6ed9ae9edee35fad
BLAKE2b-256 checksum
How to use checksums
2f7e7ce9258389404c503f55b0c9434775c8a527e6fae62c48cb70b7e1ad486f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 25, 2026.

Transparency log

Release files / connectrpc-0.13.0-py3-none-any.whl

Download URL connectrpc-0.13.0-py3-none-any.whl
Size 76.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
21e3839e6745606c72098a2e50b4d52c82dd2c4e21c0e75fbd7b9413548572fd
BLAKE2b-256 checksum
How to use checksums
0268b66df1d7e47db4ef60c5aa968bd45470898513363df6e3e87ea7bc7033c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 25, 2026.

Transparency log

Security for connectrpc 0.13.0

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for connectrpc-0.13.0.tar.gz

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 Oct 25, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page