> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.multion.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.multion.ai/_mcp/server.

# Retrieve

POST https://api.multion.ai/v1/web/retrieve
Content-Type: application/json

Retrieve data from webpage based on a url and natural language command that guides agents data extraction process.

The function can create a new session or be used as part of a session.

Reference: https://docs.multion.ai/api-reference/autonomous-api-reference/retrieve

## Authentication

- `X_MULTION_API_KEY` header (required) — API Key authentication via header

## Request

### Body (application/json)

This endpoint expects an object.

- `cmd` (string, required, default: ) — A specific natural language instruction on data the agent should extract.
- `url` (string, optional) — The URL to create or continue session from.
- `session_id` (string, optional) — Continues the session with session_id if provided.
- `local` (boolean, optional) — Boolean flag to indicate if session to be run locally or in the cloud (Default: False). If set to true, the session will be run locally via your chrome extension. If set to false, the session will be run in the cloud.
- `fields` (list of string, optional) — List of fields (columns) to be outputted in data.
- `format` (enum, optional) — The format of the response data. (Default: json)
  - Allowed values: `json`, `markdown`
- `max_items` (double, optional, default: 100) — Maximum number of data items to retrieve. (Default: 100)
- `full_page` (boolean, optional) — Flag to retrieve full page (Default: True). If set to false, the data will only be retrieved from the current session viewport.
- `render_js` (boolean, optional) — Flag to include rich JS and ARIA elements in data retrieved. (Default: False)
- `scroll_to_bottom` (boolean, optional) — Flag to scroll to the bottom of the page (Default: False). If set to true, the page will be scrolled to the bottom for a maximum of 5 seconds before data is retrieved.
- `mode` (string, optional, default: fast) — The mode you would like to use for the session. 'standard', 'fast' or 'ludicrous'
- `include_screenshot` (boolean, optional) — Flag to include a screenshot with the response. (Default: False)
- `optional_params` (map from string to any, optional) — Additional optional parameters for the session.

## Response

### 200

- `message` (string, required) — information relating to response
- `url` (string, required) — The last accessed URL during the session.
- `status` (string, required) — The current status of the session.
- `data` (list of map from string to any, required) — Array of data objects, each containing data requested in fields.
- `screenshot` (string, optional) — image url of the screenshot taken during the session.
- `session_id` (string, optional) — The unique identifier for the session.

## Errors

### 422 Unprocessable Entity

Validation Error

- `detail` (list of ValidationError, optional)

## Types

### ValidationError

- `loc` (list of ValidationErrorLocItem, required)
- `msg` (string, required)
- `type` (string, required)

### ValidationErrorLocItem

## Examples

**Request**

```json
{
  "cmd": "Find the top post on Hackernews and get its title and points.",
  "url": "https://news.ycombinator.com/",
  "fields": [
    "title",
    "points"
  ]
}
```

**Response**

```json
{
  "message": "Retrieved data successfully",
  "url": "https://news.ycombinator.com/",
  "status": "DONE",
  "data": [
    {
      "title": "Show HN: Sonauto – a more controllable AI music creator",
      "points": 219
    }
  ],
  "screenshot": "https://api.multion.ai/v1/web/screenshot/1",
  "session_id": "1"
}
```

**SDK Code**

```python
import requests

url = "https://api.multion.ai/v1/web/retrieve"

payload = {
    "cmd": "Find the top post on Hackernews and get its title and points.",
    "url": "https://news.ycombinator.com/",
    "fields": ["title", "points"]
}
headers = {
    "X_MULTION_API_KEY": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```typescript
import { MultiOnClient } from "multion";

const client = new MultiOnClient({ apiKey: "YOUR_API_KEY" });
await client.retrieve({
    cmd: "Find the top post on Hackernews and get its title and points.",
    url: "https://news.ycombinator.com/",
    fields: ["title", "points"]
});

```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.multion.ai/v1/web/retrieve"

	payload := strings.NewReader("{\n  \"cmd\": \"Find the top post on Hackernews and get its title and points.\",\n  \"url\": \"https://news.ycombinator.com/\",\n  \"fields\": [\n    \"title\",\n    \"points\"\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("X_MULTION_API_KEY", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.multion.ai/v1/web/retrieve")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["X_MULTION_API_KEY"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"cmd\": \"Find the top post on Hackernews and get its title and points.\",\n  \"url\": \"https://news.ycombinator.com/\",\n  \"fields\": [\n    \"title\",\n    \"points\"\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.multion.ai/v1/web/retrieve")
  .header("X_MULTION_API_KEY", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"cmd\": \"Find the top post on Hackernews and get its title and points.\",\n  \"url\": \"https://news.ycombinator.com/\",\n  \"fields\": [\n    \"title\",\n    \"points\"\n  ]\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.multion.ai/v1/web/retrieve', [
  'body' => '{
  "cmd": "Find the top post on Hackernews and get its title and points.",
  "url": "https://news.ycombinator.com/",
  "fields": [
    "title",
    "points"
  ]
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'X_MULTION_API_KEY' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.multion.ai/v1/web/retrieve");
var request = new RestRequest(Method.POST);
request.AddHeader("X_MULTION_API_KEY", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"cmd\": \"Find the top post on Hackernews and get its title and points.\",\n  \"url\": \"https://news.ycombinator.com/\",\n  \"fields\": [\n    \"title\",\n    \"points\"\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "X_MULTION_API_KEY": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "cmd": "Find the top post on Hackernews and get its title and points.",
  "url": "https://news.ycombinator.com/",
  "fields": ["title", "points"]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.multion.ai/v1/web/retrieve")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```