Get an API key Your API keys

Extract data without selectors

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 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"
  }'
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"])
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);
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)
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
$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;
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"])
}
require "json"
require "net/http"

uri = URI("https://api.virginproxy.com/v1/requests")
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer " + ENV.fetch("VP_KEY")
req["Content-Type"] = "application/json"
req.body = JSON.generate({
  "url" => "https://shop.example/p/trail-runner-2",
  "auto_extract" => "product",
})

res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true, read_timeout: 180) { |http| http.request(req) }
data = JSON.parse(res.body)
abort(data["error"]["code"] + ": " + data["error"]["message"]) unless res.is_a?(Net::HTTPSuccess)
puts JSON.pretty_generate(data["auto_extracted"])
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;

public class Main {
    public static void main(String[] args) throws Exception {
        String payload = """
            {
              "url": "https://shop.example/p/trail-runner-2",
              "auto_extract": "product"
            }
            """;
        HttpRequest req = HttpRequest.newBuilder(URI.create("https://api.virginproxy.com/v1/requests"))
            .header("Authorization", "Bearer " + System.getenv("VP_KEY"))
            .header("Content-Type", "application/json")
            .timeout(Duration.ofSeconds(180))
            .POST(HttpRequest.BodyPublishers.ofString(payload))
            .build();
        HttpResponse<String> res = HttpClient.newHttpClient().send(req, HttpResponse.BodyHandlers.ofString());
        if (res.statusCode() >= 300) {
            System.err.println(res.statusCode() + " " + res.body()); // the error object: code, message
            System.exit(1);
        }
        System.out.println(res.body()); // JSON: read it with the JSON library of your choice
    }
}
using System.Net.Http.Headers;
using System.Text;
using System.Text.Json;

using var http = new HttpClient { Timeout = TimeSpan.FromSeconds(180) };
http.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("VP_KEY"));
var payload = """
    {
      "url": "https://shop.example/p/trail-runner-2",
      "auto_extract": "product"
    }
    """;
var req = new HttpRequestMessage(HttpMethod.Post, "https://api.virginproxy.com/v1/requests");
req.Content = new StringContent(payload, Encoding.UTF8, "application/json");
var res = await http.SendAsync(req);
using var data = JsonDocument.Parse(await res.Content.ReadAsStringAsync());
if (!res.IsSuccessStatusCode)
{
    var e = data.RootElement.GetProperty("error");
    Console.Error.WriteLine(e.GetProperty("code") + ": " + e.GetProperty("message"));
    Environment.Exit(1);
}
Console.WriteLine(data.RootElement.GetProperty("auto_extracted"));
Response (shortened)
{
  "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_extractFields of data
productname, brand, description, sku, gtin, mpn, url, images[], price, currency, availability (in_stock, out_of_stock, preorder, unknown), condition, rating {value, count}, offers[], variants[]
articleheadline, description, author[], published_at, modified_at, section, tags[], image, text, word_count, language
jobtitle, company, location, remote, employment_type, salary {min, max, currency, period}, posted_at, valid_through, description, apply_url
review_listitem_name, rating {value, count}, reviews[{author, rating, title, text, date}]
recipename, description, image, prep_time, cook_time, total_time, yield, ingredients[], steps[], nutrition {calories}, rating
eventname, description, start, end, location {name, address}, organizer, url, offers[], status
organizationname, 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 for pages that build their data with JavaScript, in jobs, crawls and monitors.

Tip

For your own fields use extract with CSS, XPath or JSON paths – both can be sent together.

Was this page helpful?

Last updated