RELAYTO logo

RELAYTO JavaScript SDK and CLI (npm relayto)

Install the official RELAYTO SDK and CLI from npm to search and read the pages, hubs and documents of any RELAYTO site. TypeScript, no API key, no dependencies.

relayto is RELAYTO's official JavaScript and TypeScript SDK and command-line tool for the public site API. It reads the pages, hubs and documents of any site published with RELAYTO. No API key, no runtime dependencies.

Install

npm install relayto

Or run the CLI without installing:

npx relayto --help

CLI

npx relayto search "open enrollment" --site benefits.relayto.com
npx relayto hubs --site benefits.relayto.com
npx relayto get https://benefits.relayto.com/e/what-is-open-enrollment-4uoe8tjxhumq6
CommandWhat it returns
relayto search <query>pages, hubs and documents matching the words, best first
relayto hubsthe site's hubs
relayto pagesthe site's own pages
relayto contentsthe documents in the site's library
relayto get <url-or-slug>a document or page as Markdown; for a hub, its items
relayto export <slug>…the Markdown of up to 10 documents
relayto sitethe site's name, description, API, OpenAPI, llms.txt and MCP addresses

SDK

import { RelaytoSite } from 'relayto';

const site = new RelaytoSite('benefits.relayto.com');

const results = await site.search('wellness', { kind: 'content', limit: 5 });
for (const item of results.data) console.log(item.title, item.url);

for await (const hub of site.allHubs()) console.log(hub.title, hub.slug);

const doc = await site.getContent('what-is-open-enrollment-4uoe8tjxhumq6');

Typed errors (NotFoundError, NotPublicError, rate limits) and automatic retry on 429 are built in. The full reference is in the package README.

Need to create or change content?

The SDK reads published sites. To publish, organize and measure content in your own workspace from an AI agent, use the RELAYTO MCP server.

Links