Skip to main content

rabbitpy

A pure-Python, thread-safe, minimalistic RabbitMQ client library.

rabbitpy provides a straightforward API for working with RabbitMQ. Connections, channels, queues, exchanges, and messages are plain Python objects. The library handles the AMQP protocol details so you don't have to.

Installation

pip install rabbitpy

Requirements

  • Python 3.11+
  • RabbitMQ 3.8+

Quick start

Publish a message

import rabbitpy

with rabbitpy.Connection('amqp://guest:guest@localhost:5672/%2f') as conn:
    with conn.channel() as channel:
        exchange = rabbitpy.Exchange(channel, 'my-exchange')
        exchange.declare()

        queue = rabbitpy.Queue(channel, 'my-queue')
        queue.declare()
        queue.bind(exchange, 'my-routing-key')

        message = rabbitpy.Message(channel, 'Hello, world!')
        message.publish(exchange, 'my-routing-key')

Consume messages

import rabbitpy

with rabbitpy.Connection('amqp://guest:guest@localhost:5672/%2f') as conn:
    with conn.channel() as channel:
        for message in rabbitpy.Queue(channel, 'my-queue'):
            print(message.body)
            message.ack()

Get a single message

import rabbitpy

with rabbitpy.Connection('amqp://guest:guest@localhost:5672/%2f') as conn:
    with conn.channel() as channel:
        queue = rabbitpy.Queue(channel, 'my-queue')
        message = queue.get()
        if message:
            print(message.body)
            message.ack()

Publish with confirmations

import rabbitpy

with rabbitpy.Connection('amqp://guest:guest@localhost:5672/%2f') as conn:
    with conn.channel() as channel:
        channel.enable_publisher_confirms()
        message = rabbitpy.Message(channel, 'Hello, world!')
        if message.publish('', routing_key='my-queue'):
            print('Confirmed by broker')

Transactional publishing

import rabbitpy

with rabbitpy.Connection('amqp://guest:guest@localhost:5672/%2f') as conn:
    with conn.channel() as channel:
        tx = rabbitpy.Tx(channel)
        tx.select()
        message = rabbitpy.Message(channel, 'Hello, world!')
        message.publish('', routing_key='my-queue')
        tx.commit()

Simple one-liner API

For scripts and simple use cases, rabbitpy provides module-level functions that manage the connection and channel for you:

import rabbitpy

# Publish
rabbitpy.publish('amqp://localhost/%2f', routing_key='my-queue', body=b'hello')

# Get
message = rabbitpy.get('amqp://localhost/%2f', queue_name='my-queue')

# Consume
for message in rabbitpy.consume('amqp://localhost/%2f', queue_name='my-queue'):
    print(message.body)
    message.ack()
    break

Connection URL

amqp[s]://username:password@host:port/virtual_host[?options]

Query string options:

Option Description
heartbeat Heartbeat interval in seconds (default: 60)
channel_max Maximum number of channels
frame_max Maximum frame size in bytes
timeout Connection timeout in seconds (default: 3)
cacertfile Path to CA certificate file
certfile Path to client certificate file
keyfile Path to client certificate key
verify Certificate verification: ignore, optional, or required

Example: amqp://guest:guest@localhost:5672/%2f?heartbeat=30&timeout=5

Documentation

Full API documentation is available at https://gmr.github.io/rabbitpy/.

License

BSD 3-Clause. See LICENSE for details.

Metadata

Release files for rabbitpy 3.0.2

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

Source distribution (sdist)

Source distribution for rabbitpy 3.0.2
File Size Uploaded
rabbitpy-3.0.2.tar.gz 136.7 kB Details

Built distribution (wheel)

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

Total release size: 188.5 kB

Release files / rabbitpy-3.0.2.tar.gz

Download URL rabbitpy-3.0.2.tar.gz
Size 136.7 kB
Tags Source
SHA-256 checksum
How to use checksums
9322a1e82b4d3d1afc21a617ce0b1e86b921174328735e7d54abc9525805ae5c
BLAKE2b-256 checksum
How to use checksums
b6464d36cfd2f15f9f919ea1ccccd59e900617371f41fb97ecdcd147d98d5619
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 Jun 12, 2026.

Transparency log

Release files / rabbitpy-3.0.2-py3-none-any.whl

Download URL rabbitpy-3.0.2-py3-none-any.whl
Size 51.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cb1cf8bf65881e256a4bcaf586581c53a4f1e8dfbf3a04f572b95112083ff23d
BLAKE2b-256 checksum
How to use checksums
b4a9bc224d490998824041a408a998c24c63aacebfdee0b9a681c84ae94f7c0b
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 Jun 12, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

3.0.2 This release

2 release files

3.0.1

2 release files

3.0.0

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.0.0

2 release files

0.27.1

2 release files

0.27.0

1 release file

0.26.2

2 release files

0.26.0

0.25.0

2 release files

0.24.0

2 release files

0.21.1

2 release files

0.21.0

2 release files

0.20.0

1 release file

0.19.0

2 release files

0.18.1

1 release file

0.18.0

1 release file

0.17.0

1 release file

0.16.0

1 release file

0.15.1

1 release file

0.15.0

1 release file

0.14.2

1 release file

0.14.1

1 release file

0.14.0

1 release file

0.13.0

1 release file

0.12.3

1 release file

0.12.2

1 release file

0.12.1

1 release file

0.12.0

1 release file

0.11.0

1 release file

0.10.0

1 release file

0.9.0

1 release file

0.8.1

1 release file

0.8.0

1 release file

0.7.0

1 release file

0.6.0

1 release file

0.5.1

1 release file

0.5.0

1 release file

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