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 optionsconst client = await SurfClient.discover('https://shop.example.com', { auth: 'sk-my-token', discoverTimeout: 5000,})ย // Inspect the manifestconsole.log(client.manifest.name) // 'My Store'console.log(client.manifest.version) // '1.0.0'console.log(client.manifest.checksum) // 'a1b2c3...'ย // List all commandsconst cmds = client.commands()// => { search: { description: '...', params: {...} }, 'cart.add': {...} }ย // Get a specific commandconst cmd = client.command('search')// => { description: '...', params: {...}, hints: {...} }ย // Create from existing manifest (skip discovery)const client2 = SurfClient.fromManifest(manifest, { baseUrl: 'https://...' })