Skip to main content

Overview

Royalti.io provides real-time WebSocket events so your application can receive instant updates about file processing status. Instead of polling the job status endpoint, you can subscribe to events and get immediate notifications when processing starts, progresses, completes, or fails.

Why Use WebSocket Events?

  • Instant Updates: Receive status changes immediately without polling
  • Progress Tracking: Get granular progress updates (every 10%) during processing
  • User-Scoped: Events are sent only to the user who uploaded the file
  • Efficient: Reduces API calls and improves user experience
  • Reliable: Built on Socket.io with automatic reconnection

Prerequisites

Authentication

You need a valid JWT access token to connect to the WebSocket server. Use the same token you use for REST API calls.

Socket.io Client

Install the Socket.io client for your platform:

Quick Start

1

Connect to WebSocket

Establish a WebSocket connection with your JWT token:
Node.js
2

Subscribe to File Processing Events

Listen for file processing status updates:
Node.js
3

Upload a File

Upload a royalty file - events will automatically be sent to your WebSocket connection:
Node.js

Event Types

Royalti.io emits four types of file processing events:

Event Payload Structure

All events share a common payload structure:

Progress Stages

Progress updates are emitted at key processing stages. The exact stages depend on the file type:

CSV/Text Files

ZIP Files

Excel Files


Code Examples

Complete Node.js Example

Node.js

Python Example

Python

React Hook Example

React

Best Practices

Error Handling

Always handle connection errors and implement reconnection logic:
Node.js

Token Refresh

Update your token when it expires without losing the connection:
Node.js

Cleanup

Always disconnect when your component unmounts or user logs out:
Node.js

Combining with Notifications

WebSocket events provide real-time progress, while the notification system provides persistent records. Use both for a complete solution:
Node.js

Troubleshooting

Cause: Your JWT token is invalid or expired.Solution: Ensure you’re using a valid access token. If using refresh tokens, exchange for a new access token before connecting.
Cause: WebSocket connection may have dropped or file was uploaded by a different user.Solution:
  1. Verify your WebSocket is connected (socket.connected)
  2. Events are user-scoped - only the uploader receives them
  3. Check that you’re listening to the correct event names
Cause: Multiple WebSocket connections or event handlers registered.Solution: Ensure you only create one socket connection per session and clean up event handlers when disconnecting.
Cause: File processing completed very quickly (small file) or progress events are being batched.Solution: This is normal for small files. For larger files, you should see intermediate progress updates.

API Reference

For REST API endpoints used with file uploads, see:

Support

If you encounter issues with WebSocket events: