| Ocalt Query Language
Pricing Dashboard ocalt.com v1.0

OQL JS SDK

A thin JavaScript client for calling OQL from browsers and Node.js. No build step required.

CDN

<script src="https://cdn.ocalt.com/oql-sdk.min.js"></script>

npm

npm install @ocalt/oql-sdk

Initialise

Authenticate with your Ocalt credentials — the same username and password as accounts.ocalt.com.

import OQL from '@ocalt/oql-sdk'; const oql = new OQL({ username: 'your_ocalt_username', password: 'your_ocalt_password', endpoint: 'https://oql.ocalt.com/v1/query' /* optional — this is the default */ });

Execute a query

const result = await oql.run('EMIT "Hello"'); console.log(result); // "Hello"

Query with request context (Site Mode simulation)

const result = await oql.run( 'IF !REQUEST(method) IS IDENTICAL TO "GET" OPEN NEST EMIT "get" CLOSE NEST', { request: { method: 'GET', path: '/api/test' } } );

Real-time stream subscription

const channel = oql.subscribe('my-channel', (message) => { console.log('Received:', message); }); // Unsubscribe when done channel.close();

Async mode with poll

const job = await oql.runAsync('SLEEP "5s" AFTER EMIT "Done"'); const result = await oql.poll(job.id); console.log(result); // "Done"

Error handling

try { await oql.run('FETCH "https://bad-url" SET ?r'); } catch (e) { console.error(e.code); // "NetUnreachable" console.error(e.message); }