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.
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 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.
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.
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.
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.
- 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 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.
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.
Pair positions with Google News brand monitoring to explain a jump in visibility with the coverage behind it.
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?
Can I check Google rankings for a city or on mobile?
How many pages deep should SERP position tracking go?
Does the rank tracking API store ranking history?
Is the Microlink rank checker affiliated with Google?
Solve the next problem with the same API
Keyword research with Google Autocomplete
Google results page as Markdown or HTML
Brand and media monitoring from Google News
Price comparison from Google Shopping
Screenshot a site from another country
Region-specific metadata
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.