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

# Migrare da Context.dev a Olostep

> Mappatura di endpoint, SDK, parametri e risposte per spostare il codice di web scraping da Context.dev (precedentemente Brand.dev) a Olostep, scritto in modo che un agente di codifica possa effettuare il passaggio.

Gli endpoint web di Context.dev (scrape, map, crawl, search, answers e batches) si mappano agli endpoint di Olostep con gli stessi compiti. Il passaggio richiede l'SDK o l'URL di base, la chiave API e alcuni nomi di parametri. Context.dev era chiamato Brand.dev fino a marzo 2026, quindi il codice più vecchio potrebbe importare `brand.dev`; la mappatura è la stessa.

> [!TIP]
>
> **Usi un agente di codifica?** Forniscigli questo prompt:
>
> ```text theme={null}
> Migra questo codice da Context.dev (o Brand.dev) a Olostep. Segui
> https://docs.olostep.com/migrate/context-dev.md esattamente: sostituisci l'SDK e la chiave API,
> mappa ogni chiamata web di Context.dev al suo equivalente Olostep e aggiorna il codice che
> legge le risposte. Leggi OLOSTEP_API_KEY dall'ambiente. Elenca tutto ciò che non ha un equivalente Olostep invece di indovinare.
> ```

## Scambio rapido

| | Context.dev | Olostep |
| - | - | - |
| Pacchetto Python | `pip install context.dev` (precedentemente `brand.dev`) | `pip install olostep` |
| Pacchetto Node | `npm install context.dev` (precedentemente `brand.dev`) | `npm install olostep` |
| Variabile chiave API | `CONTEXT_DEV_API_KEY` | `OLOSTEP_API_KEY` |
| URL di base | `https://api.context.dev/v1` | `https://api.olostep.com/v1` |
| Header di autenticazione | `Authorization: Bearer ctxt_secret_...` | `Authorization: Bearer $OLOSTEP_API_KEY` |
| Stile dei campi | principalmente camelCase | snake\_case in HTTP e Python, opzioni camelCase in Node |

Ottieni una chiave su [olostep.com/auth](https://www.olostep.com/auth). I nuovi account ricevono 500 crediti gratuiti.

```python Python theme={null}
# Prima
from context.dev import ContextDev
client = ContextDev()  # legge CONTEXT_DEV_API_KEY

# Dopo
from olostep import Olostep
client = Olostep()  # legge OLOSTEP_API_KEY
```

```javascript Node theme={null}
// Prima
import ContextDev from "context.dev";
const client = new ContextDev({ apiKey: process.env.CONTEXT_DEV_API_KEY });

// Dopo
import Olostep from "olostep";
const client = new Olostep({ apiKey: process.env.OLOSTEP_API_KEY });
```

## Mappa degli endpoint

| Context.dev | Olostep | Note |
| - | - | - |
| `POST /web/scrape` | `POST /scrapes` | `formats` è un array invece di un oggetto di booleani |
| `GET /web/urls` (map) | `POST /maps` | Restituisce stringhe URL semplici |
| `POST /web/crawl` | `POST /crawls` | Async su Olostep: fai polling, poi leggi le pagine. Nessun limite di 500 pagine |
| `POST /web/search` | `POST /searches` | Fino a 25 risultati per chiamata (Context.dev: 100) |
| `POST /web/answers` | `POST /answers` | Stessa forma `task` + `json_format` |
| `POST /batch/submit` con `mode: "scrape"` | `POST /batches` | Fino a 100.000 URL per batch su entrambi |
| `POST /batch/submit` con `mode: "crawl"` | `POST /crawls` | |
| `GET /batch/{id}`, `GET /batch/{id}/results` | `GET /batches/{id}`, `GET /batches/{id}/items` + `GET /retrieve` | Il contenuto è recuperato tramite `retrieve_id` |
| `POST /company/search`, `POST /people/search` | `POST /searches` con `category: { "type": "companies" }` o `"people"` | |
| `/monitors` | [`/monitors`](https://docs.olostep.com/features/monitors) | Forma della richiesta diversa: Olostep accetta una `query` in linguaggio naturale |

## Mappa dei metodi SDK

| Context.dev Python | Context.dev Node | Olostep Python | Olostep Node |
| - | - | - | - |
| `client.web.scrape(url=url, formats={"markdown": True})` | `client.web.scrape({ url, formats: { markdown: true } })` | `client.scrapes.create(url_to_scrape=url, formats=["markdown"])` | `client.scrapes.create({ url, formats: ["markdown"] })` |
| `client.web.map_urls(domain=domain)` | `client.web.mapUrls({ domain })` | `client.maps.create(url=domain)` | `client.maps.create({ url: domain })` |
| `client.web.web_crawl_md(url=url, max_pages=50)` | `client.web.webCrawlMd({ url, maxPages: 50 })` | `client.crawls.create(start_url=url, max_pages=50)`, poi `crawl.pages()` | `client.crawls.create({ url, maxPages: 50 })`, `crawl.waitTillDone()`, poi `crawl.pages()` |
| `client.web.search(query=q, num_results=10)` | `client.web.search({ query: q, numResults: 10 })` | `client.searches.create(query=q, limit=10)` | `client.searches.create({ query: q, limit: 10 })` |
| `client.web.answers(task=t, json_format={...})` | `client.web.answers({ task: t, json_format: {...} })` | `client.answers.create(task=t, json_format={...})` | `client.answers.create({ task: t, jsonFormat: {...} })` |
| `client.batch.submit(input={"mode": "scrape", ...})` | `client.batch.submit({ input: {...} })` | `client.batches.create(urls=[...])`, poi `batch.items()` | `client.batches.create([...])`, `batch.waitTillDone()`, poi `batch.items()` |

**Lettura dei risultati**

| Context.dev | Olostep Python | Olostep Node |
| - | - | - |
| `res.markdown.data` | `page.markdown_content` | `page.markdown_content` |
| `res.html.data` | `page.html_content` | `page.html_content` |
| `res.json.data` | `json.loads(page.json_content)` | `JSON.parse(page.json_content)` |
| `res.urls[i].url` (map) | `for url in site_map.urls()` | `for await (const url of siteMap.urls())` |
| `res.results[i].markdown` (crawl) | `page.retrieve(["markdown"]).markdown_content` per ogni `page` in `crawl.pages()` | `(await client.retrieve.get(page.retrieve_id, ["markdown"])).markdown_content` |
| `res.results[i].url` / `title` (search) | `results.links[i]["url"]` / `["title"]` | `results.links[i].url` / `.title` |
| `res.json_content` (answers) | `json.loads(answer.json_content)` | `JSON.parse(answer.json_content)` |
| `res.sources` (answers) | `answer.sources` | `answer.sources` |

> [!NOTE]
>
> Context.dev restituisce HTTP 200 anche quando un output fallisce, quindi il codice controlla `markdown.success` prima di leggere `markdown.data`. Olostep restituisce uno stato di errore quando uno scrape fallisce, quindi quel controllo per output può essere eliminato.

### Esempio

```python Python theme={null}
import json
from olostep import Olostep

client = Olostep()  # legge OLOSTEP_API_KEY

page = client.scrapes.create(url_to_scrape="https://example.com", formats=["markdown"])
print(page.markdown_content)

site_map = client.maps.create(url="https://docs.olostep.com", top_n=100)
print(list(site_map.urls())[:10])

# crawl.pages() attende che il crawl sia completato, poi restituisce ogni pagina
crawl = client.crawls.create(start_url="https://docs.olostep.com", max_pages=10)
for crawled in crawl.pages():
    print(crawled.url, len(crawled.retrieve(["markdown"]).markdown_content or ""))

answer = client.answers.create(
    task="When was the Eiffel Tower completed?", json_format={"year": ""}
)
print(json.loads(answer.json_content), answer.sources)
```

```javascript Node theme={null}
import Olostep from "olostep";

const client = new Olostep({ apiKey: process.env.OLOSTEP_API_KEY });

const page = await client.scrapes.create({ url: "https://example.com", formats: ["markdown"] });
console.log(page.markdown_content);

const siteMap = await client.maps.create({ url: "https://docs.olostep.com", topN: 100 });
for await (const url of siteMap.urls()) console.log(url);

const crawl = await client.crawls.create({ url: "https://docs.olostep.com", maxPages: 10 });
await crawl.waitTillDone();
for await (const crawled of crawl.pages()) {
  const content = await client.retrieve.get(crawled.retrieve_id, ["markdown"]);
  console.log(crawled.url, content.markdown_content?.length);
}

const answer = await client.answers.create({
  task: "When was the Eiffel Tower completed?",
  jsonFormat: { year: "" },
});
console.log(JSON.parse(answer.json_content), answer.sources);
```

***

## Riferimento API HTTP

### Scrape

```bash Context.dev theme={null}
curl -X POST https://api.context.dev/v1/web/scrape \
  -H "Authorization: Bearer $CONTEXT_DEV_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com",
    "formats": { "markdown": true, "html": true },
    "sharedParams": { "mainContentOnly": true, "waitFor": 2000, "country": "IT" }
  }'
```

```bash Olostep theme={null}
curl -X POST https://api.olostep.com/v1/scrapes \
  -H "Authorization: Bearer $OLOSTEP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url_to_scrape": "https://example.com",
    "formats": ["markdown", "html"],
    "remove_css_selectors": "default",
    "wait_before_scraping": 2000,
    "country": "IT"
  }'
```

**Parametri della richiesta**

| Context.dev | Olostep |
| - | - |
| `url` | `url_to_scrape` |
| `formats: { "markdown": true, "html": true }` | `formats: ["markdown", "html"]` |
| `formats.screenshot` + `screenshotParams.area: "fullPage"` | `formats: ["screenshot"]` + `screenshot: { "full_page": true }` |
| `formats.json` + `jsonParams.schema` | `formats: ["json"]` + `llm_extract: { "schema": {...} }` |
| `formats.json` + `jsonParams.instructions` solo | `formats: ["json"]` + `llm_extract: { "prompt": "..." }` |
| `formats.parse` + parser predefinito `links` | `links_on_page: {}` |
| `formats.parse` + altri parser predefiniti | `formats: ["json"]` + `parser: { "id": "@olostep/..." }` (vedi [Parsers](https://docs.olostep.com/features/structured-content/parsers.md); il set di parser è diverso) |
| `sharedParams.mainContentOnly: true` | `remove_css_selectors: "default"` (rimuove nav, footer, dialoghi, banner) |
| `sharedParams.excludeSelectors: ["nav", ".ads"]` | `remove_css_selectors: "[\"nav\", \".ads\"]"` (stringa JSON) |
| `sharedParams.waitFor` (ms) | `wait_before_scraping` (ms) |
| `sharedParams.actions` | `actions` (`wait`, `click`, `fill_input`, `scroll`) |
| `sharedParams.country` | `country` |
| `sharedParams.viewport` | `screen_size: { "screen_width": 1920, "screen_height": 1080 }` |
| `maxAgeMs` | rimuovere: Olostep recupera le pagine in tempo reale |
| `sharedParams.includeSelectors`, `headers`, `profile`, `timeoutOpts` | nessun equivalente |

**Risposta**

| Context.dev | Olostep |
| - | - |
| `markdown.data` | `result.markdown_content` |
| `html.data` | `result.html_content` |
| `screenshot.data` (base64 data URL) | `result.screenshot_hosted_url` (un URL) |
| `json.data` (oggetto) | `result.json_content` (**stringa**: analizzala) |
| `parsed.data` | `result.json_content` (parser) o `result.links_on_page` (link) |
| `metadata.title` | non restituito in modo affidabile: leggi il `<title>` da `result.html_content` |
| `key_metadata.credits_consumed` | `credits_consumed` |
| `request_id` | `id` |

### Map

```bash Context.dev theme={null}
curl "https://api.context.dev/v1/web/urls?domain=example.com&maxLinks=500&search=pricing" \
  -H "Authorization: Bearer $CONTEXT_DEV_API_KEY"
```

```bash Olostep theme={null}
curl -X POST https://api.olostep.com/v1/maps \
  -H "Authorization: Bearer $OLOSTEP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "url": "https://example.com", "top_n": 500, "search_query": "pricing" }'
```

| Context.dev | Olostep |
| - | - |
| `domain` (parametro query, `GET`) | `url` (corpo JSON, `POST`) |
| `maxLinks` (default 10,000) | `top_n` (omettendolo si ottengono tutti gli URL) |
| `search` | `search_query` |
| `urlRegex` / `excludeUrlRegex` (**regex**) | `include_urls` / `exclude_urls` (**glob**, es. `/blog/**`) |
| `includeSubdomains` (default `false`) | `include_subdomain` (default **`true`**: imposta `false` per corrispondere al default di Context.dev) |
| `sitemapUrl` | nessun equivalente |
| Risposta `urls: [{ "url", "title", ... }]` | Risposta `urls: ["https://..."]` |
| — | `cursor` nella risposta quando rimangono più URL: invialo indietro per ottenere la pagina successiva |

### Crawl

Il `/web/crawl` di Context.dev è sincrono e restituisce ogni pagina in una risposta (fino a 500 pagine). Il crawl di Olostep è un lavoro: avvialo, attendi `completed`, poi leggi le pagine. Gli SDK attendono per te (`crawl.pages()` in Python, `crawl.waitTillDone()` in Node).

```bash Context.dev theme={null}
curl -X POST https://api.context.dev/v1/web/crawl \
  -H "Authorization: Bearer $CONTEXT_DEV_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "url": "https://example.com", "maxPages": 50, "maxDepth": 3, "urlRegex": "^https://example\\.com/blog/" }'
```

```bash Olostep theme={null}
# 1. Avvia il crawl
curl -X POST https://api.olostep.com/v1/crawls \
  -H "Authorization: Bearer $OLOSTEP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "start_url": "https://example.com", "max_pages": 50, "max_depth": 3, "include_urls": ["/blog/**"] }'

# 2. Fai polling fino a quando "status" è "completed"
curl https://api.olostep.com/v1/crawls/$CRAWL_ID -H "Authorization: Bearer $OLOSTEP_API_KEY"

# 3. Elenca le pagine (ognuna ha un retrieve_id), poi recupera il contenuto di ogni pagina
curl "https://api.olostep.com/v1/crawls/$CRAWL_ID/pages?limit=50" -H "Authorization: Bearer $OLOSTEP_API_KEY"
curl "https://api.olostep.com/v1/retrieve?retrieve_id=$RETRIEVE_ID&formats=markdown" -H "Authorization: Bearer $OLOSTEP_API_KEY"
```

| Context.dev | Olostep |
| - | - |
| `url` | `start_url` |
| `maxPages` (default 100, max 500) | `max_pages` (richiesto) |
| `maxDepth` | `max_depth` |
| `urlRegex` / `excludeUrlRegex` (**regex**) | `include_urls` / `exclude_urls` (**glob**, es. `/blog/**`) |
| `followSubdomains` | `include_subdomain` |
| `maxAgeMs`, `waitForMs`, `stopAfterMs`, `timeoutOpts` | rimuovere |
| Risposta `results[].markdown` | `/retrieve` risposta `markdown_content` per pagina |
| Risposta `results[].metadata.url` | `pages[].url` |

### Search

```bash Context.dev theme={null}
curl -X POST https://api.context.dev/v1/web/search \
  -H "Authorization: Bearer $CONTEXT_DEV_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "query": "best web scraping APIs", "numResults": 5, "markdownOptions": { "enabled": true } }'
```

```bash Olostep theme={null}
curl -X POST https://api.olostep.com/v1/searches \
  -H "Authorization: Bearer $OLOSTEP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "query": "best web scraping APIs", "limit": 5, "scrape_options": { "formats": ["markdown"], "timeout": 45 } }'
```

| Context.dev | Olostep |
| - | - |
| `query` | `query` |
| `numResults` (1–100, default 10) | `limit` (**1–25**, default 12) |
| `includeDomains` / `excludeDomains` | `include_domains` / `exclude_domains` |
| `markdownOptions.enabled: true` | `scrape_options: { "formats": ["markdown"], "timeout": 45 }` (`timeout` in secondi, 1–60; i link che non finiscono tornano con contenuto `null`) |
| `freshness` | nessun equivalente: aggiungi il periodo di tempo a `query` |
| `country`, `languages`, `highlightsOptions` | nessun equivalente |
| `zdr: "enabled"` | `zero_data_retention: true` |
| Risposta `results[]` (`url`, `title`, `description`) | `result.links[]` (`url`, `title`, `description`) |
| Risposta `results[].markdown.markdown` | `result.links[].markdown_content` |
| Risposta `results[].relevance` | nessun equivalente (i risultati vengono in ordine di rilevanza) |

### Answers

La forma della richiesta è la stessa: `task` più `json_format` come oggetto di esempio.

```bash Olostep theme={null}
curl -X POST https://api.olostep.com/v1/answers \
  -H "Authorization: Bearer $OLOSTEP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "task": "Find the CEO and founding year of Stripe", "json_format": { "ceo": "", "founded": "" } }'
```

| Context.dev | Olostep |
| - | - |
| `task` | `task` |
| `json_format` (oggetto di esempio) | `json_format` (oggetto di esempio, o una descrizione in testo semplice) |
| `mode: "fast"` / `"ultra"` | nessun equivalente (omettibile) |
| Risposta `json_content` (oggetto) | `result.json_content` (**stringa**: analizzala) |
| Risposta `sources` | `result.sources` |

### Batches

```bash Context.dev theme={null}
curl -X POST https://api.context.dev/v1/batch/submit \
  -H "Authorization: Bearer $CONTEXT_DEV_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "input": {
      "mode": "scrape",
      "data": {
        "formats": { "markdown": true },
        "urls": [
          { "url": "https://example.com", "itemId": "a" },
          { "url": "https://www.iana.org/help/example-domains", "itemId": "b" }
        ]
      }
    },
    "webhook": { "url": "https://my.app/hook" }
  }'
```

```bash Olostep theme={null}
curl -X POST https://api.olostep.com/v1/batches \
  -H "Authorization: Bearer $OLOSTEP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "items": [
      { "custom_id": "a", "url": "https://example.com" },
      { "custom_id": "b", "url": "https://www.iana.org/help/example-domains" }
    ],
    "webhook": "https://my.app/hook"
  }'
```

| Context.dev | Olostep |
| - | - |
| `input.data.urls[]` (`url`, `itemId`) | `items[]` (`url`, `custom_id`) |
| `input.data.formats` | scelto quando leggi i risultati: `GET /retrieve?formats=markdown` |
| `webhook.url` | `webhook` (una stringa) |
| `GET /batch/{id}` `status` (`completed`, `failed`, ...) | `GET /batches/{id}` `status` (`in_progress`, `completed`) |
| `GET /batch/{id}/results` (`next_cursor`) | `GET /batches/{id}/items` (`cursor`), poi `GET /retrieve?retrieve_id=...` per ogni item |
| Risultato `result.markdown.data` | `/retrieve` risposta `markdown_content` |
| `itemId` su ogni risultato | `custom_id` su ogni item |

***

## Non coperto uno a uno

Questi endpoint di Context.dev non hanno un equivalente Olostep: dati del marchio (`/brand/retrieve`, `/brand/search`), `/web/styleguide`, `/news/search`, `/scholar/search`, `/people/enrich`, e `/parse` per file caricati. Olostep estrae PDF e altri documenti tramite URL.

## Verifica la migrazione

1. Non ci sono più importazioni di Context.dev o Brand.dev, pacchetti o letture di `CONTEXT_DEV_API_KEY`: cerca nel codice `context.dev`, `brand.dev` e `ContextDev`.
2. `OLOSTEP_API_KEY` è impostato ovunque l'app venga eseguita (locale `.env`, segreti CI, produzione).
3. Gli oggetti `formats` (`{ "markdown": true }`) sono ora array (`["markdown"]`).
4. Il codice che leggeva `.markdown.data` o `.json.data` ora legge `markdown_content` o analizza `json_content`.
5. I crawl attendono il completamento e leggono le pagine tramite `retrieve_id`; i filtri URL usano glob (`/blog/**`), non regex.
6. Esegui un scrape, una ricerca e, se li usi, un crawl o batch da capo a fine prima di distribuire.

## Link

* [Riferimento API di Olostep](https://docs.olostep.com/api-reference/scrapes/create.md)
* [SDK di Olostep (Python / Node)](https://docs.olostep.com/sdks/overview.md)
* [Migrare da Exa](https://docs.olostep.com/migrate/exa.md)


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