> ## Documentation Index
> Fetch the complete documentation index at: https://docs.markifact.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Keyword Gap

> Keyword gap analysis from DataForSEO Labs: the keywords two domains both rank for with each one's position, the keywords only the first ranks for, or the keywords shared across up to 20 specific pa...

Keyword gap analysis from DataForSEO Labs: the keywords two domains both rank for with each one's position, the keywords only the first ranks for, or the keywords shared across up to 20 specific pages, each with volume, CPC, difficulty and intent.

|                      |                              |
| -------------------- | ---------------------------- |
| **App**              | DataForSEO                   |
| **Operation ID**     | `dataforseo_get_keyword_gap` |
| **Type**             | Action                       |
| **Connection**       | `dataforseo` (required)      |
| **Credits per run**  | Free                         |
| **Agent / MCP tool** | Yes                          |

## Inputs

| Field         | Type                       | Required | Default   | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| ------------- | -------------------------- | -------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `targets`     | array of string or string  | Yes      | -         | Domains (comparison 'domains': exactly two, without scheme or www) or page URLs (comparison 'pages': 2 to 20 full URLs), as a list or newline/comma-separated text.                                                                                                                                                                                                                                                                                                                                                                                                    |
| `comparison`  | string or SelectableOption | No       | `domains` | 'domains' (default): compare the keyword sets of two domains. 'pages': compare the keyword sets of 2 to 20 specific pages.                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `shared_only` | boolean                    | No       | `True`    | Domains: true returns keywords BOTH domains rank for (with each domain's position); false returns keywords the FIRST domain ranks for and the second does not. Pages: true returns keywords all pages share; false returns keywords any of them ranks for.                                                                                                                                                                                                                                                                                                             |
| `location`    | string or SelectableOption | No       | `2840`    | Country or location: a two-letter country code (us, gb, de...), a DataForSEO location code (2840 = United States), or a full location name such as 'London,England,United Kingdom'. Defaults to the United States.                                                                                                                                                                                                                                                                                                                                                     |
| `language`    | string or SelectableOption | No       | `en`      | Language code of the search results, e.g. en, de, es, fr, nl. Defaults to en.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| `item_types`  | string or array of string  | No       | -         | SERP element types to compare on: organic, paid, featured\_snippet, local\_pack, ai\_overview\_reference. Defaults to organic and paid.                                                                                                                                                                                                                                                                                                                                                                                                                                |
| `filters`     | array of FilterItem        | No       | -         | Up to 8 filters on dotted result fields, e.g. keyword\_data.keyword\_info.search\_volume GREATER\_THAN 500, first\_domain\_serp\_element.rank\_group LESS\_THAN 11, second\_domain\_serp\_element.rank\_group GREATER\_THAN 10.                                                                                                                                                                                                                                                                                                                                        |
| `orders`      | array of OrderItem         | No       | -         | Sort by up to 3 dotted result fields, e.g. keyword\_info.search\_volume DESC.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| `limit`       | integer                    | No       | `100`     | Maximum number of rows to return (1 to 1000). Defaults to 100. Each row is billed by DataForSEO, so keep this as small as the task needs.                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `offset`      | integer                    | No       | -         | Number of rows to skip, for paging.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `fields`      | string or array of string  | No       | -         | Dotted result fields to keep, e.g. keyword\_data.keyword, keyword\_data.keyword\_info.search\_volume, keyword\_data.keyword\_info.cpc, keyword\_data.keyword\_properties.keyword\_difficulty, first\_domain\_serp\_element.rank\_group, first\_domain\_serp\_element.url, second\_domain\_serp\_element.rank\_group, second\_domain\_serp\_element.url (domains comparison), or intersection\_result.1.rank\_group, intersection\_result.2.rank\_group (pages comparison). Leave empty for the default set listed in the output description. Does not change the cost. |

### FilterItem

| Field      | Type                       | Required | Default | Description                                                                                                                                                                                                                                                                                 |
| ---------- | -------------------------- | -------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `field`    | string or SelectableOption | Yes      | -       | The field to filter on, must be one of the current selected metrics or dimensions.                                                                                                                                                                                                          |
| `operator` | string                     | Yes      | -       | The operator to use for filtering. Must be one of the supported values. Use REGEXP\_MATCH to search/filter by multiple OR values like '.*(summer\|holiday).*'                                                                                                                               |
| `value`    | string                     | Yes      | -       | The value to filter by, always as a string: text, a number, or a regex. For IN\_LIST and NOT\_IN\_LIST, pass the values as one comma-separated string such as 'a,b,c', not as an array. For regex values, escape backslashes once in the JSON string: write \b for a word boundary, not \b. |

### OrderItem

| Field       | Type                       | Required | Default | Description                                                                      |
| ----------- | -------------------------- | -------- | ------- | -------------------------------------------------------------------------------- |
| `field`     | string or SelectableOption | Yes      | -       | The field to sort by. must be one of the current selected metrics or dimensions. |
| `direction` | string                     | Yes      | -       | The order to sort by, must be one of 'ASC', 'DESC'                               |

### SelectableOption

| Field   | Type   | Required | Default | Description |
| ------- | ------ | -------- | ------- | ----------- |
| `value` | string | Yes      | -       |             |
| `label` | string | Yes      | -       |             |

## Output

**Type**: `List[Dict]`

Returns one row per keyword with dotted columns: keyword\_data.keyword, keyword\_data.keyword\_info.search\_volume, keyword\_data.keyword\_info.cpc, keyword\_data.keyword\_properties.keyword\_difficulty, keyword\_data.search\_intent\_info.main\_intent, then first\_domain\_serp\_element.\* and second\_domain\_serp\_element.\* (type, rank\_group, rank\_absolute, url, title, etv) for the domains comparison, or intersection\_result.\<n>.\* per page for the pages comparison.

**Fields**: `keyword_data.keyword`, `keyword_data.keyword_info.search_volume`, `first_domain_serp_element.rank_group`, `first_domain_serp_element.url`, `second_domain_serp_element.rank_group`, `second_domain_serp_element.url`

**Example**:

```json theme={"dark"}
[
  {
    "keyword_data.keyword": "keyword research tool",
    "keyword_data.keyword_info.search_volume": 22200,
    "first_domain_serp_element.rank_group": 4,
    "second_domain_serp_element.rank_group": 2
  }
]
```
