How to Check Keyword Positions with an API
Can you check keyword positions with a Google API?
Google has no public API that returns a live ranking for any keyword. In code you have two options: the Search Console API, which returns average positions for your own verified sites, or a third-party SERP API with live Google results.
Quick verdict: Use the Search Console API for your own sites at no cost. Use a pay-per-request SERP API when you need competitors or live positions.
Price tier: Free or pay per request
Run a free checkOption 1: the Google Search Console API
The Search Console API's Search Analytics endpoint returns clicks, impressions, CTR and average position by query, page, country, device and date. It is free but covers only your verified properties and only queries where your site actually appeared in search.
The Search Analytics endpoint of the Search Console API returns the same data as the Performance report: clicks, impressions, CTR and average position, grouped by dimensions such as query, page, country, device and date.
You need a Google Cloud project with the Search Console API enabled, and either an OAuth sign-in or a service account that has been added as a user on the property. A request looks like this:
curl -X POST \
"https://www.googleapis.com/webmasters/v3/sites/sc-domain%3Aexample.com/searchAnalytics/query" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"startDate":"2026-09-01","endDate":"2026-09-28","dimensions":["query"],"rowLimit":1000}'
Each row includes a position value. Read our guide on what average position means before treating it as a rank.
Option 2: a SERP API (works for any domain)
A SERP API fetches Google results on request and returns them as JSON, so it works for any domain. You send a keyword, location and language, then search the organic items for your domain. Providers charge per request, so cache results.
SERP data providers fetch Google results on request and return them as JSON. Our free checker uses DataForSEO this way.
Providers charge per request, so cache results and avoid repeating identical calls.
PHP example
This PHP script requests the top 100 US desktop organic results from the DataForSEO live endpoint and prints the position of one domain. It reads credentials from environment variables, so the API login and password never appear in the code or in version control.
Credentials are read from environment variables so they never sit in the code.
<?php
$login = getenv('DATAFORSEO_LOGIN');
$pass = getenv('DATAFORSEO_PASSWORD');
$task = [[ 'keyword' => 'keyword position checker', 'location_code' => 2840,
'language_code' => 'en', 'device' => 'desktop', 'depth' => 100 ]];
$ch = curl_init('https://api.dataforseo.com/v3/serp/google/organic/live/regular');
curl_setopt_array($ch, [CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true,
CURLOPT_USERPWD => "$login:$pass", CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode($task)]);
$data = json_decode(curl_exec($ch), true);
$items = $data['tasks'][0]['result'][0]['items'] ?? [];
foreach ($items as $it) {
if (($it['type'] ?? '') === 'organic' && str_ends_with($it['domain'] ?? '', 'example.com')) {
echo "Position {$it['rank_group']}: {$it['url']}\n"; exit;
}
}
echo "Not in the top 100\n";
Why not scrape Google directly?
Old "keyword position checker PHP script" downloads usually fetch Google's HTML and parse it. Google's terms do not allow automated scraping, the HTML changes often, and requests from one server are quickly blocked with captchas. A SERP API or Search Console is more reliable.
Android and other platforms
Both APIs use plain HTTPS and JSON, so any language or platform can call them. On Android, keep API credentials on your own server and let the app call that server, because anything shipped inside an app package can be extracted.
The no-code route
If you want the data without writing code, Keyword Position Checker Pro connects to Search Console for every site and Google account you add, and can look up search volume through your own DataForSEO account, only after you approve the cost.
For one-off lists, compare the options for checking many keywords.
Check one keyword now, or track all of them.
Run a free check with the Keyword Position Checker (3 per day, no sign-up). To follow every keyword on every site each day, see Keyword Position Checker & Tracker Pro for Windows.
Early bird: $299 with code EARLYBIRD for the first 50 buyers (regular price $499). One-time payment, 3 PCs.