Making requests

/v1/search takes the same query you would type into the search box, plus a few parameters. It answers to GET and to POST; the parameters are the same either way.

Parameters

NameDefaultMeaning
queryrequiredThe search string. Same syntax as the website - see query syntax.
page11-based.
per_page100Up to your plan's row limit; /v1/account reports it as max_per_page.
snippetsoff1 to include the matching text. Spends snippet quota.
formatjsonOne of six - see response formats.
columnsdepends on formatComma-separated subset of domain, url, rank, ranked, snippets.
delimiter; / tabFor csv and tsv.
headeroff1 to put a header line on csv and tsv.

GET

curl -H "Authorization: Bearer $KEY" \
     "https://api.publicwww.com/v1/search?query=%22angular.min.js%22&page=2&per_page=50"

Remember to url-encode the query. Quotes, slashes and + all matter.

POST

The same parameters as a JSON body. Use it when the query is long or has several phrases: a multi-line query in a url runs into length limits in proxies and clients long before the server minds.

curl https://api.publicwww.com/v1/search \
     -H "Authorization: Bearer $KEY" \
     -H "Content-Type: application/json" \
     -d '{"query": ["\"angular.min.js\"", "\"bootstrap.min.css\""],
          "per_page": 50,
          "snippets": true}'

An array of phrases means all of them, exactly as separating them with newlines in the query string would. In the example above 278 sites carry the first phrase and 99 carry both.

JSON types are understood: true works where the query string needs 1. When a parameter is given in both the url and the body, the body wins.

The response

FieldMeaning
totalHow many sites match, in the whole index. A real count, not an estimate.
total_pagestotal divided by per_page, rounded up.
returnedHow many rows this page actually carries.
truncatedWhether your plan's disclosed-position limit removed any of them.
took_msHow long the search took, in milliseconds.
resultsThe rows.

A row

FieldMeaning
domainThe site.
urlThe page the match was found on, which for depth: searches is not the home page.
rankPosition in the ranking, lower being more popular. null when the site has no rank.
rankedfalse exactly when rank is null.
snippetsOnly with snippets=1. Up to five {"text", "match"} pairs, where match is what matched and text is it with surrounding context.

Paging and bulk

Page through with page, or ask for everything at once with a large per_page - up to max_per_page from /v1/account, which on a paid plan is a million. There is no separate export endpoint; the answer is written out as it is built, so a million rows is not also a million rows held in memory somewhere.

Paging is cheap: repeating a query you have already run today is not charged again, so walking through pages costs one search rather than one per page. Snippet requests are the exception - those are charged every time. See quotas and rate limits.

Next Response formats