> For the complete documentation index, see [llms.txt](https://docs.scraperapi.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.scraperapi.com/getting-started/tutorials/api-tutorials/keyword-rankings-api.md).

# Keyword Rankings

API Playground is ScraperAPI's request builder for testing and configuring scraping requests. In this tutorial, you will use the API Playground to track Google Search rankings for any keyword list. By the end, you will have daily SERP snapshots with rank, SERP features, and metadata for every keyword you monitor, so you can catch rank drops and competitor moves in your own data pipeline.

***

## Step 1: Configure the Google Search endpoint

Open the [**API Playground**](https://dashboard.scraperapi.com/apiplayground) from the left sidebar.

1. Select scraping method: **Structured Data Endpoints**.
2. In the endpoint dropdown, select **Google Search**.
3. Enter query `best running shoes`. Set **Country code** to `us`.
4. Review the Summary panel on the right to understand the cost of the job before you run it.
5. Scroll down to the generated code and click **Try it**.

The Playground runs the request and shows the response inline. Each entry in `organic_results` includes `position`, `title`, `link`, `snippet`, and `displayed_link`. The response also includes `related_questions`, `related_searches`, and `pagination` for deeper keyword analysis.

{% hint style="info" %}
Use the language dropdown to switch to Python, Node.js, PHP, Ruby, or Java. Click **Copy to clipboard** to run the request in your own terminal instead.
{% endhint %}

## Step 2: Additional options and filters

Use **Additional options & filters** to fine-tune your request. The Playground adds the relevant parameters to the generated code automatically.

* **Country code** adds `country_code`. Targets a specific country's Google Search results.
* **Domain** adds `domain`. Sets the Google domain to search (e.g. `co.uk`, `com.au`).
* **Time based search** adds `time_period`. Filters results by recency — past 24 hours, past week, past month, or past year.
* **Output format** adds `output_format`. Returns results as `json` (default) or `markdown` for LLM pipelines.
* **UULE** adds `uule`. Encodes a specific city for local search results. Generate a UULE value using a UULE encoder tool.
* **Number of results** adds `num`. Sets how many organic results to return per page.
* **Additional parameters** adds any other supported ScraperAPI parameters, separated by `&`.

{% hint style="info" %}
Some parameters increase the cost per request. Check the Summary panel before committing to a configuration at scale.
{% endhint %}

## Step 3: Save snapshots with date prefixes

To track rankings over time, save each response as a dated file. This lets you load any two dates and diff the `organic_results` array by `position`.

```bash
curl "https://api.scraperapi.com/structured/google/search?api_key=API_KEY&query=best+running+shoes&country_code=us" \
  -o "snapshots/$(date +%Y-%m-%d)_best-running-shoes_us.json"
```

## Step 4: Batch across keywords and locations

Switch the scraping method to **Async** in the Playground and paste your queries as full structured endpoint URLs, one per line:

```
https://api.scraperapi.com/structured/google/search?query=best+running+shoes&country_code=us
https://api.scraperapi.com/structured/google/search?query=best+running+shoes&country_code=gb
https://api.scraperapi.com/structured/google/search?query=keyword+research+tool&country_code=us
https://api.scraperapi.com/structured/google/search?query=keyword+research+tool&country_code=au
```

The response returns a `statusUrl` per job that you can use to track progress.

## Step 5: Schedule daily snapshots

To run your batch automatically on a recurring schedule, add it to your crontab. The example below runs every day at 6am.

```bash
0 6 * * * /usr/bin/bash /path/to/submit_serp_batch.sh >> /var/log/serp_tracker.log 2>&1
```

***

{% hint style="info" %}
Prefer a no-code setup? [Track keyword rankings with DataPipeline instead](/getting-started/tutorials/no-code-tutorials/keyword-rankings-no-code.md).
{% endhint %}

## More API tutorials

* [Scrape any URL](/getting-started/tutorials/api-tutorials/any-url-api.md)
* [Track prices across Amazon and Walmart](/getting-started/tutorials/api-tutorials/track-prices-api.md)
* [Monitor unauthorized sellers and MAP violations](/getting-started/tutorials/api-tutorials/monitor-sellers-api.md)
* [Monitor Google Shopping prices](/getting-started/tutorials/api-tutorials/google-shopping-api.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.scraperapi.com/getting-started/tutorials/api-tutorials/keyword-rankings-api.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
