API

Get location-specific search results

In this guide, we’ll show you how to use the SERP API to retrieve precise search results for specific locations. You can apply these steps to any location and keyword set to analyze competition and keywords locally.

Step 1. Get available locations

In our example, we’ll use the keyword “yoga studio” and two nearby cities in Spain as our locations: Barcelona and Sant Cugat del Vallès. We’ll first fetch all locations in Spain, then select the cities to analyze.

Example: Retrieve all locations in Spain

Copy
curl -X GET 'https://api.seranking.com/v1/serp/classic/locations?country_code=ES' \
-H 'Authorization: Token YOUR_API_KEY'

What you’ll get:

  • A list of locations for a specific country
  • Their location IDs, names, and country code

From the returned list, we pick the two location IDs of interest for our SEO analysis:

  • Barcelona → location_id: 12998
  • Sant Cugat del Vallès → location_id: 354503

These IDs will be used in Step 2 when creating SERP tasks.


Step 2. Add SERP tasks

Now, we’ll use the Add SERP tasks endpoint to queue keywords for SERP collection. You can specify the device, language, and location. Each queued task returns a task_id for fetching results later.

Example: Queue keyword “yoga studio” for Barcelona

Copy
curl -X POST 'https://api.seranking.com/v1/serp/classic/tasks' \
-H 'Authorization: Token YOUR_API_KEY' \
--data '{
"search_engine": "google",
"device": "desktop",
"language_code": "es",
"location_id": 12998,
"query": ["yoga studio"],
"tag": "barcelona_test"
}'

Step 3. Retrieve SERP results

After queuing tasks in Step 2, we can now retrieve results using either the Get standard SERP results or Get advanced SERP results endpoints. Both return structured results for your keywords, but they differ in scope and detail.

A. Standard SERP results

Copy
curl -X GET 'https://api.seranking.com/v1/serp/classic/tasks?task_id=104' \
-H 'Authorization: Token YOUR_API_KEY'

What you’ll get:

  • Request metadata: keyword, device, location, language, tag, and crawl time
  • Summary statistics: total search results, number of organic results, and SERP features
  • Top 100 SERP results of the following types only: organic results, ads, featured snippets
  • For each item: absolute and group rank, position on the page, page title and URL, description/snippet, and associated SERP features

B. Advanced SERP results

Copy
curl -X GET 'https://api.seranking.com/v1/serp/classic/tasks/results_advanced?task_id=104' \
-H 'Authorization: Token YOUR_API_KEY'

What you’ll get:

  • All standard metadata and summary statistics
  • Detailed information for all SERP item types, including: organic results, ads, featured snippets, videos and images, AI Overview, and related searches
  • For each item: absolute and group rank, position on the page, snippet/overview, domain and URL, and additional type-specific fields

We’ll use the Get advanced SERP results endpoint in this example to include AI Overview items.


Step 4. Analyze local SERP overlap and competitors

Once results for both cities are retrieved, we identify overlapping competitors and unique local opportunities.

In our example, the overlapping domains are:

  • estudiodeyoga.com
  • urbansportsclub.com

Top competitors per location:

  • Barcelona: estudiodeyoga.com, bronsayogastudio.com, urbansportsclub.com
  • Sant Cugat del Vallès: estudiodeyoga.com, yogasantcugat.com, urbansportsclub.com

Next steps:

  • Compare SERP results and overlapping sources with AI Overview data.
  • Analyze text snippets from AI Overview items and your page’s content to optimize for search intent.
  • Conduct keyword research across competitors to discover new keywords you may be missing.
  • Use the findings to refine local SEO strategy, content, and targeting for each city.

Learn how SE Ranking’s API can boost your SEO!

Hi! Meet our product expert, Alex.

He’ll walk you through the API and show you how to get the most out of it.

  • Enjoy a tailored demo on integrating rich, structured SEO data into your stack.
  • Pin down every tech detail live—auth, endpoints, rate limits, data formats.
  • Compare usage tiers and pricing so you can unlock maximum data value.

Request a free demo to see our tools and integrations in action

By clicking this button, you agree to SE Ranking’s Terms of Services and Privacy Policy.