Skip to main content

BRX Client

The BRX Client is the primary way to interact with the BRX platform programmatically. It provides methods for fetching, creating, updating, and executing BRKs.

Overview

The BRX Client is available in multiple languages, with the official Node.js SDK (brx-node) being the most feature-complete. The client handles:
  • Authentication with the BRX platform
  • Fetching BRK schemas
  • Creating and updating BRKs
  • Executing BRKs and handling results
  • Managing WebSocket connections for streaming results

Node.js SDK

Installation

Initialization

To use the BRX Client, you need to initialize it with your API key:

Core Methods

Fetching BRKs

The get method fetches a BRK schema by its ID:

Creating BRKs

The create method creates a new BRK:

Updating BRKs

The update method updates an existing BRK:

Executing BRKs

The run method executes a BRK:

Using Callbacks

The run method also supports callbacks for handling streaming results:

Advanced Usage

WebSocket Connections

The BRX Client uses WebSockets for real-time communication with the BRX platform. This allows for streaming results as they become available, rather than waiting for the entire execution to complete.

Error Handling

The BRX Client throws errors for various failure conditions:
Common errors include:
  • Authentication failures
  • Invalid BRK schemas
  • Execution errors
  • Network issues

Best Practices

  • Reuse the BRX Client: Create a single instance of the BRX Client and reuse it for multiple operations
  • Handle errors gracefully: Implement proper error handling to provide a good user experience
  • Use callbacks for streaming: When executing long-running BRKs, use callbacks to provide real-time feedback
  • Validate inputs: Ensure that input values match the expected types and formats
  • Manage API keys securely: Store API keys securely and never expose them in client-side code