RabbitMQ REST API
There’s a little known REST API built into RabbitMQ, accessible via the management plugin. Its methods are as follows:
GET | PUT | DELETE | POST | Path | Description |
---|---|---|---|---|---|
X | /api/overview | Various random bits of information that describe the whole system. | |||
X | X | /api/cluster-name | Name identifying this RabbitMQ cluster. | ||
X | /api/nodes | A list of nodes in the RabbitMQ cluster. | |||
X | /api/nodes/name | An individual node in the RabbitMQ cluster. Add “?memory=true” to get memory statistics, and “?binary=true” to get a breakdown of binary memory use (may be expensive if there are many small binaries in the system). | |||
X | /api/extensions | A list of extensions to the management plugin. | |||
X | X | /api/definitions /api/all-configuration (deprecated) |
The server definitions – exchanges, queues, bindings, users, virtual hosts, permissions and parameters. Everything apart from messages. POST to upload an existing set of definitions. Note that:
For convenience you may upload a file from a browser to this URI (i.e. you can use |
||
X | /api/connections | A list of all open connections. | |||
X | X | /api/connections/name | An individual connection. DELETEing it will close the connection. Optionally set the “X-Reason” header when DELETEing to provide a reason. | ||
X | /api/connections/name/channels | List of all channels for a given connection. | |||
X | /api/channels | A list of all open channels. | |||
X | /api/channels/channel | Details about an individual channel. | |||
X | /api/consumers | A list of all consumers. | |||
X | /api/consumers/vhost | A list of all consumers in a given virtual host. | |||
X | /api/exchanges | A list of all exchanges. | |||
X | /api/exchanges/vhost | A list of all exchanges in a given virtual host. | |||
X | X | X | /api/exchanges/vhost/name | An individual exchange. To PUT an exchange, you will need a body looking something like this:
{"type":"direct","auto_delete":false,"durable":true,"internal":false,"arguments":{}} The |
|
X | /api/exchanges/vhost/name/bindings/source | A list of all bindings in which a given exchange is the source. | |||
X | /api/exchanges/vhost/name/bindings/destination | A list of all bindings in which a given exchange is the destination. | |||
X | /api/exchanges/vhost/name/publish | Publish a message to a given exchange. You will need a body looking something like:
{"properties":{},"routing_key":"my key","payload":"my body","payload_encoding":"string"} All keys are mandatory. The {"routed": true}
|
|||
X | /api/queues | A list of all queues. | |||
X | /api/queues/vhost | A list of all queues in a given virtual host. | |||
X | X | X | /api/queues/vhost/name | An individual queue. To PUT a queue, you will need a body looking something like this:
{"auto_delete":false,"durable":true,"arguments":{},"node":"rabbit@smacmullen"} All keys are optional.When DELETEing a queue you can add the query string parameters |
|
X | /api/queues/vhost/name/bindings | A list of all bindings on a given queue. | |||
X | /api/queues/vhost/name/contents | Contents of a queue. DELETE to purge. Note you can’t GET this. | |||
X | /api/queues/vhost/name/actions | Actions that can be taken on a queue. POST a body like:
{"action":"sync"} Currently the actions which are supported are |
|||
X | /api/queues/vhost/name/get | Get messages from a queue. (This is not an HTTP GET as it will alter the state of the queue.) You should post a body looking like:
{"count":5,"requeue":true,"encoding":"auto","truncate":50000}
Please note that the get path in the HTTP API is intended for diagnostics etc – it does not implement reliable delivery and so should be treated as a sysadmin’s tool rather than a general API for messaging. |
|||
X | /api/bindings | A list of all bindings. | |||
X | /api/bindings/vhost | A list of all bindings in a given virtual host. | |||
X | X | /api/bindings/vhost/e/exchange/q/queue | A list of all bindings between an exchange and a queue. Remember, an exchange and a queue can be bound together many times! To create a new binding, POST to this URI. You will need a body looking something like this:
{"routing_key":"my_routing_key","arguments":{}} All keys are optional. The response will contain a |
||
X | X | /api/bindings/vhost/e/exchange/q/queue/props | An individual binding between an exchange and a queue. The props part of the URI is a “name” for the binding composed of its routing key and a hash of its arguments. | ||
X | X | /api/bindings/vhost/e/source/e/destination | A list of all bindings between two exchanges. Similar to the list of all bindings between an exchange and a queue, above. | ||
X | X | /api/bindings/vhost/e/source/e/destination/props | An individual binding between two exchanges. Similar to the individual binding between an exchange and a queue, above. | ||
X | /api/vhosts | A list of all vhosts. | |||
X | X | X | /api/vhosts/name | An individual virtual host. As a virtual host usually only has a name, you do not need an HTTP body when PUTing one of these. To enable / disable tracing, provide a body looking like:
{"tracing":true} |
|
X | /api/vhosts/name/permissions | A list of all permissions for a given virtual host. | |||
X | /api/users | A list of all users. | |||
X | X | X | /api/users/name | An individual user. To PUT a user, you will need a body looking something like this:
{"password":"secret","tags":"administrator"} or: {"password_hash":"2lmoth8l4H0DViLaK9Fxi6l9ds8=", "tags":"administrator"} The |
|
X | /api/users/user/permissions | A list of all permissions for a given user. | |||
X | /api/whoami | Details of the currently authenticated user. | |||
X | /api/permissions | A list of all permissions for all users. | |||
X | X | X | /api/permissions/vhost/user | An individual permission of a user and virtual host. To PUT a permission, you will need a body looking something like this:
{"configure":".*","write":".*","read":".*"} All keys are mandatory. |
|
X | /api/parameters | A list of all parameters. | |||
X | /api/parameters/component | A list of all parameters for a given component. | |||
X | /api/parameters/component/vhost | A list of all parameters for a given component and virtual host. | |||
X | X | X | /api/parameters/component/vhost/name | An individual parameter. To PUT a parameter, you will need a body looking something like this:
{"vhost": "/","component":"federation","name":"local_username","value":"guest"} |
|
X | /api/policies | A list of all policies. | |||
X | /api/policies/vhost | A list of all policies in a given virtual host. | |||
X | X | X | /api/policies/vhost/name | An individual policy. To PUT a policy, you will need a body looking something like this:
{"pattern":"^amq.", "definition": {"federation-upstream-set":"all"}, "priority":0, "apply-to": "all"}
|
|
X | /api/aliveness-test/vhost | Declares a test queue, then publishes and consumes a message. Intended for use by monitoring tools. If everything is working correctly, will return HTTP status 200 with body:
{"status":"ok"} Note: the test queue will not be deleted (to to prevent queue churn if this is repeatedly pinged). |
This can probably be used to build a library that monitor RabbitMQ nodes and automatically select the best node to connect to