Docs
Dashboard
Examples / FormsBeta

Public registry lookup

An agent finds a company in the UK's public company register (Companies House) and opens its page; extract then reads the record into JSON with a schema.

When to use it: You look up records in a public register through its website.

Usesagent.run and agent.stream, then extract with a schema
Needsa model on the API
Sitefind-and-update.company-information.service.gov.uk (public)
Outputoutput/record.json
LanguagesNode and Python

The code

The example as it is in its folder. Both versions do the same job and write the same output/, so one result check covers both.

/** * Public registry lookup: an agent finds a company in the UK's public company register (Companies House), then * extract reads its record into JSON with a schema. * *   npx tsx node/index.ts            (BOXLINE_API_KEY; COMPANY for another company) * * Writes output/record.json. */import { mkdirSync, writeFileSync } from "node:fs";import { join } from "node:path";import { Boxline } from "@boxline/sdk";const out = process.env.OUTPUT_DIR ?? "output";const company = process.env.COMPANY ?? "ARM LIMITED";const REGISTER = "https://find-and-update.company-information.service.gov.uk";const bx = new Boxline();interface CompanyRecord {  companyNumber: string;  name: string;  status: string;  type: string;  incorporated: string;  registeredOffice: string;}// 1. The agent searches the register and opens the company's overview page (it chooses among similar names).const run = await bx.agent.run({  task: `Find the company "${company}" on the UK Companies House register (${REGISTER}): search for it and open its overview page. Reply with the address of that overview page only.`,  maxSteps: 15,});console.log(`Agent run ${run.id} (${run.provider}/${run.model}) · Session: ${run.sessionId}`);for await (const e of bx.agent.stream(run.id)) {  if (e.type === "tool") console.log(`→ ${e.name} ${JSON.stringify(e.input ?? {}).slice(0, 100)}`);  else if (e.type === "done") console.log(`${e.status}: ${e.result ?? e.error}`);}const done = await bx.agent.get(run.id);const page = /https:\/\/find-and-update\.company-information\.service\.gov\.uk\/company\/[A-Z0-9]+/i.exec(done.result ?? "")?.[0];if (!page) throw new Error(`the agent did not find the company's page: ${done.result ?? done.error}`);// 2. extract reads the record on that page into a fixed shape.const { data, usage } = await bx.extract<CompanyRecord>({  url: page,  prompt: "The company record on this page.",  schema: {    type: "object",    properties: {      companyNumber: { type: "string" },      name: { type: "string" },      status: { type: "string" },      type: { type: "string", description: "the company type, e.g. Private limited company" },      incorporated: { type: "string", description: "the incorporation date as YYYY-MM-DD" },      registeredOffice: { type: "string", description: "the registered office address on one line" },    },    required: ["companyNumber", "name", "status", "type", "incorporated", "registeredOffice"],  },});console.log(JSON.stringify(data, null, 2));mkdirSync(out, { recursive: true });writeFileSync(join(out, "record.json"), JSON.stringify(data, null, 2));writeFileSync(join(out, "result.json"), JSON.stringify({ company, page, record: data, agentRuns: [{ id: run.id }], usage: { modelUsd: usage.costUsd } }, null, 2));

Inputs

Environment variables the example reads:

  • COMPANY: the company to look up (default ARM LIMITED).

Run it

Get the examples with git clone https://github.com/Boxline-dev/examples.git and open this one: cd examples/public-registry-lookup. Put your API key in BOXLINE_API_KEY (and BOXLINE_API_URL for another API), then run either version from the example’s folder. Both write to output/ and stop their sessions when they finish.

# Node 18 or newer, in the example's folderexport BOXLINE_API_KEY=…   # your API keynpm install @boxline/sdk tsxnpx tsx node/index.ts

Then check the result, from the same folder: npx tsx check.ts output. It exits with 0 only when the result is right.

What its check proves

check.ts reads what the example wrote and passes only when the result is right, not merely when the example ran.

The record is complete and matches its page; for ARM LIMITED: 02557590, active, incorporated in 1990, Fulbourn Road.

Source

github.com/Boxline-dev/examples/public-registry-lookup on GitHub, with its README.md, check.ts and .env.example. The examples are open source. See all examples.

These docs describe a beta API. Endpoints, fields and SDK methods may change before general availability; breaking changes will be listed in the changelog.