@brownandroot/api
v0.8.0
Published
TypeScript client for the Brown & Root APIHub data service. Provides read-only access to company data and an LLM chat endpoint powered by Azure AI Foundry.
Readme
@brownandroot/api
TypeScript client for the Brown & Root APIHub data service. Provides read-only access to company data and an LLM chat endpoint powered by Azure AI Foundry.
Installation
npm install @brownandroot/apiSetup
import { ApiHubClient } from '@brownandroot/api'
const client = new ApiHubClient({
baseUrl: 'https://your-apihub-url.com',
apiKey: 'your-api-key',
})Usage
Employees
const employees = await client.getEmployees()
const employee = await client.getEmployee(12345)
const results = await client.searchByName('John')
const results = await client.searchByEmail('[email protected]')
const reports = await client.getBySupervisor(12345)
const chain = await client.getSupervisorChain(12345)
const { jde, employee } = await client.getJdeFromEmail('[email protected]')Business Units
const units = await client.getBusinessUnits()
const unit = await client.getBusinessUnit('BU001')Cost Codes
const codes = await client.getCostcodes()
const code = await client.getCostcode('CC001')Pay Types
const types = await client.getPaytypes()
const type = await client.getPaytype('PT001')Work Orders
const orders = await client.getWorkorders()
const order = await client.getWorkorder('WO001')LLM
// List logs
const logs = await client.getLlmLogs()
// Chat completion
const result = await client.chat({
messages: [{ role: 'user', content: 'Summarize this document...' }],
source: 'my-app',
user: 'jane.doe',
function: 'summarize',
})
console.log(result.message.content)
console.log(result.usage) // { tokensIn, tokensOut, totalTokens }Types
The package exports interfaces for all resource types:
import type {
Employee,
BusinessUnit,
Costcode,
Paytype,
Workorder,
LlmLog,
ChatMessage,
ChatRequest,
ChatResponse,
ApiHubClientOptions,
} from '@brownandroot/api'Error Handling
Methods throw an Error when the API returns a non-OK response. The error message contains the server's error detail or the HTTP status code.
try {
const emp = await client.getEmployee(99999)
} catch (err) {
console.error(err.message) // "Employee not found"
}