# Turn a website into an API

> Describe what you need from a site; Scribe builds the API, tests it, and gives you REST and MCP access.

Source: https://usewrit.app/docs/website-to-api/

Use this when you need data from a website, or an action on it, and the site offers no API you can
use. You write one sentence about the result you want. Writ builds the functions, proves each one on
the live site, and saves them as an API you can call from code, from your AI assistant or on a schedule.

## Build an API in the app

-

1. **Open the Website to API form**

In the Writ app, open **Create**, pick **Turn a website into an API** and click **Open in Scribe**. You can also open **Scribe** from the
sidebar (⌘J) and choose the starter **Turn a website into an API**.

In Writ Desktop, open **Create** and pick **Turn a website into an API**,
or use the **Create an API for a site** door on **Home**. Scribe needs an
AI model: add your own key in **Settings → AI Provider**, or link a Writ Cloud account
and use its AI.

-

2. **Describe the API**

Fill in **Website** (for example `https://example.com`) and **What the API should do**, in plain words, up to 1,500 characters. If the data is
behind a login, pick a persona in **Sign in as**. Leave it empty for public pages.

-

3. **Click Build the API**

Scribe first looks for something that already does the job: one of your own APIs for the same site,
or a [ready-made API](https://usewrit.app/docs/marketplace). If one fits, it offers it and you
choose. Otherwise it builds. **Describe something else instead** takes you back to a
blank Scribe conversation.

-

4. **Watch Scribe build it**

Scribe opens a real browser on the site and uses it the way a person would. It finds how the site
serves the data: often a request the page sends in the background, otherwise the page itself. It
writes one function per thing you asked for, then calls each function on two different inputs to
check that it returns real data. The panel shows each step as it happens.

-

5. **Answer when it asks**

Scribe stops and asks when it needs you: a persona for a sign-in, a verification code, a CAPTCHA to
solve in the live browser, or a choice between options. While it waits, the **Scribe** button in the sidebar shows **Needs you**. See [Scribe, the assistant](https://usewrit.app/docs/scribe) for every kind of question.

-

6. **Open your API**

When the build ends, **Your result is ready** links to the new API. It is listed under **APIs**, with one entry per function on its **Functions** tab. If some
functions could not be proven, the panel says **Partly built** and lists them: ask
Scribe to continue, or add them later.

Next, try each function and publish the endpoint: [Test and edit an API](https://usewrit.app/docs/functions).

## Write a request Scribe can build

Name the inputs a caller will change, the fields you want back, and each separate action. Scribe turns
each action into its own function and each “let me choose” into an input.

| Clear request | Too vague |
| --- | --- |
| “Search apartments for rent by city and maximum price. Return title, price, address, number of rooms and link. Let me choose how many results.” | “Get the apartments.” |
| “List my orders with date, total and status. Add a second function that returns the items of one order by its order number.” | “Make an API for my account.” |
| “Post a message to a channel. Inputs: channel name and text. Return the link to the new message.” | “Automate this site.” |

- Give the page where the data lives when you know it, not only the home page.
- Say when a function changes something on the site (posts, submits, buys), so Scribe tests it with care.
- Ask for one site per API. For a second site, start a second build.

## Logins and sites that refuse Writ

### Sites behind a login

Pick a persona in **Sign in as**. A persona holds the login for one site, and Writ signs in
with it on every run. If you have none, Scribe offers to create one while it builds; you type the login
into a form, never into the chat. See [Sign-ins and secrets](https://usewrit.app/docs/personas).

> **limit:** Logins kept on Writ Cloud need the Starter plan or higher. On the Free plan, build with Writ Desktop: it signs in from your own computer, where logins are free and unlimited. Writ runs on your own accounts, with your own credentials and data, on sites you are authorized to use.

### When a site refuses Writ’s servers

Some sites turn away connections from data centers. When that happens, the build stops and Scribe says
so, then lists what gets past it on your account, in this order: **Upgrade to** the plan
that includes residential connections (recommended), **Do it from your computer with Writ Desktop** (free on every plan), **Buy credits**, or **Try from Writ’s servers anyway**.
Details and prices: [Blocks, CAPTCHAs and hand-offs](https://usewrit.app/docs/bot-walls).

## Add or fix a function later

An API is never final. On the API’s page, under its name, click **Missing a function? Tell Scribe →**. Scribe asks what the new function should do, builds it, tests it on the live
site and adds it to the same API, next to the functions you already have.

To change a function that returns the wrong data, open Scribe and say what is wrong, for example “The
price field in search_listings is empty since yesterday.” Scribe reuses your API instead of building a
new one. How Writ notices and repairs breaks on its own: [Keep an API working](https://usewrit.app/docs/keep-it-working).

## Build from your assistant or your code

### From your AI assistant

Connect Writ Cloud to your assistant over MCP ([Connect an AI assistant](https://usewrit.app/docs/mcp)), then ask, for example: “Turn news.ycombinator.com into an API that returns the top stories.” Your
assistant calls `writ_website_to_api`, and Writ opens a cloud browser tied to that build. Your
assistant drives it: it uses the site, reads the requests the page makes, defines the functions, tests
each one on two inputs and saves.

Your assistant’s own model does the thinking, so a build from your assistant spends your assistant’s
tokens. It does not count against your Writ AI builds, and its browser is not charged in credits. A
build that Writ’s AI started and could not finish can also be handed to your assistant: see [Continue a build](https://usewrit.app/docs/mcp#continue-a-build).

> **tip:** The Writ Desktop MCP server offers the same tool, plus Writ’s own builder, on your computer and for free. See Writ Desktop.

### From the REST API

A program cannot drive a browser turn by turn, so over REST Writ’s own AI builds the API. You start a
build, then check on it until it ends.

POST `https://api.usewrit.app/api/v1/website-to-api` 1 Writ AI build · 1,500 credits past the plan’s count · deep 6,000 credits wt_ key · workflows:write

Body

- `url` (string, required): The site to start on, for example https://example.com.
- `goal` (string, required): What the API should return or do, in plain words. Up to 5,000 characters.
- `persona_id` (integer): The persona to sign in with, for pages behind a login.
- `tier` (string): standard or deep. A deep build covers the whole site with bigger bounds (60 browser minutes, 1,000,000 AI tokens, 200 MB of residential bandwidth, up to 40 functions) and always costs 6,000 credits, never an included build.
- `accept_credits` (boolean): Your consent to pay credits for this build: a standard build past your plan’s monthly count (1,500 credits) or a deep build (6,000 credits). Without it the call answers 402 with build_quota_exhausted or build_credits_consent_required, the price_credits and your credits_available; send the same request again with accept_credits: true. The credits are held while the build runs; the full price is charged only when it delivers a working API, and a build you stop pays what it used so far, never more than its price. build_credits_insufficient means the price is not covered.
- `save_as` (string): The name of the API the build saves.
- `skip_existing` (boolean): Build even when one of your own APIs already matches the goal.
- `skip_marketplace` (boolean): Build even when a ready-made API already matches the goal.
- `contribute_to_catalog` (boolean): Your Marketplace choice for this build. Left out, the rules below decide: a free build is submitted to the Marketplace for review, a build paid in credits stays private. true submits it; false keeps it private, on Starter and up or during a trial. See Free builds go to the Marketplace.

```bash
curl -X POST https://api.usewrit.app/api/v1/website-to-api \
  -H "Authorization: Bearer $WRIT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://news.ycombinator.com",
    "goal": "Top stories with title, points, comment count and link. Let me ask for how many.",
    "save_as": "Hacker News"
  }'
```

```python
import os, requests

API = "https://api.usewrit.app"
HEADERS = {"Authorization": f"Bearer {os.environ['WRIT_API_KEY']}"}

res = requests.post(
    f"{API}/api/v1/website-to-api",
    headers=HEADERS,
    json={
        "url": "https://news.ycombinator.com",
        "goal": "Top stories with title, points, comment count and link. Let me ask for how many.",
        "save_as": "Hacker News",
    },
)
res.raise_for_status()
build = res.json()
print(build["status"])  # queued, existing_workflows or marketplace_candidates
```

```typescript
const API = "https://api.usewrit.app";
const headers = {
  Authorization: `Bearer ${process.env.WRIT_API_KEY}`,
  "Content-Type": "application/json",
};

const res = await fetch(`${API}/api/v1/website-to-api`, {
  method: "POST",
  headers,
  body: JSON.stringify({
    url: "https://news.ycombinator.com",
    goal: "Top stories with title, points, comment count and link. Let me ask for how many.",
    save_as: "Hacker News",
  }),
});
const build = await res.json();
console.log(build.status); // queued, existing_workflows or marketplace_candidates
```

The answer comes back at once with status `202`, in one of three forms. The first two cost
nothing and use no AI:

- `existing_workflows`: one of your APIs already covers the goal. Run it, or send the request again with `skip_existing` set to `true`.
- `marketplace_candidates`: a ready-made API covers it. Install it, or send again with `skip_marketplace` set to `true`.
- `queued`: the build has started. Keep its `build_id`.

```json
{
  "build_id": 9031,
  "status": "queued",
  "url": "https://news.ycombinator.com",
  "goal": "Top stories with title, points, comment count and link. Let me ask for how many.",
  "created_at": "2026-10-31T14:02:11Z",
  "completed_at": null,
  "workflow_id": null,
  "error": null
}
```

```json
{
  "status": "existing_workflows",
  "message": "Your library already has workflows matching this goal — replaying one is instant and costs no AI.",
  "goal": "Top stories with title, points, comment count and link. Let me ask for how many.",
  "workflows": [
    {
      "workflow_id": 4822,
      "name": "Hacker News",
      "description": "Top stories from news.ycombinator.com",
      "inputs": ["limit"],
      "functions": ["top_stories"],
      "run": { "tool": "writ_run_workflow", "arguments": { "workflow_id": 4822 } }
    }
  ],
  "next": "Run one with POST /api/v1/workflows/{workflow_id}/runs (writ_run_workflow), or call again with skip_existing=true to build fresh."
}
```

```json
{
  "status": "marketplace_candidates",
  "message": "Ready-made marketplace APIs already cover this goal.",
  "goal": "Top stories with title, points, comment count and link. Let me ask for how many.",
  "candidates": [
    {
      "slug": "hacker-news-top-stories",
      "title": "Hacker News top stories",
      "summary": "Front page stories with points and comment counts."
    }
  ],
  "next": "Install one, or call again with skip_marketplace=true to build fresh."
}
```

GET `https://api.usewrit.app/api/v1/website-to-api/{build_id}` wt_ key · workflows:read

Check every few seconds. The build ends on `succeeded`, `failed` or `cancelled`; on success, `workflow_id` is your new API.

```bash
curl https://api.usewrit.app/api/v1/website-to-api/9031 \
  -H "Authorization: Bearer $WRIT_API_KEY"
```

```python
import time

# Continues the example above: API, HEADERS and build are already set.
while build["status"] in ("queued", "building") or build.get("superseded"):
    time.sleep(10)
    # When Writ moves the build to another approach, it gives the new id.
    build_id = build.get("fallback_build_id") or build["build_id"]
    build = requests.get(f"{API}/api/v1/website-to-api/{build_id}", headers=HEADERS).json()

if build["status"] == "succeeded":
    print("API ready, workflow", build["workflow_id"])
else:
    print(build["status"], build.get("error") or build.get("next"))
```

```typescript
// Continues the example above: API, headers and build are already set.
let current = build;
while (["queued", "building"].includes(current.status) || current.superseded) {
  await new Promise((r) => setTimeout(r, 10_000));
  // When Writ moves the build to another approach, it gives the new id.
  const id = current.fallback_build_id ?? current.build_id;
  const res = await fetch(`${API}/api/v1/website-to-api/${id}`, { headers });
  current = await res.json();
}

if (current.status === "succeeded") {
  console.log("API ready, workflow", current.workflow_id);
} else {
  console.log(current.status, current.error ?? current.next);
}
```

```json
{
  "build_id": 9031,
  "status": "building",
  "url": "https://news.ycombinator.com",
  "goal": "Top stories with title, points, comment count and link. Let me ask for how many.",
  "created_at": "2026-10-31T14:02:11Z",
  "completed_at": null,
  "workflow_id": null,
  "error": null,
  "progress": "Reading the front page",
  "steps_taken": 6,
  "current_url": "https://news.ycombinator.com/"
}
```

```json
{
  "build_id": 9031,
  "status": "succeeded",
  "url": "https://news.ycombinator.com",
  "goal": "Top stories with title, points, comment count and link. Let me ask for how many.",
  "created_at": "2026-10-31T14:02:11Z",
  "completed_at": "2026-10-31T14:06:40Z",
  "workflow_id": 4822,
  "error": null
}
```

Fields worth reading

- `status` (string): queued, building, succeeded, failed, cancelled or needs_guidance.
- `tier` (string): standard or deep.
- `price_credits` (integer): What the build costs in credits; 0 when an included build covers it.
- `paid` (boolean): Credits are held for this build.
- `charged` (boolean): The held credits were settled: the full price once the build delivered a working API, or what a build you stopped had used, never more than its price. A failed or parked build releases them.
- `progress` (string): What the build is doing now, while it runs.
- `fallback_build_id` (integer): Writ moved the build to another approach under this id, and superseded is true. Follow the new id.
- `missing_functions` (array): Functions you asked for that could not be proven, with the reason.
- `needs_sign_in` (boolean): The build stopped at a sign-in page. Start it again with a persona_id.
- `site_block` (object): The site refused Writ’s servers. It lists what gets past it on your account.
- `next` (string): On needs_guidance: why the build paused and how to continue it.

A build that reaches the limit one build may use (30 browser minutes,
300,000 AI tokens or 50 MB of
residential bandwidth for a standard build; 60 minutes,
1,000,000 tokens, 200 MB and up to
40 functions for a deep build) pauses as `needs_guidance` and keeps what it
found. Your AI assistant can finish it; a paid build that parks charges nothing. Once it succeeds, call the API like any other: [Call your API](https://usewrit.app/docs/call).

> **limit:** A build started with an API key never waits for a person. If it meets a sign-in, a verification code or a CAPTCHA it cannot pass, it ends and says why. Builds started from the app or from your assistant pause and ask you instead.

## What it costs

Each plan includes a number of standard builds by Writ’s AI per month. Past that number a standard build is
1,500 credits, and a deep build (the whole site, with bigger bounds) is
6,000 credits on every plan, never an included build. The credits are held when the
build starts, and the full price is charged only when it delivers a working API: a build that fails or parks
charges nothing and releases the hold. A build you stop pays what it used so far (Writ’s AI, browser time and
residential traffic, at the usual rates), never more than its price; the app tells you what that is before you
stop it. A build on your plan’s included number stays counted when you stop it. A build that fails because of
Writ, such as a lost browser, does not count against the included number either.

| Plan | Writ AI builds per month |
| --- | --- |
| Free | 5 |
| Starter | 20 |
| Pro | 50 |
| Growth | 200 |
| Scale | 500 |
| Enterprise | Unlimited |

- Scribe’s own replies around the build use Writ’s AI and are billed by tokens. See [Scribe, the assistant](https://usewrit.app/docs/scribe).
- A build from your own AI assistant, or on Writ Desktop with your own AI key, is free and unlimited.
- Once built, each call on Writ Cloud costs **2 credits** without a browser and **20 credits** with one. A call that fails because of the site or Writ costs nothing.
- Calls that run on Writ Desktop are free.

All prices and plans: [Credits and plans](https://usewrit.app/docs/billing-wallet).

## Free builds go to the Marketplace

A free build on Writ Cloud, one of your plan’s included Writ AI builds or a build made with your own AI
assistant over MCP, is submitted to the [Marketplace](https://usewrit.app/docs/marketplace) once its functions
pass a proof run, and Writ reviews it before it is listed. That is the deal of a free build. A build you stop
is submitted too when some of its functions already passed their live test, with those functions only.

- A build paid in credits stays private unless you list it.
- A build that signs in with your account (a login, a persona or a secret) is never listed without your yes.
- A site that is not on the public internet is never listed.
- On Starter and up, and during a free trial, you can keep your builds private: all of them with **Keep my free builds private** in **Settings → Overview**, or one build at a time (`contribute_to_catalog: false` over the API). On Free, a free build is always submitted; a choice made during a trial stops applying when the trial ends.

## Next

-
- [Test and edit an API](https://usewrit.app/docs/functions): Try each function, publish the REST endpoint, expose it over MCP.
-
- [Call your API](https://usewrit.app/docs/call): Endpoints, keys, waiting for results, caching and errors.
-
- [Sign-ins and secrets](https://usewrit.app/docs/personas): Personas, 2FA codes and the secrets vault.
-
- [Record a workflow](https://usewrit.app/docs/workflows): For multi-step actions, show Writ the clicks yourself.
