Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.simplefunctions.dev/llms.txt

Use this file to discover all available pages before exploring further.

Use @spfunctions/sdk when a TypeScript service, notebook, dashboard, or agent harness owns the application code.

1. Install

npm init -y
npm install @spfunctions/sdk@1.0.0
Use Node 18 or newer. Use the stable package version.

2. Create the client

import { SimpleFunctions } from "@spfunctions/sdk"

const sf = new SimpleFunctions({
  baseUrl: "https://simplefunctions.dev",
  apiKey: process.env.SF_API_KEY,
})
Do not expose long-lived API keys in browser bundles.

3. Inspect the manifest without a key

const noKey = new SimpleFunctions({ baseUrl: "https://simplefunctions.dev" })

const manifest = await noKey.manifest.list()
const world = await noKey.manifest.get("world.read")
const legacy = await noKey.manifest.get("get_world_state")

console.log(manifest.schemaVersion)
console.log(world?.name)
console.log(legacy) // null
The SDK uses canonical dotted names from /api/contracts/tools.

4. Read market context

const worldState = await sf.world.get()
const delta = await sf.world.delta({ since: "1h" })

const screen = await sf.intelligence.screen({
  venue: "kalshi",
  volMin: 100,
  sort: "volume",
  order: "desc",
  limit: 10,
  nextActions: false,
})

const ticker = screen.markets[0]?.ticker
const inspected = ticker ? await sf.markets.get(ticker) : null

5. Read portfolio and runtime state

const portfolio = await sf.portfolio.state()
const runtime = await sf.runtime.status()

console.log(portfolio?.openPositionCount)
console.log(runtime.usable.length)

6. Guard execution explicitly

const result = await sf.execution.place({
  ticker: "KXFED-27APR-T3.50",
  action: "buy",
  direction: "yes",
  quantity: 1,
  limitPrice: 32,
  rationale: "operator-approved test order",
  runtime: { mode: "auto", startIfNeeded: true },
})

const polyResult = await sf.execution.place({
  venue: "polymarket",
  tokenId: "POLYMARKET_CLOB_TOKEN_ID",
  action: "buy",
  quantity: 1,
  limitPrice: 32,
  rationale: "operator-approved test order",
  runtime: { mode: "auto", startIfNeeded: true },
})
execution.place supports Kalshi and Polymarket through the runtime-backed intent path. It checks runtime candidates and starts or wakes a usable runtime when allowed before creating the intent. Polymarket orders require a CLOB token id and explicit limit price. Use small limits, explicit rationale, and your own application-level guardrails.

Next steps

SDK

Full SDK surface.

SDK market research cookbook

Build a read-only research loop.

Execution guardrails cookbook

Runtime and order safety pattern.

Agent SDK quickstart

Add a model loop and policy hooks.