Expand AI logo
DocsDocs
API Reference
Login

Documentation

Start

WelcomeQuickstartCLI & AgentsAPI Reference

Concepts

Progressive DisclosureState JSONAppendixCitationsSearch & HighlightingSpatial MarkdownInclude OptionsBatched Fetch

Product

FetchMCPCLI

SDKs

SDKsTypeScript SDKPython SDK

TypeScript SDK

Official TypeScript client for expand.ai.

Use the TypeScript SDK when application code needs Fetch.

Installation

npm install @expandai/sdk
pnpm add @expandai/sdk
bun add @expandai/sdk

Fetch Markdown

fetch() returns Markdown.

import { ExpandClient } from '@expandai/sdk'

const client = new ExpandClient({ apiKey: process.env.EXPAND_API_KEY })

const markdown = await client.fetch({ url: 'https://example.com' })
console.log(markdown)

JSON Mode

Use fetchJson() when you need a structured response.

const result = await client.fetchJson({ url: 'https://example.com' })
console.log(result.markdown)

Search

const snippets = await client.fetch({
  url: 'https://example.com',
  search: { query: 'authentication' },
})

console.log(snippets)

Batched Fetch

const run = await client.batched({
  urls: ['https://example.com', 'https://example.com/about'],
})

const status = await client.getBatched(run.id)
console.log(status.results)
PreviousSDKs
NextPython SDK

On This Page

InstallationFetch MarkdownJSON ModeSearchBatched Fetch