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

# Migrate from SerpApi

> Map SerpApi requests and responses to Octen.

For AI agents: [docs.octen.ai/resources/migrate-from-serpapi.md](https://docs.octen.ai/resources/migrate-from-serpapi.md)

## Endpoint Map

| SerpApi | Octen |
| :- | :- |
| Google Search API (`engine=google`) | [Web Search](https://docs.octen.ai/api-reference/search.md) |
| Google News API (`engine=google_news`) | [News Search](https://docs.octen.ai/api-reference/news-search.md) |
| Google Images API (`engine=google_images`) | [Image Search](https://docs.octen.ai/api-reference/image-search.md) |
| Google Lens API (`engine=google_lens`) | [Image Search](https://docs.octen.ai/api-reference/image-search.md) with an image input |
| Google Videos API (`engine=google_videos`) | [Video Search](https://docs.octen.ai/api-reference/video-search.md) (invite-only beta) |
| Google Maps API (`engine=google_maps`) | [Place Search](https://docs.octen.ai/api-reference/place-search.md) |
| Google Local API (`engine=google_local`) | [Place Search](https://docs.octen.ai/api-reference/place-search.md) |
| Extract API (`engine=extract`, `mode=scrape`) | [Extract](https://docs.octen.ai/api-reference/extract.md) |

## Authentication

| | SerpApi | Octen |
| :- | :- | :- |
| Base URL | `https://serpapi.com/search` (`GET`; `engine` selects the API) | `https://api.octen.ai` (`POST` with a JSON body; one path per API) |
| Auth header | None; the key goes in the `api_key` query parameter | `x-api-key: <key>` or `Authorization: Bearer <key>` |
| Python SDK | `serpapi` (`serpapi.Client`) | `octen` (`Octen`) |

## Web Search

### Request Parameters

| SerpApi | Octen |
| :- | :- |
| `q` | `query` (up to 500 characters). Supported operators: `site:`, `-site:`, `before:`, `after:`, `OR`, and `"<words>"`, which matches pages containing every quoted word. |
| `lr` | `language` (a list of ISO 639-1 codes; `lang_fr` becomes `"fr"`) |
| `tbs` with `qdr` (past day, week, month, or year) | `time_range` (`day`, `week`, `month`, or `year`) |
| `tbs` with `cdr`, `cd_min`, `cd_max` | `start_time`, `end_time` (ISO 8601) |
| `safe` (`active` or `off`) | `safesearch` (`strict` or `off`, default `strict`) |

### Response Fields

| SerpApi | Octen |
| :- | :- |
| `organic_results` | `data.results` |
| `organic_results[].title` | `data.results[].title` |
| `organic_results[].link` | `data.results[].url` |
| `organic_results[].snippet` | `data.results[].highlight` (query-relevant; `highlight.max_tokens` sets the length) |
| `organic_results[].source` | `data.results[].authors` (website name or author) |
| `organic_results[].date` | `data.results[].time_published` (ISO 8601) |
| `organic_results[].favicon` | `data.results[].favicon` |
| `organic_results[].thumbnail` | `data.results[].cover_image.url` (with `include_images`) |
| `search_metadata.id` | `request_id` |
| `search_metadata.total_time_taken` | `meta.latency` (milliseconds) |
| `error` | `msg`, with a nonzero `code` |

### Code

```python Before (SerpApi) theme={null}
import os
import serpapi

client = serpapi.Client(api_key=os.environ["SERPAPI_KEY"])
results = client.search({
    "engine": "google",
    "q": "coffee",
    "lr": "lang_en",
})
for result in results["organic_results"]:
    print(result["title"], result["link"])
    print(result.get("snippet"))
```

```python After (Octen) theme={null}
import os
from octen import Octen

client = Octen(api_key=os.environ["OCTEN_API_KEY"])
response = client.search.search(
    query="coffee",
    count=10,
    language=["en"],
)
for result in response.results:
    print(result["title"], result["url"])
    print(result.get("highlight"))
```

## News Search

### Request Parameters

| SerpApi | Octen |
| :- | :- |
| `q` | `query` (up to 500 characters). Supported operators: `site:` and `-site:`. |
| `when:` in `q` | `time_range` (`day`, `week`, `month`, or `year`), or `start_time` and `end_time` (ISO 8601) |

### Response Fields

| SerpApi | Octen |
| :- | :- |
| `news_results` | `data.results` |
| `news_results[].title` | `data.results[].title` |
| `news_results[].link` | `data.results[].url` |
| `news_results[].snippet` | `data.results[].highlight` |
| `news_results[].source.name`, `news_results[].source.authors` | `data.results[].authors` (website name or author) |
| `news_results[].source.icon` | `data.results[].favicon` |
| `news_results[].thumbnail` | `data.results[].cover_image.url` |
| `news_results[].iso_date`, `news_results[].date` | `data.results[].time_published` (ISO 8601) |
| `news_results[].highlight`, `news_results[].stories` | `data.subjects` (related articles grouped into events, each with `top_news` and `sub_news`) |
| `search_metadata.id` | `request_id` |
| `search_metadata.total_time_taken` | `meta.latency` (milliseconds) |
| `error` | `msg`, with a nonzero `code` |

### Code

```python Before (SerpApi) theme={null}
import os
import serpapi

client = serpapi.Client(api_key=os.environ["SERPAPI_KEY"])
results = client.search({
    "engine": "google_news",
    "q": "SpaceX Starship",
})
for result in results["news_results"]:
    print(result.get("title"), result.get("link"), result.get("source", {}).get("name"), result.get("iso_date"))
```

```python After (Octen) theme={null}
import os
from octen import Octen

client = Octen(api_key=os.environ["OCTEN_API_KEY"])
response = client.search.news_search(
    query="SpaceX Starship",
    count=10,
)
for result in response.results:
    print(result["title"], result["url"], result.get("authors"), result.get("time_published"))
```

## Image Search

### Request Parameters

| SerpApi | Octen |
| :- | :- |
| `q` | `inputs` with one text input, `{"type": "text", "data": "<query>"}` (`query` in the Python SDK) |
| `site:` in `q` | `include_domains` (up to 10, matched against each result's `source_page`) |
| `url` (Google Lens) | `inputs` with one image input, `{"type": "image", "url": "<image URL>"}` (`image_url` in the Python SDK) |
| `safe` (`active` or `off`) | `safesearch` (`strict` or `off`, default `strict`) |

### Response Fields

| SerpApi | Octen |
| :- | :- |
| `images_results` | `data.results` |
| `images_results[].title` | `data.results[].title` |
| `images_results[].original` | `data.results[].url` |
| `images_results[].original_width`, `images_results[].original_height` | `data.results[].width`, `data.results[].height` |
| `images_results[].thumbnail` | `data.results[].thumbnail` |
| `images_results[].link` | `data.results[].source_page` |
| `visual_matches[]` (Google Lens: `image`, `link`, `image_width`, `image_height`, `thumbnail`) | `data.results[]` (`url`, `source_page`, `width`, `height`, `thumbnail`) |
| `search_metadata.id` | `request_id` |
| `search_metadata.total_time_taken` | `meta.latency` (milliseconds) |
| `error` | `msg`, with a nonzero `code` |

### Code

```python Before (SerpApi) theme={null}
import os
import serpapi

client = serpapi.Client(api_key=os.environ["SERPAPI_KEY"])
results = client.search({
    "engine": "google_images",
    "q": "lion",
})
for result in results["images_results"][:10]:
    print(result["title"], result["original"], result["link"])
```

```python After (Octen) theme={null}
import os
from octen import Octen

client = Octen(api_key=os.environ["OCTEN_API_KEY"])
response = client.image_search.search(
    query="lion",
    count=10,
)
for result in response.results:
    print(result["title"], result["url"], result["source_page"])
```

## Video Search

### Request Parameters

| SerpApi | Octen |
| :- | :- |
| `q` | `inputs` with one text input, `{"type": "text", "data": "<query>"}` (`query` in the Python SDK) |
| `tbs` with `qdr` (past day, week, month, or year) | `time_range` (`day`, `week`, `month`, or `year`), filtered by publish time |
| `tbs` with `cdr`, `cd_min`, `cd_max` | `start_time`, `end_time` (ISO 8601), filtered by publish time |
| `safe` (`active` or `off`) | `safesearch` (`strict` or `off`, default `strict`) |

### Response Fields

| SerpApi | Octen |
| :- | :- |
| `video_results` | `data.results` |
| `video_results[].title` | `data.results[].title` |
| `video_results[].link` | `data.results[].url` |
| `video_results[].snippet` | `data.results[].description` (server-generated description of the video content) |
| `video_results[].thumbnail` | `data.results[].cover_url` |
| `video_results[].duration` (such as `"12:42"`) | `data.results[].duration_seconds` (an integer) |
| `video_results[].date` | `data.results[].time_published` (ISO 8601) |
| `search_metadata.id` | `request_id` |
| `search_metadata.total_time_taken` | `meta.latency` (milliseconds) |
| `error` | `msg`, with a nonzero `code` |

### Code

```python Before (SerpApi) theme={null}
import os
import serpapi

client = serpapi.Client(api_key=os.environ["SERPAPI_KEY"])
results = client.search({
    "engine": "google_videos",
    "q": "how to make fresh pasta",
})
for result in results["video_results"]:
    print(result["title"], result["link"], result.get("duration"))
```

```python After (Octen) theme={null}
import os
from octen import Octen

client = Octen(api_key=os.environ["OCTEN_API_KEY"])
response = client.video_search.search(
    query="how to make fresh pasta",
    count=10,
)
for result in response.results:
    print(result["title"], result["url"], result.get("duration_seconds"))
```

## Place Search

### Request Parameters

| SerpApi | Octen |
| :- | :- |
| `q` | `query` (up to 500 characters) |
| `ll` (`@latitude,longitude,zoom`) | `latitude`, `longitude` (provide both) |
| `lat`, `lon` | `latitude`, `longitude` |
| `location` | `user_location` with `type: "approximate"` and `city`, `region`, `country` (country as an ISO 3166-1 alpha-2 code or free text) |

### Response Fields

| SerpApi | Octen |
| :- | :- |
| `local_results` | `data.places` |
| `local_results[].title` | `data.places[].name` |
| `local_results[].type` | `data.places[].category` |
| `local_results[].address` | `data.places[].address` |
| `local_results[].gps_coordinates.latitude`, `local_results[].gps_coordinates.longitude` | `data.places[].latitude`, `data.places[].longitude` |
| `local_results[].phone` | `data.places[].phone` (international format) |
| `local_results[].website` | `data.places[].website` |
| `local_results[].rating` | `data.places[].rating` (out of 5) |
| `local_results[].reviews` | `data.places[].review_count` |
| `local_results[].hours`, `local_results[].operating_hours` | `data.places[].opening_hours` (a list of strings in the local time of the place) |
| `local_results[].open_state` | `data.places[].status` (`open`, `closed`, `temporarily_closed`, or `permanently_closed`) |
| `local_results[].service_options` | `data.places[].attributes` (amenities and services as key-value pairs with boolean values) |
| `search_metadata.id` | `request_id` |
| `search_metadata.total_time_taken` | `meta.latency` (milliseconds) |
| `error` | `msg`, with a nonzero `code` |

### Code

```python Before (SerpApi) theme={null}
import os
import serpapi

client = serpapi.Client(api_key=os.environ["SERPAPI_KEY"])
results = client.search({
    "engine": "google_maps",
    "type": "search",
    "q": "coffee shops",
    "ll": "@40.7505,-73.9934,14z",
})
for place in results["local_results"]:
    print(place["title"], place.get("address"), place.get("rating"))
```

```python After (Octen) theme={null}
import os
from octen import Octen

client = Octen(api_key=os.environ["OCTEN_API_KEY"])
response = client.place_search.search(
    query="coffee shops",
    latitude=40.7505,
    longitude=-73.9934,
    places={"count": 20},
)
for place in response.places:
    print(place["name"], place.get("address"), place.get("rating"))
```

## Extract

### Request Parameters

| SerpApi | Octen |
| :- | :- |
| `url` | `urls` (up to 20 URLs, each up to 2,048 characters) |
| `mode=scrape` | No parameter; Extract always reads the given pages |
| `output=md`, `include_markdown` | `format` (`markdown` or `text`, default `markdown`) |
| `timeout` (milliseconds, 1,000-120,000) | `timeout` (seconds per URL, 1-60, default 30) |
| `no_cache` | `max_age_seconds` (300-31,536,000, default 86,400). Cached content older than this is re-fetched, so `300` is the closest to `no_cache`. |

### Response Fields

| SerpApi | Octen |
| :- | :- |
| `markdown` | `data.results[].full_content` (`data.results` is `response.items` in the Python SDK) |
| `page_information.title` | `data.results[].title` |
| `page_information.favicon` | `data.results[].favicon` |
| `open_graph.image` | `data.results[].cover_image.url` (with `include_images`) |
| `inline_images[].source` | `data.results[].images[].url` (with `include_images`) |
| `inline_links[]` (`link`, `title`, `internal`) | `data.results[].links[]` (`url`, `anchor_text`, and `is_external`, the inverse of `internal`; with the `include_links` object) |
| `error` | `msg`, with a nonzero `code`; a failed URL returns `status: "failed"` and `error_message` |

### Code

```python Before (SerpApi) theme={null}
import os
import serpapi

client = serpapi.Client(api_key=os.environ["SERPAPI_KEY"], timeout=60)  # HTTP client timeout in seconds, not the Extract timeout parameter
results = client.extract(url="https://en.wikipedia.org/wiki/Coffee")
print(results["page_information"]["title"])
print(results["markdown"][:500])
```

```python After (Octen) theme={null}
import os
from octen import Octen

client = Octen(api_key=os.environ["OCTEN_API_KEY"])
response = client.extract.extract(
    urls=["https://en.wikipedia.org/wiki/Coffee"],
    format="markdown",
)
for item in response.items:
    if item.status == "success":
        print(item.title)
        print(item.full_content[:500])
    else:
        print("failed:", item.url, item.error_message)
```

***

Last modified on November 24, 2026


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