Publish from CLI

Use the following code snippets to publish a message on a WebSocket channel with curl or wget.

Using curl

# Demo Cluster ID, API key and secret used, get yours at https://piesocket.com

curl --location --request POST 'https://CLUSTER_ID.piesocket.com/api/publish' \
--header 'Content-Type: application/json' \
--data-raw '{
    "key": "oCdCMcMPQpbvNjUIzqtvF1d2X2okWpDQj4AwARJuAgtjhzKxVEjQU6IdCjwm",
    "secret": "d8129f82f8dd71910aa4a7efa30a7297",
    "channelId": "channel_1",
    "message": "Hello world!"
}'

Using wget

# Demo Cluster ID, API key and secret used, get yours at https://piesocket.com

wget --no-check-certificate --quiet \
  --method POST \
  --timeout=0 \
  --header 'Content-Type: application/json' \
  --body-data '{
    "key": "oCdCMcMPQpbvNjUIzqtvF1d2X2okWpDQj4AwARJuAgtjhzKxVEjQU6IdCjwm",
    "secret": "d8129f82f8dd71910aa4a7efa30a7297",
    "channelId": "channel_1",
    "message": "Hello world!"
}' \
   'https://CLUSTER_ID.piesocket.com/api/publish'

This sends a JSON message to channel_1.

Please note that this example uses a demo key and secret, which is public. The demo key is only for quick testing purposes, and you should not use this in your application.

You can get your free API key and API secret here.

Help

Facing difficulties? Use the chat box on the bottom-right corner of this page to reach us.