Getting Started
The Dataworks Data SDK (@dataworks-technology/data) lets you authenticate with the Dataworks platform, ingest live athlete metrics, subscribe to real-time data streams, and report errors — all from a single DataClient class.
Installation
npm install @dataworks-technology/data
Or with your preferred package manager:
yarn add @dataworks-technology/data
# or
pnpm add @dataworks-technology/data
# or
bun add @dataworks-technology/data
The package has zero dependencies — everything is bundled and self-contained.
Quick Start
import { DataClient } from "@dataworks-technology/data";
// 1. Create a client with your Dataworks credentials
const dataworks = new DataClient({
cognitoEndpoint: "https://cognito-idp.eu-west-1.amazonaws.com/",
clientId: "your-client-id",
ingestUrl: "https://realtime.dataworks.live",
errorUrl: "https://realtime-error.dataworks.live",
realtimeUrl: "https://event-api.dataworks.live",
apiKey: "optional-appsync-events-api-key", // subscription-only fallback
});
// 2. Authenticate
await dataworks.login("your-username", "your-password");
// 3. Ingest metrics
await dataworks.ingest(
[
{
athleteId: "athlete-1",
metric: "heartrate_calculated",
value: 172,
timestamp: Math.floor(Date.now() / 1000),
},
],
"event-123",
"dataset-456",
);
// 4. Subscribe to real-time updates
// Channel format: dataworks/{datasetDatasourceId}/{eventId}/{metric}
// Use * to subscribe to all metrics first, then narrow to a specific metric channel
const sub = dataworks.subscribe("dataworks/1/1/*", (event) => {
console.log("Received:", event);
});
// Later: close the subscription
sub.close();
What You'll Need
Before using the SDK, you'll need credentials from the Dataworks team:
| Item | Description |
|---|---|
| Username | Your Dataworks developer account username |
| Password | Your Dataworks developer account password |
| Client ID | Cognito app client ID for authentication |
| Ingest URL | API Gateway endpoint for metric ingestion |
| Error URL | API Gateway endpoint for error reporting |
| Realtime URL | AppSync Events API endpoint for subscriptions |
| apiKey (optional) | AppSync Events API key for subscription-only access |
Contact the Dataworks team to get your developer credentials.
If you provide both Cognito credentials (login() + clientId) and apiKey, subscriptions always use Cognito auth. apiKey is only used when Cognito login credentials are not provided.
ESM and CommonJS
The SDK ships as a dual ESM/CJS package. Both import and require work out of the box:
// ESM
import { DataClient } from "@dataworks-technology/data";
// CJS
const { DataClient } = require("@dataworks-technology/data");
TypeScript
Full TypeScript type definitions are included. All types are exported from the package root:
import type {
DataClientConfig,
Metric,
LoginResult,
ErrorReport,
Subscription,
} from "@dataworks-technology/data";
Next Steps
- Demo & User Guide — Download a working demo and run it in 2 minutes
- Authentication — Token lifecycle and error handling
- Ingesting Data — Batching, validation, derived metrics