> ## 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.

# API quickstart

> Call SimpleFunctions over HTTP for market search, world state, market inspection, and authenticated portfolio reads.

Use the HTTP API when a service, notebook, dashboard, or custom runtime needs stable JSON contracts and does not want to shell out to `sf`.

## 1. Base URL

```text theme={null}
https://simplefunctions.dev
```

## 2. Public reads

```bash theme={null}
curl "https://simplefunctions.dev/api/public/query?q=Fed%20rate%20cut&limit=3"
curl "https://simplefunctions.dev/api/agent/world?format=json"
curl "https://simplefunctions.dev/api/agent/world/delta?since=1h&format=json"
curl "https://simplefunctions.dev/api/agent/inspect/KXRATECUT-26DEC31"
```

Start broad with query or world state, then inspect one ticker before acting on it.

## 3. Authenticated reads

```bash theme={null}
export SF_API_KEY="sf_..."

curl -H "Authorization: Bearer $SF_API_KEY" \
  "https://simplefunctions.dev/api/portfolio/state"

curl -H "Authorization: Bearer $SF_API_KEY" \
  "https://simplefunctions.dev/api/intents?limit=10"
```

Authenticated surfaces are scoped to the key owner. Do not pass arbitrary user ids from clients.

## 4. Discover canonical SDK and Agent tools

```bash theme={null}
curl "https://simplefunctions.dev/api/contracts/tools"
```

Use `/api/contracts/tools` for SDK and Agent SDK canonical tool names, side-effect classes, cost classes, replay metadata, and auth requirements. `/api/tools` is broader compatibility inventory.

## 5. Minimal service wrapper

```ts theme={null}
async function sfGet<T>(path: string, apiKey?: string): Promise<T> {
  const res = await fetch(`https://simplefunctions.dev${path}`, {
    headers: apiKey ? { Authorization: `Bearer ${apiKey}` } : {},
  })
  const body = await res.json()
  if (!res.ok) throw new Error(body?.error?.message ?? `SimpleFunctions HTTP ${res.status}`)
  return body as T
}

const world = await sfGet('/api/agent/world?format=json')
const portfolio = await sfGet('/api/portfolio/state', process.env.SF_API_KEY)
```

## Next steps

<CardGroup cols={2}>
  <Card title="REST API overview" href="/api-reference/overview">
    Endpoint groups and response style.
  </Card>

  <Card title="Direct API access" href="/build/direct-api-access">
    Curl, TypeScript, Python, and service patterns.
  </Card>

  <Card title="SDK quickstart" href="/start/sdk-quickstart">
    Use typed TypeScript wrappers.
  </Card>

  <Card title="Contract tools" href="/api-reference/contract-tools">
    Canonical SDK and Agent manifest.
  </Card>
</CardGroup>
