Ably CLI

Open in

The Ably CLI brings the full power of Ably to your terminal. You can use it to manage your Ably account and its resources, and to explore Ably's APIs and features.

It's a quick and easy way to simulate additional clients when testing how Ably works.

The Ably CLI interacts with:

  • The Control API to manage your Ably account and applications.
  • Pub/Sub to publish and subscribe to messages in realtime.
  • Chat to send messages, display typing indicators and react to what's happening in a chat room.
  • Spaces to enter spaces and register member locations.

Installation

The Ably CLI is available as an NPM package.

  1. Install the Ably CLI:
npm install -g @ably/cli
  1. Run the following to log in to your Ably account. This will prompt you to log into your Ably account and setup an access token for the Ably CLI. You can then set the default app and API key to use back in your terminal instance:
ably login
  1. Start running commands in the CLI to create and interact with your Ably resources.

Usage

After you have successfully authenticated and chosen your app and API key, you're ready to interact with Ably resources directly from your terminal.

For example, open two terminal instances and subscribe to one, and publish messages in the other:

To subscribe:

ably channels subscribe channel-1

To publish:

# To publish 1 message:
ably channels publish channel-1 Hi!

# To publish 5 messages:
ably channels publish --count 5 channel-1 "Message number {{.Count}}"

For a list of all available commands, run:

ably help

Feature set

You can use the Ably CLI for undertaking operations such as:

OperationDescription
Ably Accounts
List accountsList the accounts you have access to.
Switch accountsSwitch between multiple Ably accounts.
Account statisticsQuery your account statistics.
Ably Apps
List appsList all apps in your account.
Switch appsSwitch between multiple apps.
Manage appsCreate and delete apps.
Manage API keysCreate, update and revoke API keys in an app.
App statisticsQuery app statistics.
Manage rulesCreate, update and delete rules in an app.
LogsQuery and subscribe to logs.
Integrations and Queues
Manage integrationsList, create and delete integrations.
Manage queuesList, create and delete queues.
Pub/Sub
List channelsList active channels in an app.
PublishPublish and batch publish messages.
SubscribeSubscribe to messages on channels.
PresenceEnter and subscribe to the presence set of channels.
HistoryQuery message history.
OccupancyFetch and subscribe to channel occupancy.
Chat
List roomsList chat rooms in an app.
MessagesSend and subscribe to messages.
PresenceEnter and subscribe to the presence set of chat rooms.
HistoryQuery chat message history.
OccupancyFetch and subscribe to chat room occupancy.
ReactionsSend and subscribe to message-level and room-level reactions.
Typing indicatorsSend and subscribe to typing indicators.
Spaces
List spacesList spaces in an app.
MembersEnter and subscribe the list of members.
LocationsSet and subscribe to member locations.
CursorsSet and subscribe to member cursors.
LocksAcquire and subscribe to locks.