How to Run SERP Analysis for SEO with DataForSEO Labs API
Your agency already runs SERP analysis. You have an all-in-one suite that pulls rankings, flags competitors, and fills a client dashboard. The friction isn’t the pulling. It’s the box the tool puts you in: fixed credits, a refresh schedule you can’t change, and a preset idea of which SERP features count. An SEO SERP analysis API takes that box away. This guide walks through running SERP analysis on the DataForSEO Labs API instead, so you own the logic and pay only for the data you use.
Why an SEO SERP analysis API beats a locked-in dashboard
An all-in-one platform makes one decision for every client on your roster. It sets how often rankings are refreshed, how many keywords a seat covers, and which SERP elements appear in a report. That works until your client mix no longer matches the vendor’s defaults.
So let’s name where agencies feel the squeeze. It’s rarely the data quality. It’s the packaging. Seat-based and credit-based plans mean you pay for a tier, not for what you pulled. Add three new markets for a client mid-quarter and you either burn credits you were saving or bump up to a pricing tier that bills the same next month, whether you use it or not.
Calling the DataForSEO Labs API directly flips that arrangement. You send a request, you get structured JSON back, and you pay per request. Pricing for DataForSEO Labs starts at $0.00012 per SERP, so the cost scales with client load rather than a fixed monthly commitment. That’s the difference between a data bill you can forecast per client and one you negotiate once a year and hope fits.
The trade is real work: you build the workflow instead of clicking a button. In exchange, the workflow does exactly what your reporting needs, and it scales with the client roster rather than against it.
What you control when SERP analysis runs on the DataForSEO Labs API
This API runs on our own in-house databases, with billions of keywords and hundreds of millions of historical SERPs, refreshed on a rolling basis. Because that data sits behind an endpoint instead of a dashboard, you decide how to slice it.
Location and language are set per request, down to the city, so a client operating in twelve metros gets twelve honest local reads instead of one national average. You pick which fields land in your dashboard, which means a report can lead with SERP features, ranking distribution, or competitor overlap, depending on what the client pays attention to. Cadence is yours too: daily for a volatile e-commerce account, weekly for a steady B2B one.
Throughput holds up at agency scale. The DataForSEO Labs endpoints accept up to 2,000 requests per minute, which is enough to refresh a large keyword set across many clients inside one reporting window. And that structured JSON flows straight into the stack you already run, whether that’s Looker Studio, a warehouse table, or a Make or n8n scenario. No manual export step in the middle.
The DataForSEO Labs API endpoints you’ll use for SERP analysis
SERP analysis isn’t one call. It’s a short chain of endpoints, each answering a different client question. Here are the DataForSEO Labs endpoints this workflow uses, in the order you’ll usually reach for them.
dataforseo_labs/google/serp_competitors/livereturns the domains that rank across a keyword set you define, with position metrics per domain. See the SERP Competitors endpoint documentation.dataforseo_labs/google/ranked_keywords/livereturns every keyword a domain or page ranks for, with the SERP element behind each ranking. See the Ranked Keywords endpoint documentation.dataforseo_labs/google/historical_serps/livereturns Google SERPs collected over a set time frame, with up to 12 months of history for a keyword and location. See the Historical SERPs endpoint documentation.
If you need the full raw SERP for a single query, every organic result plus every feature Google returns live, that’s a job for our SERP API. For competitive SERP analysis at the agency scale, though, the DataForSEO Labs endpoints above are the better fit, since they run against our stored database rather than scraping each SERP on demand. The three steps below walk through them in order.
Step 1: Find true competitors with the SERP Competitors endpoint
Every client thinks they know their competitors. The SERP tells a different story. The domains outranking them for the money keywords are often not the brands they named in the kickoff call. The SERP Competitors endpoint settles it by reading a keyword set as a whole rather than one query at a time.
The snippet below sends a client’s core keyword list to the endpoint and asks for the domains ranking across it, sorted by overlap. It’s the smallest working request: one task, one client market. The response comes back as structured JSON, which you can write straight to a report.
import requests
from requests.auth import HTTPBasicAuth
# Labs endpoints use HTTP Basic auth with the login:password from your dashboard.
auth = HTTPBasicAuth("your_login", "your_password")
payload = [{
# Send the full keyword set you report on for one client in a single task.
"keywords": ["serp api", "rank tracker api", "seo serp analysis api"],
"location_code": 2840, # United States — swap per client market
"language_code": "en",
# Cap the competitor list so reports stay to the domains that matter.
"limit": 20
}]
resp = requests.post(
"https://api.dataforseo.com/v3/dataforseo_labs/google/serp_competitors/live",
auth=auth,
json=payload,
timeout=60,
)
data = resp.json()
Endpoint used: dataforseo_labs/google/serp_competitors/live — see the SERP Competitors endpoint documentation. For a fuller walkthrough of reading the output, see our help center guide on analyzing SERP competition for any keyword.
Here’s what the response looks like for that request, trimmed to the fields you’ll most likely put in a report. Each item is a domain, with how many of your keywords it ranks for and its average position across them.
{
"tasks": [
{
"result": [
{
"keyword_count": 3,
"items": [
{
"se_type": "google",
"domain": "competitor-a.com",
"intersections": 3,
"avg_position": 4.7,
"sum_position": 14
},
{
"se_type": "google",
"domain": "competitor-b.com",
"intersections": 2,
"avg_position": 8.2,
"sum_position": 25
}
]
}
]
}
]
}
The field that earns its place in a client deck is intersections. It counts how many of your keywords each domain ranks for. A domain with high intersections and a low avg_position is a real competitor for that keyword set, not a one-off. That list is the input for the next step.
Step 2: Reverse-engineer rankings with Ranked Keywords
Once you know who a client’s real competitors are, the next question writes itself: what are they ranking for that we’re not? The Ranked Keywords endpoint answers it. Point it at a competitor domain and it returns the full set of keywords that domain ranks for, each paired with the SERP element behind the ranking, whether that’s an organic result, a featured snippet, or another feature.
For an agency, this is where a report stops describing the problem and starts pointing at the work. Filter a competitor’s ranked keywords to the ones your client doesn’t rank for, sort by search volume, and you have a content gap list with the SERP context attached. That context matters. A keyword a competitor wins through a featured snippet needs a different response than one they win with a standard page.
Run it across the two or three domains from Step 1, and the overlap between their keyword sets tends to surface the terms the whole niche competes on. Those are the keywords worth a client’s budget, ranked by evidence instead of a guess. The one thing a gap list can’t tell you is whether the opportunity is stable enough to invest in. That’s a question about time.
See the Ranked Keywords endpoint documentation.
Step 3: Track SERP volatility over time with Historical SERPs
A single SERP snapshot is a photo. The client’s strategy needs the film. The Historical SERPs endpoint returns the Google SERPs collected for a keyword and location over a set window, with up to 12 months of history. That lets you show how a ranking set moved, not just where it sits today.
This is the section that spares an agency an awkward conversation. When a client’s position dips, historical SERP data shows what moved. Maybe the whole result set was reshuffled after a Google layout change, a new AI Overview, or a competitor push. Maybe the dip is noise inside a normal range. Most teams trip here by reporting a one-week drop as a crisis, then walking it back when the position recovers on its own.
Layout shifts are the other reason to watch history. Google keeps changing what a results page looks like, and its own search appearance documentation catalogs how often features come and go. When a featured snippet your client held disappears from the SERP, historical data pins the date. A vague “traffic is down” becomes a specific, fixable finding. That precision is what makes the cost question worth answering, which is the next section.
See the Historical SERPs endpoint documentation.
What pay-as-you-go pricing changes for agency margins
Every section so far has traded a dashboard click for an API call. The reason that trade pays off shows up on the invoice. Seat and credit plans bill you for a tier. The DataForSEO Labs API bills you per request, starting at $0.00012 per item. Cost moves with client work, rather than sitting there as a fixed line, whether you pulled the data or not.
For an agency, that changes how the margin behaves as you grow. Onboard five clients in a quarter, and your data cost rises roughly in step with the reporting you run for them, not in a sudden jump to the next plan tier. Pricing that tracks usage this way can protect margin at scale, though the exact savings depend on your keyword volume and refresh cadence.
It also changes what you can afford to test. Because a request costs a fraction of a cent, adding a second market to a client report or trying a daily refresh doesn’t need a budget conversation. You run it, you see the cost, you keep it or drop it. That’s the working version of “customizable”: not a settings menu, but the freedom to change the workflow without repricing the whole account.
Common mistakes when running SERP analysis via API
The workflow is straightforward once it’s running. Getting there, a few things trip up most teams. Here are the ones we see most.
- Confusing live SERP scraping with the DataForSEO Labs API. The SERP API scrapes a live results page; DataForSEO Labs endpoints query our stored database. For competitor and historical analysis, reach for the DataForSEO Labs API. It’s built for querying across many keywords at once, not for re-scraping each SERP.
- Leaving out the location. Skip
location_codeorlocation_name, and the API picks a default you probably don’t want. Set it per client market every time, since rankings and competitors change from city to city. - Treating one snapshot as a trend. A single pull can’t tell noise from a real move. Pair the current data with the Historical SERPs endpoint before making a change to a client report.
- Ignoring rate limits at scale. The DataForSEO Labs API accepts up to 2,000 requests per minute, but a large roster refreshing at once can still queue. Batch keywords per task and stagger client jobs so a Monday-morning refresh doesn’t bottleneck.
Avoid those four, and the workflow holds up as the roster grows, which is the whole point of moving SERP analysis onto an API you control.
Run your SERP analysis on data you control
Running SERP analysis through the DataForSEO Labs API is one trade repeated at every step. You give up a preset dashboard and regain control over the location, fields, cadence, and cost. Find real competitors with the SERP Competitors endpoint, reverse-engineer their rankings with Ranked Keywords, and confirm the trend with Historical SERPs, all on structured JSON that flows into the reports you already build. And because it’s pay-as-you-go, the data bill tracks your client work instead of a fixed tier. See what that costs for your keyword volume.