👋
CAYC
  • Cyber Ape Yacht Club LLC
    • About
    • Facts & Figures
    • Why Us?
    • Utility
    • Patents
    • CAYC Tiers
      • Psychedelic Apes (2% Class B Share Holders)
      • The Nether King
      • Kings and Queens Apes
      • 1 of 1’s & Sporting Apes
      • Dragon Based Apes
      • Crowns and Tiaras
      • Genesis Ape - Blue Tron Print
      • Cyber Apes - Base Multi Colored Apes
  • GambleStakes
    • About
    • Privacy Policy
    • Terms of Service
    • Outreach & Publicity
    • AML Laws
  • CAYC Cases
    • About
    • Unique Vendors on Product
    • Provably Fair Code
  • CAYC Exchange
    • CAYC Exchange Documentation Home
      • HELP & INFORMATION
        • What is CAYC Exchange
        • Privacy Policy
        • Trading fees
      • BASIC UI/UX DOCUMENTATION
        • Account Management
        • Secure Account
        • Deposit & Withdraw
      • API DOCUMENTATION
        • API Access
        • REST API
        • Using Nodejs Library
        • Custom Websocket Client
  • Unreal Kingdoms
    • About
    • Unreal Engine 5
    • Plots
    • GambleStakes ToS Inside UnrealKingdoms
  • Partnerships
    • Atlas World Sports
      • About
    • Dragon Guild LLC
      • About
      • Founders
      • Vision
    • Starship Universe (SSU)
      • About
      • Vision, Mission, Values
      • Gameplay
Powered by GitBook
On this page
  • Requirements
  • Public Usage
  • Private Usage
  1. CAYC Exchange
  2. CAYC Exchange Documentation Home
  3. API DOCUMENTATION

Custom Websocket Client

PreviousUsing Nodejs LibraryNextUnreal Kingdoms

Last updated 2 years ago

Create Custom Websocket client to connect with CAYC Exchange Server

For an easier way to use websockets with CAYC Exchange

Requirements

  • Nodejs and NPM installed

  • Nodejs version >= 12

  • Install

Public Usage

You need to import ws library and create a connection with CAYC Exchange, For e.g

const WebSocket = require('ws');
const API_URL = 'https://api.cayc.exchange'

// Public connection
const publicSocket = new WebSocket(`${API_URL}/stream`);

Private Usage

You need to authenticate through the api either using Bearer token or with API key and Secret which you can obtain from

API Expires field just used to define the validity of the connection.

const WebSocket = require('ws');
const API_URL = 'https://api.cayc.exchange'

// Bearer Token
const privateSocket = new WebSocket(`${API_URL}/stream?authorization=${BEARER_TOKEN}`);

// HMAC Authentication
const privateSocket = new WebSocket(`${API_URL}/stream?api-key=${API_KEY}&api-signature=${API_SIGNATURE}&api-expires=${API_EXPIRES}`);

// Bearer Token
privateSocket.send(
	JSON.stringify({
		op: 'auth',
		args: [{
			authorization: BEARER_TOKEN
		}]
	})
);

// HMAC Authentication
privateSocket.send(
	JSON.stringify({
		op: 'auth',
		args: [{
			'api-key': API_KEY,
			'api-signature': API_SIGNATURE,
			'api-expires': API_EXPIRES
		}]
	})
);

For a detailed documentation and to learn how it works with CAYC Network, Please visit

Websocket client library
the guide
the Repository