@realforce-software/api-client
v0.0.27
Published
Auto-generated TypeScript client SDK for the Realforce API
Readme
Realforce API - TypeScript SDK
TypeScript client SDK for the Realforce API.
Version: 0.0.27
Installation
npm install @realforce-software/api-clientAuthentication
Use a Realforce Personal Access Token (PAT). Generate one in the Realforce dashboard. Send it as a Bearer token
in the Authorization header.
import axios from 'axios';
import { RealforceApiClient } from '@realforce-software/api-client';
const http = axios.create({
headers: { Authorization: 'Bearer rfp_xxxxxxxxxxxxxxxx' }
});
const client = new RealforceApiClient('https://api.realforce.com', http);Workspace ID
Most endpoints are scoped to a workspace. The generated client surfaces this as
an x_Workspace_ID parameter (string GUID) on each method — pass the workspace
your token has access to on every call:
const workspaceId = '00000000-0000-0000-0000-000000000000';
const agent = await client.getAgent(agentId, workspaceId);Quick Start
import axios from 'axios';
import { RealforceApiClient } from '@realforce-software/api-client';
const http = axios.create({
headers: { Authorization: 'Bearer rfp_xxxxxxxxxxxxxxxx' }
});
const client = new RealforceApiClient('https://api.realforce.com', http);
const workspaceId = '...';
const agents = await client.queryAgents(workspaceId, {});Error Handling
The SDK throws ApiException for non-2xx responses, surfacing the status code
and parsed body:
try {
const result = await client.getAgent(agentId, workspaceId);
} catch (error: any) {
if (error.status) {
console.error(`HTTP ${error.status}:`, error.response);
} else if (error.request) {
console.error('No response received:', error.request);
} else {
console.error('Request error:', error.message);
}
}Custom Axios Instance
The constructor's second argument accepts any pre-configured AxiosInstance,
so you can attach interceptors, set timeouts, retry, etc.:
import axios from 'axios';
import { RealforceApiClient } from '@realforce-software/api-client';
const http = axios.create({
timeout: 30000,
headers: { Authorization: `Bearer ${token}` }
});
const client = new RealforceApiClient('https://api.realforce.com', http);Requirements
- Node.js 16+ or a modern browser
- axios ^1.6.0
Support
- Please contact the Realforce support team.
