Get an API key Your API keys

Map a website

POST /v1/map lists the addresses of a website: the links on the page you give plus everything in the site's sitemaps, each address once, only from the same site. Use it to plan a crawl, to find all product or article pages, or to give an AI agent a table of contents.

Map a site

curl https://api.virginproxy.com/v1/map \
  -H "Authorization: Bearer $VP_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://www.virginproxy.com/en/",
    "search": "features",
    "limit": 3
  }'
import os, requests

r = requests.post(
    "https://api.virginproxy.com/v1/map",
    headers={"Authorization": "Bearer " + os.environ["VP_KEY"]},
    json={
        "url": "https://www.virginproxy.com/en/",
        "search": "features",
        "limit": 3,
    },
    timeout=120,
)
data = r.json()
if not r.ok:
    raise SystemExit(data["error"]["code"] + ": " + data["error"]["message"])
print(data["total"], data["truncated"])
print(data["links"])
const res = await fetch("https://api.virginproxy.com/v1/map", {
  method: "POST",
  headers: { Authorization: "Bearer " + process.env.VP_KEY, "Content-Type": "application/json" },
  body: JSON.stringify({
    url: "https://www.virginproxy.com/en/",
    search: "features",
    limit: 3,
  }),
  signal: AbortSignal.timeout(120_000),
});
const data = await res.json();
if (!res.ok) throw new Error(data.error.code + ": " + data.error.message);
console.log(data.total, data.truncated);
console.log(data.links);
from virginproxy import VirginProxy  # docs.virginproxy.com/sdk/virginproxy.py

vp = VirginProxy()  # reads VP_KEY
data = vp.call("POST", "/v1/map", {
    "url": "https://www.virginproxy.com/en/",
    "search": "features",
    "limit": 3,
})
print(data)
import { VirginProxy } from "./virginproxy.mjs"; // docs.virginproxy.com/sdk/virginproxy.mjs

const vp = new VirginProxy(); // reads VP_KEY
const data = await vp.map({
  url: "https://www.virginproxy.com/en/",
  search: "features",
  limit: 3,
});
console.log(data);
<?php
$ch = curl_init("https://api.virginproxy.com/v1/map");
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 120,
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer " . getenv("VP_KEY"),
        "Content-Type: application/json",
    ],
    CURLOPT_POSTFIELDS => json_encode([
        "url" => "https://www.virginproxy.com/en/",
        "search" => "features",
        "limit" => 3,
    ], 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["total"], " ", $data["truncated"], PHP_EOL;
echo json_encode($data["links"], 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://www.virginproxy.com/en/",
  "search": "features",
  "limit": 3
}`)
	req, err := http.NewRequest("POST", "https://api.virginproxy.com/v1/map", 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: 120 * 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["total"], data["truncated"])
	fmt.Println(data["links"])
}
require "json"
require "net/http"

uri = URI("https://api.virginproxy.com/v1/map")
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer " + ENV.fetch("VP_KEY")
req["Content-Type"] = "application/json"
req.body = JSON.generate({
  "url" => "https://www.virginproxy.com/en/",
  "search" => "features",
  "limit" => 3,
})

res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true, read_timeout: 120) { |http| http.request(req) }
data = JSON.parse(res.body)
abort(data["error"]["code"] + ": " + data["error"]["message"]) unless res.is_a?(Net::HTTPSuccess)
puts [data["total"], data["truncated"]].join(" ")
puts JSON.pretty_generate(data["links"])
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://www.virginproxy.com/en/",
              "search": "features",
              "limit": 3
            }
            """;
        HttpRequest req = HttpRequest.newBuilder(URI.create("https://api.virginproxy.com/v1/map"))
            .header("Authorization", "Bearer " + System.getenv("VP_KEY"))
            .header("Content-Type", "application/json")
            .timeout(Duration.ofSeconds(120))
            .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(120) };
http.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("VP_KEY"));
var payload = """
    {
      "url": "https://www.virginproxy.com/en/",
      "search": "features",
      "limit": 3
    }
    """;
var req = new HttpRequestMessage(HttpMethod.Post, "https://api.virginproxy.com/v1/map");
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("total") + " " + data.RootElement.GetProperty("truncated"));
Console.WriteLine(data.RootElement.GetProperty("links"));
POST/v1/map
Response
{
  "url": "https://www.virginproxy.com/en/",
  "host": "www.virginproxy.com",
  "links": [
    { "url": "https://www.virginproxy.com/en/features/", "text": "Features", "source": "page" },
    { "url": "https://www.virginproxy.com/en/features/javascript-rendering/", "text": "JavaScript rendering", "source": "page" },
    { "url": "https://www.virginproxy.com/en/features/screenshot-api/", "text": "Screenshot API", "source": "page" }
  ],
  "total": 70,
  "truncated": true,
  "sitemaps": { "read": 1 },
  "requests": [
    { "id": "req_h76MlP6HztFCfnbL5huN", "url": "https://www.virginproxy.com/en/", "status": 200, "credits": 1 },
    { "id": "req_XGP2qcw58HmZ932dai9T", "url": "https://www.virginproxy.com/robots.txt", "status": 200, "credits": 1 },
    { "id": "req_cyoIclUmFy3pkmFRcOpe", "url": "https://www.virginproxy.com/sitemap.xml", "status": 200, "credits": 1 }
  ],
  "cost": { "credits": 3, "credits_used": 43, "credits_included": 1000 }
}

How it works

  1. The page is read and its links are collected (with their text).
  2. robots.txt of the site is read for Sitemap: lines. Without any, /sitemap.xml is tried.
  3. Sitemaps are read, also sitemap indexes and .gz files, up to 5 files.
  4. Only addresses of the same site are kept (www. counts as the same), without #fragments, each once – page links first, in page order, then sitemap entries.

sitemaps.stopped says why reading sitemaps ended early, if it did: max_credits reached, time limit reached or after the first 5 files.

Options

FieldDefaultMeaning
urlrequiredA page of the site, usually its home page.
sitemap"include"include: the page's links and the sitemaps. skip: only the page. only: only the sitemaps (the page is not loaded).
include_subdomainsfalseAlso keep addresses on subdomains (blog.example.com for example.com).
search–Keep only addresses (or link texts) that contain this text, case ignored. 1 to 200 characters.
limit1000Return at most this many addresses, 1 to 5,000. total says how many were found.
renderfalseLoad the page in a browser first (10 credits or more), for menus built by JavaScript.
browser"chrome"Browser profile for the reads.
locale"de-DE"Language of the visitor.
session–Session name for all reads.
max_credits–Bound for all reads of this call together, 1 to 1,000.
tag–Your tag; every read is in your request log with it.
robots"ignore""respect" leaves out addresses the site's robots.txt disallows, "report" keeps them marked with "disallowed": true.

What it costs

Every page and file read is an ordinary request: it is in your request log and costs what any request costs – 1 credit per started MB. A typical map costs 3 credits (page, robots.txt, one sitemap). At most it reads the page, robots.txt and 5 sitemap files of up to 10 credits each. requests lists every read with its cost, cost.credits is the sum. max_credits bounds the whole call.

When the page itself does not answer, the call fails like a request (timeout, target_unreachable …, not charged). A missing robots.txt or sitemap is no error: they are simply left out.

Tip

The reads follow each other quickly. If your plan allows few requests per second, map waits for your rate between them instead of failing – a map on the Free plan takes a few seconds.

Next: crawl what you found

Hand the addresses to a job to fetch them all, or let a crawl find and fetch the pages in one go.

Was this page helpful?

Last updated