# Clusters

A [cluster](https://publicwww.com/docs/clusters/) is a saved list of websites. Through the API you can make one from a search or from your own list, combine clusters, and pull values out of the page source of every site in one - contacts, social profiles, analytics and tag ids, anything a regular expression can match.

## The endpoints

| Endpoint | Method | What it does |
| --- | --- | --- |
| `/v1/clusters` | GET | The account's clusters, newest first: id, name, number of domains, creation time. |
| `/v1/clusters` | POST | Create a cluster from a search (`query`, optional `limit`) or from a list (`domains`); optional `name`. |
| `/v1/clusters/{id}` | GET | The cluster and a page of its domains: `page`, `per_page` (up to 10000), `format=txt` for one domain per line. |
| `/v1/clusters/combine` | POST | A new cluster from existing ones: `operation` and, or or diff, `clusters` - a list of ids. |
| `/v1/clusters/{id}/extract` | GET, POST | Extract values with `fields`, `presets` and `regex`, part by part: `offset`, `limit` (up to 1000 sites per call), `format` json, xml or csv; with csv, `delimiter` and `header`. |
| `/v1/clusters/{id}/signatures` | GET, POST | Code common to the cluster's websites, as ready searches for more like them. |
| `/v1/clusters/presets` | GET | The fields with their columns, and the presets. |
| `/v1/clusters/{id}/rename` | POST | New `name`. |
| `/v1/clusters/{id}/delete` | POST | Delete the cluster for good. |

Everything that changes a cluster is a POST with a JSON body - no PUT or DELETE, so any client that can search can manage clusters too. The token, the rate limit and the error format are the same as for [search](https://publicwww.com/docs/api/requests/); the cluster numbers in your `/v1/account` answer show how many you have and how many extraction points are left today.

## Creating a cluster

**From a search**: the results of the query, up to your plan's rows per query, become the cluster - or only the first `limit` of them, in the search's own order. A cluster holds each domain once, and `limit` counts domains: with `depth:` several pages of one website make one. It costs one search, the same as `/v1/search`.

```
curl https://api.publicwww.com/v1/clusters \
     -H "Authorization: Bearer $PUBLICWWW_KEY" \
     -H "Content-Type: application/json" \
     -d '{"query": "\"googletagmanager.com/gtm.js\"", "name": "GTM sites"}'

{"id": 7, "name": "GTM sites", "size": 100000, "created": "2026-10-10T20:21:30Z",
 "query": "\"googletagmanager.com/gtm.js\"", "total": 1000000, "total_capped": true,
 "index_complete": true, "max_size": 100000}
```

`size` is at most `max_size`, the plan's cluster size. `total` is what the search found, not the cluster's size: up to 1,000,000, and at that ceiling `total_capped` is `true`. `total_exact`, `total_estimate`, `original_query` and `query_note` work as in [a search](https://publicwww.com/docs/api/requests/).

To make a cluster of websites about a topic, use `like:` and pass `limit`: a search by similarity removes nothing, so without it the cluster takes your plan's maximum.

```
curl https://api.publicwww.com/v1/clusters \
     -H "Authorization: Bearer $PUBLICWWW_KEY" \
     -H "Content-Type: application/json" \
     -d '{"query": "like:\"online course\" site:de", "limit": 100, "name": "Online courses, .de"}'
```

**From a list**: domains or urls, as a JSON array or one per line. Each line is cut to its domain: a page address or an email gives the domain, the port is dropped. Only sites that are in the index are kept. A name with www. that is not in the index is looked up without the www. If none is in the index, the answer is `400 domains_not_found` and no cluster is created. A list costs nothing.

```
curl https://api.publicwww.com/v1/clusters \
     -H "Authorization: Bearer $PUBLICWWW_KEY" \
     -H "Content-Type: application/json" \
     -d '{"domains": ["example.com", "https://www.example.org/about", "example.org",
                      "example.net", "not-in-the-index.com"], "name": "Prospects"}'

{"id": 8, "name": "Prospects", "size": 3, "created": "2026-11-08T12:05:46Z",
 "submitted": 5, "received": 5,
 "dropped": {"not_a_domain": 0, "duplicate": 1, "not_in_index": 1, "over_limit": 0},
 "max_size": 100000}
```

`received` is how many non-empty lines you sent, `submitted` how many different names they gave, `size` how many went into the cluster. `dropped` counts the rest by reason, so `size` plus the four numbers is `received`: `not_a_domain` - a line with no domain in it; `duplicate` - a name that was already in the list, including `www.example.org` next to `example.org`; `not_in_index` - a name the index does not have; `over_limit` - names after the plan's cluster size was reached, not checked. `max_size` is that size. A `400 domains_not_found` answer carries the same counts.

The plan caps the number of domains in a cluster, and an account keeps up to 100 clusters. With 100 already there, creating another answers `409 cluster_limit` - nothing is deleted on your behalf; delete the ones you no longer need first.

## Combining clusters

```
curl https://api.publicwww.com/v1/clusters/combine \
     -H "Authorization: Bearer $PUBLICWWW_KEY" \
     -H "Content-Type: application/json" \
     -d '{"operation": "diff", "clusters": [7, 3], "name": "GTM, not yet contacted"}'

{"id": 9, "name": "GTM, not yet contacted", "size": 99140, "created": "2026-11-08T12:10:02Z",
 "operation": "diff", "from": [7, 3], "max_size": 100000}
```

`and` keeps the domains that are in every cluster, `or` those in any of them, and `diff` those in the first cluster but not in the second - exactly two. Combining costs nothing.

## Reading, renaming, deleting

```
curl -H "Authorization: Bearer $PUBLICWWW_KEY" https://api.publicwww.com/v1/clusters

{"count": 2, "max": 100, "clusters": [
  {"id": 9, "name": "GTM, not yet contacted", "size": 99140, "created": "2026-11-08T12:10:02Z"},
  {"id": 8, "name": "Prospects", "size": 3, "created": "2026-11-08T12:05:46Z"}
]}

curl -H "Authorization: Bearer $PUBLICWWW_KEY" "https://api.publicwww.com/v1/clusters/8?per_page=2"

{"id": 8, "name": "Prospects", "size": 3, "created": "2026-11-08T12:05:46Z",
 "page": 1, "per_page": 2, "total_pages": 2, "domains": ["example.com", "example.org"]}

curl https://api.publicwww.com/v1/clusters/8/rename \
     -H "Authorization: Bearer $PUBLICWWW_KEY" \
     -H "Content-Type: application/json" \
     -d '{"name": "Prospects, November"}'

{"id": 8, "name": "Prospects, November", "size": 3, "created": "2026-11-08T12:05:46Z"}

curl -X POST -H "Authorization: Bearer $PUBLICWWW_KEY" https://api.publicwww.com/v1/clusters/8/delete

{"deleted": 8, "name": "Prospects, November"}
```

`max` is how many clusters the account can keep. A cluster's domains come in pages of `per_page`, 1000 by default; with `format=txt` they come as plain text, one per line, with the count in the `X-Total-Results` header.

## Extracting data

Extraction reads the indexed pages of every site in the cluster and returns a table. The easiest way is `fields` - groups of values, the same as on the extraction form; each adds a column or two:

| Field | Columns | What it pulls out |
| --- | --- | --- |
| `name` | `name`, `kind` | The organization's name and kind of business from schema.org markup |
| `social` | `social` | Links to the site's social profiles, regional networks too |
| `email` | `email` | mailto: links, schema.org email, addresses hidden by Cloudflare |
| `phone` | `phone` | tel: links and schema.org telephone |
| `messengers` | `messengers` | Links to WhatsApp, Telegram, Viber, LINE, KakaoTalk, WeChat, Messenger, Signal, Zalo, Threema |
| `address` | `address`, `coordinates` | The postal address from schema.org markup; latitude and longitude from an embedded map or geo tags |
| `apps` | `apps` | Links to the site's apps in Google Play, the App Store and other stores |
| `languages` | `languages` | Languages of the pages, two-letter codes |
| `registration` | `registration` | Company and tax numbers: VAT, HRB, SIREN and SIRET, KvK, Company No, CNPJ, ABN, ИНН and ОГРН, ICP and others |

A column holds up to 10 values of a site - of a field, a preset or your own expression; accounts that stand on thousands of unrelated sites - parked domains, hosting and site-builder templates - are left out. The full list with columns is at `GET /v1/clusters/presets`, which also lists the presets - single networks by name, read the same way: `email`, `phone`, `whatsapp`, `telegram`, `viber`, `line`, `facebook`, `instagram`, `x`, `linkedin`, `youtube`, `tiktok`, `pinterest`, `threads`, `bluesky`, `discord`, `github`, `google_play` (the package name) and `app_store` (the app's link).

Or write your own: a regular expression in slashes (or pipes) with optional `i`, `m`, `s`, `u` flags, up to 200 characters. A slash inside is written `\/`, or use pipes: `|https://example.com/([a-z]+)|i`. The first capturing group is the value, as in [`snipexp:`](https://publicwww.com/docs/query-syntax/regex/); an expression without one gives the whole match. Up to ten expressions per call, presets included; fields do not count against the ten.

A value is cut to 1000 characters, and a site gives at most 32 KB of values across all columns; values past that are neither returned nor counted.

```
curl https://api.publicwww.com/v1/clusters/7/extract \
     -H "Authorization: Bearer $PUBLICWWW_KEY" \
     -H "Content-Type: application/json" \
     -d '{"fields": ["name", "email"], "presets": ["linkedin"], "regex": ["/data-site-id=\"([0-9]+)\"/i"], "limit": 1000}'

{
  "cluster": 7, "name": "GTM sites", "size": 100000,
  "offset": 0, "scanned": 1000, "in_index": 1000, "with_matches": 941,
  "next_offset": 1000, "remaining": 99000,
  "columns": ["name", "kind", "email", "linkedin", "regexp_1"],
  "regex": ["/data-site-id=\"([0-9]+)\"/i"],
  "points_used": 946.9, "points_left": 99053,
  "rows": [
    { "domain": "example.com", "values": [["Example Dental"], ["Dentist"], ["info@example.com"], ["https://www.linkedin.com/company/example"], []], "matches": 4 }
  ]
}
```

**Part by part.** One call goes through up to 1000 sites of the cluster, starting at `offset`. Call again with `offset` set to `next_offset` until it comes back `null`; `remaining` is how many sites of the cluster are still ahead. A long call also stops by itself with `"stopped": "time_limit"`: nothing is wrong, continue with `next_offset`. Sites where nothing matched are left out; `skip_empty=0` lists them too. `columns` names the lists in each row's `values`, in the same order: the columns of the fields, then a preset by its name, your own expressions as `regexp_1`, `regexp_2` and so on; `regex` lists your own expressions. `matches` is how many values are in the row. In the answer, `size` is the whole cluster, `scanned` how many of its sites this call went through, `in_index` how many of those are in the index and `with_matches` how many of those gave a value. A site that is not in the index gives no row, even with `skip_empty=0`.

**As a file.** `format=csv` gives a row per site: the domain, then a cell per name in `columns`, several values of one column on separate lines of the cell; `header=1` puts `domain` and those names on a first line. Comma separated, unlike search results; `delimiter` sets another character. The next offset is in the `X-Next-Offset` header, empty at the end, the points left in `X-Points-Left`. A value a spreadsheet would run as a formula gets a leading apostrophe, unless it is made only of number characters, such as `+49 211 123`. `tsv` and `txt` are `400 format_not_available`, before anything is spent.

**Points.** Extraction spends the daily extraction allowance of your plan: each site found in the index costs 1 point if anything was found on it, 0.1 if nothing. `points_used` is what this call spent, `points_left` what is left today. Every call is paid for, a repeat of the same sites too: keep the answer, and after a trial go on from `next_offset` rather than start over. When the points run out the call stops early with `"stopped": "extract_quota_exceeded"` and returns what it has; a call with nothing left gets `429 extract_quota_exceeded`. Try an expression on a small `limit` first - see [cluster limits](https://publicwww.com/docs/clusters/limits/).

## Signatures

`/v1/clusters/{id}/signatures`, by GET or POST, finds code that leads to more websites like the ones in the cluster, as ready searches - see [Build signatures](https://publicwww.com/docs/search/build-signatures/). It spends nothing, and the answer has the same shape as the MCP tool `build_signatures`.

```
curl -H "Authorization: Bearer $PUBLICWWW_KEY" https://api.publicwww.com/v1/clusters/7/signatures

{
  "id": 7, "name": "GTM sites", "size": 100000, "created": "2026-10-10T20:21:30Z",
  "domains_used": 100, "websites_with_code": 98,
  "signatures": [
    { "query": "googletagmanager.com/gtm.js", "search": "\"googletagmanager.com/gtm.js\"",
      "in_cluster": 98, "coverage": "98 of 100", "in_all": false,
      "websites": 980000, "websites_max": null, "technology": "Google Tag Manager",
      "domains": ["example.com", "example.net", "..."] },
    { "query": "cdn.example.com/network/site.js", "search": "\"cdn.example.com/network/site.js\"",
      "in_cluster": 12, "coverage": "12 of 100", "in_all": false, "websites": null, "websites_max": 210,
      "domains": ["example.org", "..."] }
  ]
}
```

Pass `search` - the `query` in double quotes - to `/v1/search` to find more such websites; start from the top: the list is ordered best first. `domains_used` is how many of the cluster's websites were looked at, `websites_with_code` how many of them had code to read, and `in_cluster` how many have this code - `coverage` says the same as "98 of 100", `in_all` is `true` when every one of them has it. `websites` is a rough count in the whole index, `null` when rarer than `websites_max`; the search gives the exact number. `technology` is there when the code belongs to a technology we know, and `domains` lists the websites of the cluster that have the code. When nothing ties the websites together, `signatures` is empty and `note` says so.

## A whole cluster, in code

Create a cluster from the first 100 results of a search and write out the values extracted from its sites; `limit` keeps the first run cheap. The [client libraries](https://github.com/publicwww-com) have the same as ready functions and a command line.

### Python

```
import csv, os, time, requests

KEY  = os.environ["PUBLICWWW_KEY"]
BASE = "https://api.publicwww.com"
H    = {"Authorization": "Bearer " + KEY}

def call(method, path, body=None):
    while True:
        r = requests.request(method, BASE + path, headers=H, json=body)
        if r.status_code == 429 and r.json()["error"]["code"] == "too_many_requests":
            time.sleep(int(r.headers.get("Retry-After", 30)))
            continue
        r.raise_for_status()
        return r.json()

cluster = call("POST", "/v1/clusters", {"query": '"googletagmanager.com/gtm.js"', "limit": 100})
offset = 0
with open("extract.csv", "w", newline="") as f:
    out = csv.writer(f)
    while offset is not None:
        part = call("POST", "/v1/clusters/%d/extract" % cluster["id"],
                    {"fields": ["name", "email", "phone"], "offset": offset})
        for row in part["rows"]:
            out.writerow([row["domain"]] + [" ".join(v) for v in row["values"]])
        offset = part["next_offset"]
```

### JavaScript (Node 18+)

```
const BASE = "https://api.publicwww.com";
const H = { Authorization: "Bearer " + process.env.PUBLICWWW_KEY,
            "Content-Type": "application/json" };

async function call(method, path, body) {
  for (;;) {
    const r = await fetch(BASE + path, { method, headers: H,
                                         body: body && JSON.stringify(body) });
    const data = await r.json();
    if (r.status === 429 && data.error.code === "too_many_requests") {
      await new Promise(ok => setTimeout(ok, 1000 * (r.headers.get("Retry-After") || 30)));
      continue;
    }
    if (!r.ok) throw new Error(data.error.message);
    return data;
  }
}

const cluster = await call("POST", "/v1/clusters", { query: '"hotjar.com"', limit: 100 });
for (let offset = 0; offset !== null; ) {
  const part = await call("POST", `/v1/clusters/${cluster.id}/extract`,
                          { fields: ["name", "email", "phone"], offset });
  for (const row of part.rows) console.log(row.domain, row.values.map(v => v.join(" ")).join(";"));
  offset = part.next_offset;
}
```

### PHP

```
<?php
function call ($method, $path, $body = null) {
    $ch = curl_init ("https://api.publicwww.com" . $path);
    curl_setopt_array ($ch, [
        CURLOPT_CUSTOMREQUEST  => $method,
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_HTTPHEADER     => ["Authorization: Bearer " . getenv ("PUBLICWWW_KEY"),
                                   "Content-Type: application/json"],
        CURLOPT_POSTFIELDS     => $body === null ? null : json_encode ($body),
    ]);
    $data = json_decode (curl_exec ($ch), true);
    if (isset ($data ["error"])) throw new Exception ($data ["error"]["message"]);
    return $data;
}

$cluster = call ("POST", "/v1/clusters", ["query" => '"jquery.min.js"', "limit" => 100]);
$out = fopen ("extract.csv", "w");
for ($offset = 0; $offset !== null; ) {
    $part = call ("POST", "/v1/clusters/" . $cluster ["id"] . "/extract",
                  ["fields" => ["name", "email", "phone"], "offset" => $offset]);
    foreach ($part ["rows"] as $row)
        fputcsv ($out, array_merge ([$row ["domain"]], array_map (fn ($v) => join (" ", $v), $row ["values"])));
    $offset = $part ["next_offset"];
}
```

### Go

```
package main

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

func call(method, path string, body, out any) error {
	b, _ := json.Marshal(body)
	req, _ := http.NewRequest(method, "https://api.publicwww.com"+path, bytes.NewReader(b))
	req.Header.Set("Authorization", "Bearer "+os.Getenv("PUBLICWWW_KEY"))
	req.Header.Set("Content-Type", "application/json")
	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		return err
	}
	defer resp.Body.Close()
	if resp.StatusCode >= 300 {
		return fmt.Errorf("publicwww: %s", resp.Status)
	}
	return json.NewDecoder(resp.Body).Decode(out)
}

func main() {
	var cluster struct{ ID int `json:"id"` }
	if err := call("POST", "/v1/clusters", map[string]any{"query": `"googletagmanager.com/gtm.js"`, "limit": 100}, &cluster); err != nil {
		panic(err)
	}
	for offset := 0; ; {
		var part struct {
			Rows []struct {
				Domain string     `json:"domain"`
				Values [][]string `json:"values"`
			} `json:"rows"`
			NextOffset *int `json:"next_offset"`
		}
		path := fmt.Sprintf("/v1/clusters/%d/extract", cluster.ID)
		if err := call("POST", path, map[string]any{"fields": []string{"name", "email", "phone"}, "offset": offset}, &part); err != nil {
			panic(err)
		}
		for _, r := range part.Rows {
			cells := []string{r.Domain}
			for _, v := range r.Values {
				cells = append(cells, strings.Join(v, " "))
			}
			fmt.Println(strings.Join(cells, ";"))
		}
		if part.NextOffset == nil {
			break
		}
		offset = *part.NextOffset
	}
}
```

### Ruby

```
require "json"
require "net/http"

def call(path, body)
  uri = URI("https://api.publicwww.com" + path)
  req = Net::HTTP::Post.new(uri, "Authorization" => "Bearer #{ENV.fetch('PUBLICWWW_KEY')}",
                                  "Content-Type" => "application/json")
  req.body = body.to_json
  res = Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |h| h.request(req) }
  data = JSON.parse(res.body)
  raise data["error"]["message"] if data["error"]
  data
end

cluster = call("/v1/clusters", { query: '"hotjar.com"', limit: 100 })
offset = 0
while offset
  part = call("/v1/clusters/#{cluster['id']}/extract", { fields: %w[name email phone], offset: offset })
  part["rows"].each { |r| puts [r["domain"], *r["values"].map { |v| v.join(" ") }].join(";") }
  offset = part["next_offset"]
end
```

## Errors

| Status and code | Meaning |
| --- | --- |
| `404 cluster_not_found` | No cluster with that id on this account. |
| `409 cluster_limit` | The account already keeps 100 clusters. |
| `400 invalid_regex` | An expression is not a PCRE in slashes or pipes, up to 200 characters. |
| `400 unknown_field` | No such field; the answer lists them. |
| `400 unknown_preset` | No such preset; the answer lists them. |
| `400 missing_source`, `ambiguous_source` | Creating needs either `query` or `domains`. |
| `400 domains_not_found` | None of the domains is in the index; no cluster was created. |
| `400 format_not_available` | `csv` anywhere but extract, `txt` anywhere but a cluster's domains, `tsv` on any of these endpoints. |
| `429 extract_quota_exceeded` | Today's extraction points are used up. |
| `503 unavailable` | Signatures are temporarily unavailable. Try again later. |

The full list is on the [errors](https://publicwww.com/docs/api/errors/) page and in the API's own description at [https://api.publicwww.com/](https://api.publicwww.com/). In an AI assistant the same operations are [MCP tools](https://publicwww.com/docs/mcp/tools/).

Source: https://publicwww.com/docs/api/clusters/
