Skip to main content

WebSocket API Integration

For developers and advanced users, StreamSlate offers a powerful WebSocket and REST API to build custom integrations and automate your workflow.

1. API Overview

StreamSlate exposes a local WebSocket server for real-time event subscriptions and a REST API for command execution.

  • WebSocket Endpoint: ws://localhost:4321/ws
  • REST API Base URL: http://localhost:4321/api/v1

2. WebSocket Events

Subscribe to real-time events from StreamSlate to react to changes in the application state. Events are sent as JSON objects.

Example: Page Change Event


 
{
  "event": "pageChange",
  "data": {
    "currentPage": 5,
    "totalPages": 10
  }
}
 
          

Common Events:

  • pageChange: Triggered when the current page changes.
  • annotationAdded: Fired when a new annotation is created.
  • annotationRemoved: Fired when an annotation is removed.
  • toolChange: Occurs when the active annotation tool changes.

3. REST API Endpoints

Control StreamSlate programmatically using our REST API. All endpoints return JSON responses.

Change Page

POST /api/v1/page

Request Body:


 
{
  "pageNumber": 3
}
 
          

Toggle Annotation Visibility

POST /api/v1/annotations/toggle

Request Body:


 
{
  "visible": false
}
 
          

4. Authentication

Currently, the local API does not require authentication for ease of integration. For production environments or public-facing applications, consider implementing your own authentication layer if exposing the API.