Authentication
All websocket API calls require authentication prior to invoking functions.
Websocket Authentication
Authentication Method
Method:
authenticateParameters:
Parameter
Type
Response
{ success: boolean, error: string, count: number }Auth JS example (Node.js) Requires:
npm i @microsoft/signalr// Import the signalr library for backend connection
const signalR = require("@microsoft/signalr");
// Establist the connection object
const connection = new signalR.HubConnectionBuilder()
.withUrl("https://api.sonorancad.com/apiWsHub", {
transport: signalR.HttpTransportType.WebSockets,
skipNegotiation: true,
})
.withAutomaticReconnect()
.build();
// Start the WSS connection
await connection.start();
// Replace community ID and API key
const auth = await connection.invoke("authenticate", "yourCommunityId", "yourApiKey");
if (!auth?.success) {
throw new Error(`Authentication failed: ${auth?.error || "unknown error"}`);
}Last updated
Was this helpful?

