Google Search API — Getting Started — FetchLayer Docs
Documentation menu
FetchLayer FetchLayer API

Getting Started

Read a Google results page as JSON, check where your site ranks for the queries you care about, then widen the research with Google’s own suggestions.

1. Get your API key

Create an account and generate a FetchLayer API key from your dashboard. There is no Google account, Cloud project or search API agreement involved.

Create free account →

2. Search

One call returns the organic results with position, title, URL, site name, snippet and sitelinks, and everything else Google showed for the query: People also ask questions, related searches, top stories, videos, discussions, local results, the knowledge panel and the answer box. Ads come back separately and never take a position.

bash
curl -X POST https://api.fetchlayer.dev/google-search/search \
  -H "Authorization: Bearer ss-your-key" \
  -H "Content-Type: application/json" \
  -d '{"query":"open source crm","limit":10}'

Going deeper

One request reads one result page. Set pages to read up to 10 at once, or send nextCursor back as cursor with the same query and options to continue later. Each page read counts as one request (pagesScraped). Google shows between 6 and 10 organic results a page and ignores a requested count, so limit only trims.

Results depend on the searcher

Results reflect a US, English, desktop searcher unless you set country, language, location (a city, such as "Austin,Texas,United States") or device. The same query ranks differently in each, and positions move over time. A mobile search takes about 15 seconds.

3. Check where your site ranks

For SEO rank tracking, don’t page through search yourself. /rank-check examines up to 100 organic results for a domain or URL and returns whether it was found, its best position and page, every match, and where else it appears on the pages read: sitelinks, ads, top stories, videos, discussions, the knowledge panel or the answer box.

bash
curl -X POST https://api.fetchlayer.dev/google-search/rank-check \
  -H "Authorization: Bearer ss-your-key" \
  -H "Content-Type: application/json" \
  -d '{"query":"open source crm","target":"github.com","depth":30}'

One credit at any depth

A rank check costs 1 credit regardless of depth: scanning 100 positions across 10 or more result pages is billed as one request. serpPagesFetched reports how many result pages were read and is never billed. A deep check can take 15 seconds or more, and up to about 150 seconds when Google turns requests away, so give your HTTP client a generous timeout.

By default the check stops at the page where the target first appears (stoppedAtFirstMatch). Set allMatches to examine the full depth and see every page of yours that ranks, and match to exact_url to track one page only. found: false means depthScanned results were examined.

4. Research keywords

/autocomplete returns what Google’s search box suggests for a partial query, for a country and language — the phrasings worth tracking next. The peopleAlsoAsk and relatedSearches lists on every search are the other half of that picture.

bash
curl -X POST https://api.fetchlayer.dev/google-search/autocomplete \
  -H "Authorization: Bearer ss-your-key" \
  -H "Content-Type: application/json" \
  -d '{"query":"fetchla"}'

Tip

Already have a Google results link? Send it to /resolve-url — it returns the query, country, language, page, safe search and time range the URL carries, or where a Google redirect link leads, without contacting Google, and it does not consume a credit.

Errors and retries

A 400 names the field to fix. Unrecognised fields are rejected rather than ignored, so a typo such as contry fails loudly instead of quietly returning US results — and /autocomplete takes a country and language but no location or device. A 503 means Google search was temporarily unavailable for the request; it is always worth retrying, and it never stands for “no results”. A search that matches nothing is a 200 with noResults: true. Read notes on every successful response too.

Next steps