Niza Global - API Docs
  • Introduction
  • General
  • Authentication
  • PUBLIC ENDPOINTS
    • Markets
    • Tickers
    • OHLC Data
    • Order Book
    • Historical Trades
  • AUTHENTICATED ENDPOINTS
    • Balances
      • (Deprecated) Trade Wallet
      • Spot Wallet
    • Orders
      • Create Order
      • Cancel Order
      • Open Orders
      • Closed Orders
      • Get Order
    • Trades
      • Trades History
      • Get Trade
  • Websocket API 1.0
    • Overview
    • Connection Details
    • WebSocket Authentication
    • Public Channels
      • Ticker Information
      • OHLC
      • Recent Trades
      • Orderbook
    • Private Channels
      • Order Executed
      • Trade Executed
Powered by GitBook
On this page
  • Pusher Channel Authorization
  • Channel Authorization Endpoint
  1. Websocket API 1.0

WebSocket Authentication

Guide how to authenticate your API user to the Niza WebSocket.

PreviousConnection DetailsNextPublic Channels

Last updated 7 months ago

To listen to private channels an authorization token is required. This is accomplished by making an HTTP request to the . The authorization token received should be set in the payload of the subscribe message.

Pusher Channel Authorization

If you are using Pusher client the authorization endpoint should be set when initializing Pusher instance, read more about setting the authorization endpoint .

Example of initialization of the Pusher with channelAuthorization

var pusher = new Pusher("APP_KEY", {
      cluster: "eu",
      forceTLS: true,
      disableStats: true,
      enabledTransports: ["wss", "ws"],
      activityTimeout: 10000,
      channelAuthorization: {
        endpoint: `https://app.niza.io/trade/v1/broadcasting/auth`,
        transport: "ajax",
        headers: {
          "X-API-Key": "[API_KEY]",
          "X-API-Sign": "[GENERATED_SIGNATURE]",
          "Access-Control-Allow-Origin": "*",
        },
      },
    });

Channel Authorization Endpoint

POST /broadcasting/auth

Headers

Name
Value

Content-Type

application/json

X-API-Key

API Key

X-API-Sign

Body

Name
Type
Description

socket_id

number

The id of the currently connected WebSocket.

channel_name

string

The private channel name you want to subscribe.

Response

{
    "auth": "23d6f445cd259b91adf9:c35ecc2c7a8280911ff4b4818be21ee80ae9b3843f8db60d422a3f5824474ac4"
}
{
  "error": "Invalid request"
}
{
    "error": "Access Denied"
}

Authorize channel subscription. Request should be made to the general .

The generated signature, check api .

Request URL
here
Channel Authorization Endpoint
authentication