> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tilion.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Create a browser session, fetch a page, and close the session.

Set your API key in the terminal where you will run the example:

```bash theme={"dark"}
export TILION_API_KEY="ph_live_..."
```

The Python example requires `requests` (`pip install requests`). The Node.js example uses built-in `fetch` in Node 20 or later. The curl example requires `jq` and `uuidgen`.

## Fetch your first page

Save the Python example as `quickstart.py` or the Node.js example as `quickstart.mjs`, then run it with `python quickstart.py` or `node quickstart.mjs`.

```python Python theme={"dark"}
import os
import uuid
import requests

base = "https://back.tilion.dev"
headers = {"Authorization": f"Bearer {os.environ['TILION_API_KEY']}"}
response = requests.post(
    f"{base}/v1/session",
    headers={**headers, "Idempotency-Key": str(uuid.uuid4())},
    json={}, timeout=200,
)
response.raise_for_status()
session_id = response.json()["session_id"]

try:
    response = requests.post(
        f"{base}/v1/fetch", headers=headers,
        json={"session_id": session_id, "url": "https://example.com/"},
        timeout=70,
    )
    response.raise_for_status()
    page = response.json()
    if not page.get("content_ok"):
        raise RuntimeError(f"Page not delivered: {page}")
    print(page["text"])
finally:
    response = requests.delete(
        f"{base}/v1/session/{session_id}", headers=headers, timeout=30
    )
    response.raise_for_status()
```

```javascript Node.js theme={"dark"}
import { randomUUID } from "node:crypto";

const base = "https://back.tilion.dev";
const headers = {
  Authorization: `Bearer ${process.env.TILION_API_KEY}`,
  "Content-Type": "application/json",
};
async function request(path, method, body, extraHeaders = {}) {
  const response = await fetch(`${base}${path}`, {
    method, headers: { ...headers, ...extraHeaders },
    body: body === undefined ? undefined : JSON.stringify(body),
    signal: AbortSignal.timeout(200_000),
  });
  if (!response.ok) throw new Error(`${response.status}: ${await response.text()}`);
  return response.status === 204 ? null : response.json();
}
const session = await request("/v1/session", "POST", {}, {
  "Idempotency-Key": randomUUID(),
});
try {
  const page = await request("/v1/fetch", "POST", {
    session_id: session.session_id, url: "https://example.com/",
  });
  if (!page.content_ok) throw new Error(JSON.stringify(page));
  console.log(page.text);
} finally {
  await request(`/v1/session/${session.session_id}`, "DELETE");
}
```

```bash curl theme={"dark"}
# Run as a bash script. Requires jq and uuidgen.
set -euo pipefail
BASE="https://back.tilion.dev"
CREATE_ID=$(uuidgen)
SESSION=$(curl --fail-with-body --silent --show-error "$BASE/v1/session" \
  -H "Authorization: Bearer $TILION_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $CREATE_ID" -d '{}')
SESSION_ID=$(printf '%s' "$SESSION" | jq -er '.session_id')
cleanup() {
  curl --fail-with-body --silent --show-error -X DELETE \
    "$BASE/v1/session/$SESSION_ID" \
    -H "Authorization: Bearer $TILION_API_KEY"
}
trap cleanup EXIT
curl --fail-with-body --silent --show-error "$BASE/v1/fetch" \
  -H "Authorization: Bearer $TILION_API_KEY" \
  -H "Content-Type: application/json" \
  -d "$(jq -n --arg sid "$SESSION_ID" \
    '{session_id: $sid, url: "https://example.com/"}')" \
  | jq -er 'if .content_ok then .text else error(tostring) end'
```

The script prints the page text, starting with “Example Domain”. Session creation returns `201`; deletion returns `204` with no body.

> [!NOTE]
>
> Browser time is metered while the session exists. The `finally` block closes it even if fetching the page fails. The shell example uses an exit trap for the same purpose.

Use [Create a browser](https://docs.tilion.dev/guides/create-browser.md) to configure regions and proxy exits, or [Read a protected page](https://docs.tilion.dev/guides/read-page.md) for asynchronous requests and job polling.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.