Skip to content
Search API · Use case

Track Google rankings by country with a keyword rank checker API

A keyword rank checker API answers one question on a loop: where does my domain rank for this query, in this country, today? SEO teams, agencies reporting to clients and product teams watching a launch all need that number per keyword and per market. The Search API returns the results in order, so the rank is where your domain appears in the list.

The problem

Rank trackers report one number and hide how they measured it

Google results differ by country, so “position 4” means nothing without the market it was measured in. Checking by hand from one browser shows your own local results, and repeating it for hundreds of keywords across several countries every week is not a job for a person.

Off-the-shelf rank trackers solve the volume with a dashboard and a price per tracked keyword, but the data stays inside their tool and their definition of position. Scraping Google yourself means proxies in every country, a parser for a results page that keeps changing, and blocked sessions as soon as volume grows.

The Search API returns results in order, geo-targeted with a two-letter location code. There is no position field: the rank is the index of your domain in the results plus the number of results on earlier pages. Walk the pages with next() until you find the domain or reach the depth you care about, and store the number where your reports already live.

How it works

How to track SERP positions by country with the Search API

Search the keyword in a country, walk the pages, and compute the position from the index. The web search guide documents the result fields.

1 · Find the domain in the results
import createClient from 'microlink.io'

const microlink = createClient({
  apiKey: process.env.MICROLINK_API_KEY
})

const isDomain = (url, domain) => {
  const { hostname } = new URL(url)
  return hostname === domain || hostname.endsWith('.' + domain)
}

const rankOf = async (keyword, domain, location, depth = 3) => {
  let page = await microlink.search(keyword, { location })
  let offset = 0

  for (let n = 1; n <= depth && page; n++) {
    const index = page.results.findIndex(({ url }) => isDomain(url, domain))
    if (index !== -1) {
      return { position: offset + index + 1, url: page.results[index].url }
    }
    offset += page.results.length
    if (n < depth) page = await page.next()
  }

  return { position: null, url: null }
}

Each page is one request, so a depth of 3 costs at most three. position is 1-based across pages, subdomains count as your domain, and null means not found within the depth.

2 · Run the keyword set per country
import createClient from 'microlink.io'

const microlink = createClient({
  apiKey: process.env.MICROLINK_API_KEY
})

const keywords = ['headless browser api', 'website screenshot api']
const countries = ['us', 'gb', 'es']
const checkedAt = new Date().toISOString()

const rows = []
for (const location of countries) {
  for (const keyword of keywords) {
    const { position, url } = await rankOf(keyword, 'example.com', location)
    rows.push({ keyword, location, position, url, checkedAt })
  }
}

One row per keyword and country with a timestamp, ready for the table your reports read. url records which of your pages ranked, which is how you spot two of your own URLs competing for one query.

3 · Compare with the previous run
const movements = rows.map(row => {
  const before = previous.get(row.keyword + ':' + row.location)
  const change = before && row.position ? before - row.position : null
  return Object.assign({}, row, { change })
})

A positive change means the page moved up. previous stands for the last run loaded from your database, keyed by keyword and country; the API does not keep rank history.

Parameters used
  • location Two-letter country code. The only geo option: there is no city, device or language parameter.
  • page Jumps to a results page directly instead of walking with next().
  • limit Maximum number of results per page. Count results, not pages, when you compute the offset.
  • type Omit it: the default 'search' returns title, url and description in order.

Results carry title, url and description, with no ads, local pack or position fields, so the rank computed here counts the listed results only. When you need to see everything the page showed around the links, capture the SERP as Markdown or HTML next to the positions.

Why it works

Why compute rankings yourself instead of renting a rank tracker

A position is a derived number. Deriving it yourself means you know exactly what it measures and you own every row.

01 · Your definition
Position is index plus offset, nothing hidden.
You decide whether a subdomain counts as your domain, how deep to look and what to record when you are not found. The same function works for competitors: pass their domain against the same results.

One results page answers for every domain on it, so store the full list and compute competitor positions with no extra requests. Pagination in the search method covers next() and page.

02 · Country by country
One location code per market.
Rankings in Spain and in the United States are different lists. location takes a two-letter country code, so running the same keyword per country gives a market-by-market view at one request per page per country.

Pair positions with Google News brand monitoring to explain a jump in visibility with the coverage behind it.

03 · Costs you can predict
Keywords × countries × pages, per run.
Each results page is one request. 100 keywords in 3 countries at a depth of one page, checked daily, is 300 requests a day, about 9,000 a month.

When not to: if you need city-level or mobile versus desktop rankings, or search volume next to each position, this API does not provide them. It geo-targets by country only and returns results, not keyword metrics. For new terms to track, start with autocomplete keyword research.

FAQ

How does a keyword rank checker API calculate position?

There is no position field in the response. Find the index of your domain in page.results and add the number of results on the pages before it, plus one. That is the 1-based rank among the returned results for that country.

Can I check Google rankings for a city or on mobile?

No. location geo-targets results by two-letter country code, and there is no city, device or language option. Track what the API supports, country-level results, and keep the same settings across runs so positions stay comparable.

How many pages deep should SERP position tracking go?

Most tracking stops at the first two or three pages. Each page is one request, fetched with page.next() or the page option, so depth multiplies cost. Stop as soon as your domain is found.

Does the rank tracking API store ranking history?

No. Each call returns the current results; history is the rows you store. Run the job on your own scheduler, save keyword, country, position, url and timestamp, and compare runs in your database. Search has no free tier, and Pro plans start at €39/month for 46,000 requests.
No. Microlink Search is an independent product that queries public Google results. It is not affiliated with or endorsed by Google, and Google is a trademark of Google LLC.
Related use cases

Solve the next problem with the same API

Keyword research with Google Autocomplete

Expand a seed into the queries people type, plus related searches and People Also Ask questions, per country.

Google results page as Markdown or HTML

Start from a query, not a URL: get the structured results plus the Google results page itself as Markdown or HTML.

Brand and media monitoring from Google News

Query Google News by brand, country and time window and get headline, publisher and ISO 8601 date for every article.

Price comparison from Google Shopping

Get every merchant Google Shopping lists for a product, with a numeric price, the merchant name and the rating, per country.

Screenshot a site from another country

Pin the request to a country with a two-letter code and capture the prices and copy a local visitor sees.

Region-specific metadata

Fetch titles, descriptions and prices as a visitor from a given country and language sees them.

Ready to track rankings by country?

Ordered results per country as JSON, and positions you compute yourself. Get a Pro key and record your first run today.