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.

@spfunctions/sdk is published as an alpha npm package. The SDK is a typed wrapper over existing SimpleFunctions HTTP/Data API objects. It does not create a second object model and it does not shell out to the CLI.
npm install @spfunctions/sdk@0.1.0-alpha.0
import { SimpleFunctions } from "@spfunctions/sdk"

const sf = new SimpleFunctions({
  apiKey: process.env.SF_API_KEY,
  baseUrl: process.env.SF_API_URL,
})
Use the SDK from server-side TypeScript, trusted local scripts, backend jobs, or agent harnesses. Do not expose long-lived SF_API_KEY values in browser bundles.

Read-first surfaces

await sf.world.get()
await sf.world.delta({ since: "1h" })
await sf.markets.discover({ limit: 5 })
await sf.markets.search({ query: "Fed CPI", limit: 10 })
await sf.markets.get("KXRECESSION-26DEC31")
await sf.markets.history("KXRECESSION-26DEC31")
await sf.query.ask({ q: "What are markets saying about recession risk?" })
await sf.econ.query({ q: "unemployment rate", mode: "raw" })
await sf.gov.query({ q: "SAVE Act", mode: "raw" })
await sf.manifest.list()
await sf.manifest.get("world.read")
These calls are read-only and map to sideEffect: none in the draft contract map. sf.manifest.* reads the strict SDK/Agent contract manifest from /api/contracts/tools. It uses canonical dotted names such as world.read; broad hosted tool names from /api/tools, such as get_world_state, are compatibility inventory names and are not SDK contract truth. The SDK is API-key-first. Manifest inspection is the no-key bootstrap path. Data and research calls are preflighted against the strict contract metadata; if a tool has costEffect or access.anonymousAllowed: false, the SDK throws MissingApiKeyError before the live request when no API key is configured.

Authenticated reads

await sf.theses.list()
await sf.theses.get("thesis-id")
await sf.portfolio.state()
await sf.portfolio.ticks.list({ limit: 5, envelope: true })
await sf.portfolio.trades.list({ limit: 5, envelope: true })
await sf.intents.list({ active: true })
await sf.watchlists.list()
await sf.alerts.list()
Authenticated reads require SF_API_KEY or an explicit apiKey.

Not included

The SDK does not implement live trading, direct venue order placement, daemon mode, hosted long-running agents, MCP expansion, or a Python SDK rewrite. The SDK is also not the Agent SDK. @spfunctions/agent is published as an alpha package. v0 is a governed direct tool runner, and v1 is an alpha model-loop runtime. The current sf agent --tool CLI path is a command-line wrapper around direct-tool semantics, not the Agent SDK itself. Private Agent v0 consumers should use the SDK client explicitly:
import { SimpleFunctions } from "@spfunctions/sdk"
import { SimpleFunctionsAgent } from "@spfunctions/agent"

const sf = new SimpleFunctions({
  apiKey: process.env.SF_API_KEY,
  baseUrl: "https://simplefunctions.dev",
})

const agent = new SimpleFunctionsAgent({
  client: sf,
  policy: { maxSideEffect: "none", maxCostEffect: "api_cost" },
})

await agent.tools.world.read({})
agent.tools.* helpers are typed wrappers over canonical dotted tools. They do not bypass policy, use /api/tools, or shell out to the CLI.

Alpha boundaries

The alpha package exposes the governed strict subset first. Deferred or hallucination-risk surfaces such as events.*, market.related, auth.status, investigations.create, intents.propose, webhooks.create, and live_trade stay out of the SDK/Agent default surface until they have explicit contract, auth, side-effect, cost, and policy decisions.