Client SDK

Discovery

Discover Surf-enabled websites

Client SDK โ€” Discovery#

The @surfjs/client package provides a full-featured SDK for interacting with any Surf-enabled website.

typescript
import { SurfClient } from '@surfjs/client'
ย 
// Discover a Surf-enabled site (fetches manifest automatically)
const client = await SurfClient.discover('https://shop.example.com')
ย 
// Or with options
const client = await SurfClient.discover('https://shop.example.com', {
auth: 'sk-my-token',
discoverTimeout: 5000,
})
ย 
// Inspect the manifest
console.log(client.manifest.name) // 'My Store'
console.log(client.manifest.version) // '1.0.0'
console.log(client.manifest.checksum) // 'a1b2c3...'
ย 
// List all commands
const cmds = client.commands()
// => { search: { description: '...', params: {...} }, 'cart.add': {...} }
ย 
// Get a specific command
const cmd = client.command('search')
// => { description: '...', params: {...}, hints: {...} }
ย 
// Create from existing manifest (skip discovery)
const client2 = SurfClient.fromManifest(manifest, { baseUrl: 'https://...' })