{
    "name": "PublicWWW Search API",
    "version": "v1",
    "docs": "https://publicwww.com/docs/api/",
    "docs_pages": {
        "query_syntax": "https://publicwww.com/docs/query-syntax/",
        "requests": "https://publicwww.com/docs/api/requests/",
        "formats": "https://publicwww.com/docs/api/formats/",
        "limits": "https://publicwww.com/docs/api/limits/",
        "errors": "https://publicwww.com/docs/api/errors/",
        "clusters": "https://publicwww.com/docs/api/clusters/",
        "examples": "https://publicwww.com/docs/api/examples/",
        "all_for_llms": "https://publicwww.com/llms.txt"
    },
    "clients": "https://github.com/publicwww-com",
    "openapi": "https://api.publicwww.com/openapi.json",
    "authentication": {
        "header": "Authorization: Bearer <your token>",
        "note": "A paid plan is required for searches and clusters; /v1/account works on any account. Tokens are issued at https://publicwww.com/profile/api . A token in the query string is not accepted here - it would end up in access logs and referrers.",
        "oauth": {
            "authorization_server": "https://publicwww.com",
            "metadata": "https://publicwww.com/.well-known/oauth-authorization-server",
            "resource_metadata": "https://api.publicwww.com/.well-known/oauth-protected-resource",
            "note": "Authorization code with PKCE (S256). client_id is the https URL of a client metadata document; there is no client registration. The token goes in the same Authorization: Bearer header and lives until revoked - no expiry, no refresh token. https://publicwww.com/docs/api/authentication/#oauth"
        }
    },
    "endpoints": [
        {
            "path": "/v1/search",
            "methods": [
                "GET",
                "POST"
            ],
            "params": {
                "query": "required. Same syntax as the website search box: \"exact phrase\", a b (both must appear), (a | b) either, -word excludes, site:de a domain zone, site:example.com one site, depth:all inner pages too, like:\"topic\" or like:example.com finds websites about a topic or like a given site: it orders by similarity and removes nothing, so limit it with a phrase or site: and read the first rows. Only a-z, 0-9 and _ are searched; other characters separate words. Several phrases: separate with newlines, or POST an array; all must match. Results come most popular first, or most similar first with like:. Syntax: https://publicwww.com/docs/query-syntax/",
                "page": "optional, default 1.",
                "per_page": "optional, default 100. Up to the row limit of your plan - see /v1/account.",
                "snippets": "optional, 1 to include matching text. Spends snippet quota.",
                "format": "optional, one of json, ndjson, xml, csv, tsv, txt. Default json.",
                "columns": "optional, comma separated subset of domain, url, rank, ranked, title, snippets (title and snippets with snippets=1).",
                "delimiter": "optional, for csv and tsv. Default ; and tab.",
                "header": "optional, 1 to put a header line on csv and tsv."
            },
            "note": "POST takes the same parameters as a JSON body, for queries too long or too multi-line to sit in a url.",
            "answer": {
                "total": "how many matched; a ceiling when total_capped is true. With depth: pages, not websites.",
                "total_capped": "present when there are more than total: narrow the query rather than paging on.",
                "total_exact": "present and false when the search reached its time limit: total is what was found in time, total_estimate about how many in all.",
                "truncated": "the plan cut this page.",
                "index_complete": "false when part of the index did not answer: the numbers are a lower bound.",
                "query_note": "present when the query uses like: or was read differently from what you sent.",
                "original_query": "present when the query was rewritten; query is what ran.",
                "results": "domain, url, rank (place by popularity, 1 is the most popular, an estimate with no guarantees; null if unranked), snippets if asked."
            }
        },
        {
            "path": "/v1/account",
            "methods": [
                "GET"
            ],
            "note": "Plan, quota and limits, clusters included. Does not spend quota."
        },
        {
            "path": "/v1/clusters",
            "methods": [
                "GET",
                "POST"
            ],
            "params": {
                "query": "POST: create the cluster from this search's results. Costs one search.",
                "domains": "POST: or from these names or urls (array, or one per line). Costs nothing.",
                "name": "POST: optional name.",
                "limit": "POST with query: take only the first N results, in the search's own order. Pass it with like:, or the cluster takes the plan's maximum."
            },
            "note": "GET lists the account's clusters, newest first. At most 100 per account: past that, POST answers 409 cluster_limit and deletes nothing."
        },
        {
            "path": "/v1/clusters/{id}",
            "methods": [
                "GET"
            ],
            "params": {
                "page": "optional, default 1.",
                "per_page": "optional, default 1000, up to 10000.",
                "format": "optional: json, xml, or txt (one domain per line)."
            },
            "note": "The cluster and a page of its domains."
        },
        {
            "path": "/v1/clusters/combine",
            "methods": [
                "POST"
            ],
            "params": {
                "operation": "and, or, or diff (first minus second).",
                "clusters": "array of ids.",
                "name": "optional."
            }
        },
        {
            "path": "/v1/clusters/{id}/extract",
            "methods": [
                "GET",
                "POST"
            ],
            "params": {
                "fields": "groups of values, a column or two each: name, social, email, phone, messengers, address, apps, languages, registration (GET /v1/clusters/presets lists their columns).",
                "presets": "single networks by name: email, phone, whatsapp, telegram, viber, line, facebook, instagram, x, linkedin, youtube, tiktok, pinterest, threads, bluesky, discord, github, google_play, app_store.",
                "regex": "your own: PCRE in slashes or pipes, flags imsu, the first capture group is the value, with no group the whole match. Up to 10 with the presets.",
                "offset": "where to start in the cluster; next_offset from the previous call.",
                "limit": "domains per call, up to 1000. Try a small limit first: every website gone through is paid for.",
                "skip_empty": "default 1: leave out sites where nothing matched.",
                "format": "json, xml, or csv.",
                "delimiter": "csv: default comma.",
                "header": "csv: 1 for a header line."
            },
            "note": "Spends extraction points: a site in the index costs 1 point if anything was found, 0.1 if nothing. Every call is paid for, a repeat of the same sites too: keep the answer and go on from next_offset."
        },
        {
            "path": "/v1/clusters/{id}/signatures",
            "methods": [
                "GET",
                "POST"
            ],
            "note": "Code common to the cluster's websites, as ready searches for more like them. Spends nothing."
        },
        {
            "path": "/v1/clusters/presets",
            "methods": [
                "GET"
            ],
            "note": "The presets with their expressions."
        },
        {
            "path": "/v1/clusters/{id}/rename",
            "methods": [
                "POST"
            ],
            "params": {
                "name": "the new name."
            }
        },
        {
            "path": "/v1/clusters/{id}/delete",
            "methods": [
                "POST"
            ],
            "note": "For good."
        }
    ],
    "mcp": {
        "url": "https://api.publicwww.com/mcp",
        "transport": "Streamable HTTP, JSON-RPC 2.0, one message per POST, application/json answers",
        "auth": "Authorization: Bearer <the same token> or OAuth; without signing in, the tool list and read_docs work, the other tools need a paid plan",
        "tools": [
            "search",
            "account",
            "read_docs",
            "list_clusters",
            "get_cluster",
            "create_cluster",
            "combine_clusters",
            "extract_from_cluster",
            "build_signatures",
            "rename_cluster",
            "delete_cluster"
        ],
        "docs": "https://publicwww.com/docs/mcp/"
    },
    "formats": {
        "json": "default. One object; results in an array.",
        "ndjson": "one JSON object per line, metadata first. For streaming into a pipeline.",
        "xml": "the same document as XML.",
        "csv": "semicolon separated, no header. Defaults to domain;rank. In cluster extraction: comma separated, domain then one column per expression.",
        "tsv": "tab separated, otherwise as csv.",
        "txt": "one url per line."
    },
    "errors": {
        "400 missing_query": "'query' was empty or absent.",
        "400 unknown_format": "'format' is not one of the formats above.",
        "400 unknown_column": "'columns' names a field that does not exist.",
        "400 format_not_available": "csv, tsv and txt only fit rows: search results; also csv for extraction and txt for a cluster's domains.",
        "400 invalid_parameter": "A parameter's value is not of its kind: page, per_page, offset or limit not a whole number in range, delimiter longer than one character, a cluster number that is not one.",
        "400 per_page_too_large": "'per_page' above what the plan allows.",
        "400 page_too_deep": "'page' * 'per_page' past the plan's rows per report: a plan covers the first N rows of a query.",
        "400 invalid_json": "POST body is not valid JSON.",
        "401 missing_key": "No Authorization: Bearer header.",
        "401 invalid_key": "The key does not name an account.",
        "403 plan_required": "The account has no paid plan.",
        "404 unknown_endpoint": "No such path.",
        "404 cluster_not_found": "No cluster with that id on this account.",
        "405 method_not_allowed": "Use GET, or POST; changes to clusters take POST.",
        "409 cluster_limit": "The account already keeps the most clusters it can; delete some first.",
        "400 missing_source": "Creating a cluster needs 'query' or 'domains'.",
        "400 ambiguous_source": "Both 'query' and 'domains' were sent.",
        "400 missing_domains": "'domains' held no usable name.",
        "400 domains_not_found": "None of the names in 'domains' is in the index; no cluster is created.",
        "400 invalid_operation": "'operation' is not and, or or diff.",
        "400 invalid_clusters": "'clusters' must list two or more ids, exactly two for diff.",
        "400 missing_name": "Renaming needs a non-empty 'name'.",
        "400 missing_regex": "Extraction needs 'fields', 'presets' or 'regex'; the answer lists the field and preset names.",
        "400 invalid_regex": "An expression is not a PCRE in slashes or pipes, up to 200 characters, flags imsu. A slash inside is written \\/, or use pipes.",
        "400 too_many_regex": "More than 10 expressions, presets included.",
        "400 unknown_preset": "A preset name that does not exist; the answer lists them.",
        "400 unknown_field": "A field name that does not exist; the answer lists them.",
        "429 extract_quota_exceeded": "Daily extraction points spent. Resets at UTC midnight.",
        "429 too_many_requests": "Arriving too fast. Wait Retry-After seconds and repeat.",
        "429 quota_exceeded": "Daily search quota spent. Resets at UTC midnight.",
        "429 snippet_quota_exceeded": "Daily snippet quota spent. Searching without snippets still works.",
        "503 unavailable": "Signatures are temporarily unavailable. Try again later."
    },
    "rate_limit": {
        "requests": "10 per minute, per account, shared by the API and the MCP server. /v1/account does not count.",
        "on_exceed": "429 with a Retry-After header, immediately. The API never holds the connection open to slow you down - it tells you how long to wait.",
        "headers": [
            "X-Requests-Limit",
            "X-Requests-Remaining"
        ]
    },
    "quota": {
        "searches": "Per day by plan, until the next UTC midnight; see /v1/account.",
        "headers": [
            "X-RateLimit-Limit",
            "X-RateLimit-Remaining",
            "X-RateLimit-Reset",
            "X-Snippets-Limit",
            "X-Snippets-Remaining"
        ]
    },
    "guarantees": [
        "Results are never silently reduced. If your quota is gone you get 429, not fewer rows.",
        "A short answer is marked: 'truncated' in the body, X-Truncated in the headers.",
        "An unranked domain has rank null and ranked false, never a placeholder number."
    ],
    "compatibility": "The old ?export= urls on https://publicwww.com keep working exactly as they always have, byte for byte. They are the compatibility layer; this API is not, and its output is free to be its own shape."
}
