pyrabbit2

raw JSON →
1.0.7 verified Mon Apr 27 auth: no python

A Pythonic interface to the RabbitMQ Management HTTP API. Version 1.0.7 wraps the RabbitMQ management plugin's REST API for cluster management, queue introspection, and user administration. Maintained slowly; no breaking changes in the 1.x line.

pip install pyrabbit2
error AttributeError: module 'pyrabbit2' has no attribute 'Client'
cause Incorrect import: trying `from pyrabbit2 import Client` instead of `from pyrabbit2.api import Client`.
fix
Use from pyrabbit2.api import Client.
error requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=5672): Max retries exceeded
cause Using default AMQP port (5672) for HTTP management API; should be 15672.
fix
Pass port=15672 (or correct management port) to Client.
breaking pyrabbit2 is NOT drop-in compatible with the original pyrabbit. API module structure and method signatures differ (e.g., `get_queues()` vs `get_queues()` similar but parameter names changed).
fix Use `from pyrabbit2.api import Client` and consult pyrabbit2 docs for method arguments.
gotcha Default port is 15672 (management plugin HTTP port), not 5672 (AMQP). Common mistake: using AMQP port, causing connection timeout.
fix Ensure RABBIT_PORT is set to the management plugin port (usually 15672).
gotcha The library provides only synchronous HTTP calls; no async support. Long-running operations may block.
fix Use threading/asyncio wrapper or consider aio-pika for async AMQP management.

Connect to RabbitMQ management plugin and list queues.

from pyrabbit2.api import Client
import os

client = Client(
    host=os.environ.get('RABBIT_HOST', 'localhost'),
    port=os.environ.get('RABBIT_PORT', 15672),
    user=os.environ.get('RABBIT_USER', 'guest'),
    password=os.environ.get('RABBIT_PASS', 'guest')
)
queues = client.get_queues()
print(queues)