# Extract data without selectors

> auto_extract reads a standard record – product, article, job, review list, recipe, event or organization – from any page without selectors, in one schema for every site.

Source: https://docs.virginproxy.com/auto-extract/

Name the kind of page and get its data in the same shape for every site: `auto_extract` reads the page's structured data (JSON-LD, Microdata, Open Graph) and fills the gaps from the page itself. No selectors to write, nothing to repair when a shop changes its layout.

**cURL**

```bash
curl https://api.virginproxy.com/v1/requests \
  -H "Authorization: Bearer $VP_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://shop.example/p/trail-runner-2",
    "auto_extract": "product"
  }'
```

**Python**

```python
import os, requests

r = requests.post(
    "https://api.virginproxy.com/v1/requests",
    headers={"Authorization": "Bearer " + os.environ["VP_KEY"]},
    json={
        "url": "https://shop.example/p/trail-runner-2",
        "auto_extract": "product",
    },
    timeout=180,
)
data = r.json()
if not r.ok:
    raise SystemExit(data["error"]["code"] + ": " + data["error"]["message"])
print(data["auto_extracted"])
```

**Node.js**

```javascript
const res = await fetch("https://api.virginproxy.com/v1/requests", {
  method: "POST",
  headers: { Authorization: "Bearer " + process.env.VP_KEY, "Content-Type": "application/json" },
  body: JSON.stringify({
    url: "https://shop.example/p/trail-runner-2",
    auto_extract: "product",
  }),
  signal: AbortSignal.timeout(180_000),
});
const data = await res.json();
if (!res.ok) throw new Error(data.error.code + ": " + data.error.message);
console.log(data.auto_extracted);
```

**Python SDK**

```pysdk
from virginproxy import VirginProxy  # docs.virginproxy.com/sdk/virginproxy.py

vp = VirginProxy()  # reads VP_KEY
data = vp.request({
    "url": "https://shop.example/p/trail-runner-2",
    "auto_extract": "product",
})
print(data)
```

**Node SDK**

```nodesdk
import { VirginProxy } from "./virginproxy.mjs"; // docs.virginproxy.com/sdk/virginproxy.mjs

const vp = new VirginProxy(); // reads VP_KEY
const data = await vp.request({
  url: "https://shop.example/p/trail-runner-2",
  auto_extract: "product",
});
console.log(data);
```

**PHP**

```php
<?php
$ch = curl_init("https://api.virginproxy.com/v1/requests");
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 180,
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer " . getenv("VP_KEY"),
        "Content-Type: application/json",
    ],
    CURLOPT_POSTFIELDS => json_encode([
        "url" => "https://shop.example/p/trail-runner-2",
        "auto_extract" => "product",
    ], JSON_UNESCAPED_SLASHES),
]);
$data = json_decode(curl_exec($ch), true);
if (isset($data["error"])) {
    exit($data["error"]["code"] . ": " . $data["error"]["message"] . PHP_EOL);
}
echo json_encode($data["auto_extracted"], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE), PHP_EOL;
```

**Go**

```go
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"log"
	"net/http"
	"os"
	"time"
)

func main() {
	payload := []byte(`{
  "url": "https://shop.example/p/trail-runner-2",
  "auto_extract": "product"
}`)
	req, err := http.NewRequest("POST", "https://api.virginproxy.com/v1/requests", bytes.NewReader(payload))
	if err != nil {
		log.Fatal(err)
	}
	req.Header.Set("Authorization", "Bearer "+os.Getenv("VP_KEY"))
	req.Header.Set("Content-Type", "application/json")

	client := &http.Client{Timeout: 180 * time.Second}
	res, err := client.Do(req)
	if err != nil {
		log.Fatal(err)
	}
	defer res.Body.Close()

	var data map[string]any
	if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
		log.Fatal(err)
	}
	if res.StatusCode >= 300 {
		e := data["error"].(map[string]any)
		log.Fatalf("%v: %v", e["code"], e["message"])
	}
	fmt.Println(data["auto_extracted"])
}
```

POST`/v1/requests`[≈ 1 credit](https://docs.virginproxy.com/billing/#cost)[Open in Playground](https://dash.virginproxy.com/playground#request=eyJ1cmwiOiJodHRwczovL3Nob3AuZXhhbXBsZS9wL3RyYWlsLXJ1bm5lci0yIiwiYXV0b19leHRyYWN0IjoicHJvZHVjdCJ9)

*Response (shortened):*

```json
{
  "status": 200,
  "auto_extracted": {
    "type": "product",
    "data": {
      "name": "Trail Runner 2",
      "brand": "Example",
      "sku": "TR2-42",
      "gtin": "4006381333931",
      "price": 129.9,
      "currency": "EUR",
      "availability": "in_stock",
      "rating": { "value": 4.6, "count": 213 },
      "images": ["https://shop.example/img/tr2.jpg"],
      "offers": [{ "price": 129.9, "currency": "EUR", "availability": "in_stock", "seller": "Example Store" }],
      "variants": []
    },
    "sources": ["json-ld", "microdata"],
    "confidence": 0.95
  },
  "cost": { "credits": 1 }
}
```

## Types and fields

| auto_extract | Fields of data |
| --- | --- |
| `product` | name, brand, description, sku, gtin, mpn, url, images[], price, currency, availability (in_stock, out_of_stock, preorder, unknown), condition, rating {value, count}, offers[], variants[] |
| `article` | headline, description, author[], published_at, modified_at, section, tags[], image, text, word_count, language |
| `job` | title, company, location, remote, employment_type, salary {min, max, currency, period}, posted_at, valid_through, description, apply_url |
| `review_list` | item_name, rating {value, count}, reviews[{author, rating, title, text, date}] |
| `recipe` | name, description, image, prep_time, cook_time, total_time, yield, ingredients[], steps[], nutrition {calories}, rating |
| `event` | name, description, start, end, location {name, address}, organizer, url, offers[], status |
| `organization` | name, legal_name, url, logo, email, phone, address {street, city, zip, region, country}, same_as[] |

Missing fields are `null` (lists `[]`). Dates are ISO 8601, prices are numbers with `currency` beside them. `sources` says where the data came from; `confidence` (0 to 1) is lower when most of it came from the page text rather than structured data. When a page has no such record, `auto_extracted` is `null`.

## What it costs

Nothing extra: it is part of the request, priced as usual (1 credit per started MB). It works with [render](https://docs.virginproxy.com/render/) for pages that build their data with JavaScript, in [jobs](https://docs.virginproxy.com/jobs/), [crawls](https://docs.virginproxy.com/crawl/) and [monitors](https://docs.virginproxy.com/monitors/).

> **Tip:** For your own fields use [extract](https://docs.virginproxy.com/extract/) with CSS, XPath or JSON paths – both can be sent together.
