Skip to content
MACHHUB MACHHUB MACHHUB
Contribute to this page

API cheatsheet

A quick reference to the whole @machhub-dev/sdk-ts surface. Follow the links for details and examples.

import { SDK } from '@machhub-dev/sdk-ts';
const sdk = new SDK();
await sdk.Initialize(/* config? */);

See Install & initialize.

NamespaceKey methodsGuide
sdk.collection(name)getAll, getOne, create, update, delete, filter, orFilter, sort, offset, limit, first, count, expand, fields, filterInArrayCollections
sdk.authlogin, logout, getCurrentUser, getJWTData, validateCurrentUser, validateJWTAuthentication
sdk.auth (authz)checkPermission, checkAction, getPermissions, getGroups, createGroup, addUserToGroup, getUsers, createUserAuthorization
sdk.taggetAllTags, publish, subscribe, unsubscribe, getValueRealtime
sdk.historianquery, getHistoricalDataAsCSVHistorian
sdk.processesexecute, getProcesses, changeTriggersProcesses
// Query
await sdk.collection('products')
.filter('inStock', '=', true)
.sort('price', 'asc')
.offset(0).limit(25)
.getAll();
// Auth
await sdk.auth.login('username', 'password');
const me = await sdk.auth.getCurrentUser();
// Realtime
await sdk.tag.subscribe('line1/+/temperature', (v, topic) => console.log(topic, v));
await sdk.tag.publish('line1/oven/temperature', 72.4);
// Historian
await sdk.historian.query(`SELECT math::mean(value) AS avg FROM historian WHERE topic = 'line1/oven/temperature'`);
// Process
await sdk.processes.execute('computeAverage', { window: '1h' });

application_id.collection:record_id — e.g. myapp.products:PROD-001. Updates and deletes need the full id; relations are written as { Table, ID }. See RecordID.