Output formats
Most of a web page is navigation, scripts and layout. With format you get what you actually read: Markdown for language models and notes, plain text for search and analysis, or clean HTML that is safe to store and show.
curl https://api.virginproxy.com/v1/requests \
-H "Authorization: Bearer $VP_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://quotes.toscrape.com/",
"format": "markdown",
"main_content": true
}'import os, requests
r = requests.post(
"https://api.virginproxy.com/v1/requests",
headers={"Authorization": "Bearer " + os.environ["VP_KEY"]},
json={
"url": "https://quotes.toscrape.com/",
"format": "markdown",
"main_content": True,
},
timeout=180,
)
data = r.json()
if not r.ok:
raise SystemExit(data["error"]["code"] + ": " + data["error"]["message"])
print(data["format"], data["cost"]["credits"])
print(data["body"])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://quotes.toscrape.com/",
format: "markdown",
main_content: true,
}),
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.format, data.cost.credits);
console.log(data.body);from virginproxy import VirginProxy # docs.virginproxy.com/sdk/virginproxy.py
vp = VirginProxy() # reads VP_KEY
data = vp.request({
"url": "https://quotes.toscrape.com/",
"format": "markdown",
"main_content": True,
})
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://quotes.toscrape.com/",
format: "markdown",
main_content: true,
});
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://quotes.toscrape.com/",
"format" => "markdown",
"main_content" => true,
], JSON_UNESCAPED_SLASHES),
]);
$data = json_decode(curl_exec($ch), true);
if (isset($data["error"])) {
exit($data["error"]["code"] . ": " . $data["error"]["message"] . PHP_EOL);
}
echo $data["format"], " ", $data["cost"]["credits"], PHP_EOL;
echo $data["body"], PHP_EOL;package main
import (
"bytes"
"encoding/json"
"fmt"
"log"
"net/http"
"os"
"time"
)
func main() {
payload := []byte(`{
"url": "https://quotes.toscrape.com/",
"format": "markdown",
"main_content": true
}`)
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["format"], data["cost"].(map[string]any)["credits"])
fmt.Println(data["body"])
}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://quotes.toscrape.com/",
"format" => "markdown",
"main_content" => true,
})
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 [data["format"], data["cost"]["credits"]].join(" ")
puts data["body"]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://quotes.toscrape.com/",
"format": "markdown",
"main_content": true
}
""";
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://quotes.toscrape.com/",
"format": "markdown",
"main_content": true
}
""";
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("format") + " " + data.RootElement.GetProperty("cost").GetProperty("credits"));
Console.WriteLine(data.RootElement.GetProperty("body"));/v1/requests≈ 1 creditOpen in Playground{
"id": "req_V7dLq2mTzR9aKc4xWb0E",
"status": 200,
"final_url": "https://quotes.toscrape.com/",
"headers": { "content-type": "text/html; charset=utf-8" },
"format": "markdown",
"body": "# Quotes to Scrape\n\n> “The world as we have created it is a process of our thinking.”\n>\n> by [Albert Einstein](https://quotes.toscrape.com/author/Albert-Einstein)\n\n…",
"body_encoding": "utf8",
"truncated": false,
"exit": { "ip": "203.0.113.42", "country": "DE" },
"bytes": { "up": 2004, "down": 14871 },
"duration_ms": 641,
"cost": { "credits": 1, "credits_used": 31, "credits_included": 1000 }
}The formats
| Value | What you get |
|---|---|
raw | Default. The body exactly as the target sent it. |
markdown | Headings as #, lists, links as [text](absolute URL), images as , tables as GitHub-style tables, code as fenced blocks. |
text | The readable text only, blocks separated by an empty line, no markup at all. |
clean_html | HTML without script, style, noscript, iframe and template, without on… event attributes and comments. Links and images are made absolute. |
Only the main content
"main_content": true keeps only the part of the page that carries its content before converting it. We take the <main> or <article> element with the most text; without one, the <body> without navigation, header, footer, sidebars, forms, scripts, frames and graphics. It works with every format, raw included.
Tip
Markdown plus main_content is usually the smallest input you can give a language model: often a tenth of the raw HTML.
Shape the conversion: format_options
| Field | Default | Meaning |
|---|---|---|
include_selector | – | A CSS selector: keep only this part of the page, e.g. article or #content. |
exclude_selector | – | A CSS selector: leave these parts out, e.g. nav, .ads, .cookie-banner. |
images | true | false: no images in the Markdown. |
links | true | false: links become plain text. |
max_pages | 100 | For documents: pages, slides or sheets at most, 1 to 500. |
Every converted answer carries tokens: about how many tokens the body is (about 4 characters per token in Latin script, 1 per character in Chinese, Japanese and Korean) – to plan what fits into a prompt.
Black out personal data: redact
redact replaces personal data in the text you get – the converted body, extracted, parsed and auto_extracted – before it leaves us. It needs a format (markdown, text or clean_html): a raw body is never changed. Kinds: email, phone, iban, card, ip, or true for all. Each becomes a marker such as [email]; redacted counts them, e.g. {"email": 2, "phone": 1}. Card numbers are checked with their check digit, so prices and order numbers stay.
{
"url": "https://example.com/contact",
"format": "text",
"redact": [
"email",
"phone"
]
}What changes in the response
formatsays which format was actually applied.bodyholds the converted text, always with"body_encoding": "utf8".headerskeep the target's originalcontent-type.- Formats apply to HTML and to documents (PDF, Word, Excel, PowerPoint, OpenDocument, CSV). Any other answer (JSON, images) comes back unchanged and the response says
"format": "raw". tokensestimates the length of the converted text for a language model.
In raw mode
GET /v1/raw takes format as a query parameter and returns the converted text directly, with a matching Content-Type: text/markdown, text/plain or text/html, each with charset=utf-8.
curl "https://api.virginproxy.com/v1/raw?url=https%3A%2F%2Fquotes.toscrape.com%2F&format=markdown" \
-H "Authorization: Bearer $VP_KEY" -o quotes.mdHTTP/2 200
content-type: text/markdown; charset=utf-8
x-vp-request-id: req_P3sNw8YhQe1bLt6uVx2C
x-vp-credits: 1
# Quotes to Scrape
> “The world as we have created it is a process of our thinking.”
…Cost
Converting costs nothing extra. You pay for what the target sent (bytes.down), not for the shorter output. Combine format with parse and extract freely: both always read the original HTML.
Was this page helpful?
Last updated