Register and execute
Install the SDK, register a ruleset, and execute it. About five minutes.
Step 1: Install
npm i @boerules/sdkThe TypeScript package is @boerules/sdk on npm. Python is boerules on PyPI. Java is com.boerules:boerules-sdk on Maven Central.
Step 2: Get a Dev key
Create a key in the console under Keys. Set it as BOE_API_KEY in your shell. The SDK reads it on startup.
export BOE_API_KEY="[YOUR DEV KEY]"Step 3: Register a ruleset
A ruleset has an id, an engine mode and a list of rules. This one scores income. Each thousand of income adds one point.
Step 4 runs it. Both steps share one file.
import { createBOE } from '@boerules/sdk';
const boe = createBOE(); // reads BOE_API_KEY
const ruleset = await boe.register({
id: 'credit-score',
mode: 'scoring',
rules: [{
id: 'income-score',
inputs: [{ name: 'a', type: 'Applicant' }],
then: { score: ['multiply', 0.001, '$a.income'] },
}],
});
const decision = await boe.execute(
ruleset.shortCode,
{ Applicant: [{ income: 82000 }] },
{ version: ruleset.version },
);Step 4: Execute
Pass the short code, your facts, and the version. Facts are grouped by type, so Applicant holds a list of applicants. Pinning the version gives you the same answer every time.
What you get back
Execute returns one object. These are its fields.
| Field | Meaning |
|---|---|
| executionId | The id of this decision. Look it up later in the decision log. |
| ruleset | The ruleset that ran. |
| result | The decision itself. Its shape depends on the engine mode. |
| engineMode | The engine that produced it, such as scoring. |
| shortCode | The short name you call the ruleset by. |
| version | The version that answered. |
| executionTimeMs | Time the engine spent on the rules. |
| totalTimeMs | Time for the whole call, including routing. |
| lineage optional | Which rules fired and why. Pass lineage: true to include it. |
Register response
| Field | Meaning |
|---|---|
| rulesetId | The permanent id of the ruleset. |
| shortCode | The short name to pass to execute. |
| engineMode | The engine the ruleset is locked to. |
| version | The version this register call saved. |
| created | True when the call saved a new version. False when it matched the stored one. |
| executeUrl | The address on execute.boerules.com that serves this ruleset. |
Python names the same fields in snake case, such as short_code. Java reads them through accessors, such as shortCode().
Next: batch and the decision log
Run many decisions at once, then read them back.
submitBatchSend many fact sets in one call.pollBatchCheck progress and fetch results.listExecutionsPage through past decisions.getExecutionOpen one decision by its id.
The batch and decision log page is planned.
Errors you may meet
| Error | In plain words |
|---|---|
| BOEFactValidationError | The facts you sent do not match what the ruleset expects. The error lists each field to fix. |
| BOERulesetNotLiveInEnvironmentError | The ruleset exists and has no live version in the environment your key belongs to. Promote a version there first. |