# get_keyword_data

**Get keyword data** · Read-only, idempotent

Before choosing keyword-data dates, call `get_data_availability` unless already known in this conversation; explain unavailable history rather than silently shortening the request.

- Read stored weekly or monthly Amazon search market data (clicks, sales, conversion) for any keywords in one marketplace, with optional top-3 ASIN details per period.
- Not limited to project keywords and not rank data.
- Weekly periods start on Sunday and monthly periods on the 1st.
- Pass period start dates: a `start_date` inside a period skips that period, and an `end_date` inside one can drop the last period.
- Up to 26 weekly or 24 monthly periods, all inside the plan history window.
- Each result returns that window as `plan_history_window` (`start_period` to `latest_loaded_period`, both period start dates).
- A request reaching outside it is rejected whole, with `allowed_start_date` and `latest_loaded_period` in the error.
- Missing keywords return empty records.

**Cost and limits:** Costs 1 credit per record returned (one keyword in one period), at least 1 credit; the call is refused before it runs unless the credit balance covers every keyword requested times every period requested; separate 10-per-minute limit.

## Input

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `marketplace` | `string` | Required | Marketplace code: US, CA, MX, UK, DE, FR, IT, ES, AU. Maximum length 2. |
| `keywords` | `string[]` | Required | Keywords to read, one per item. Items are never split, so a keyword may contain commas. Trimmed, lowercased and deduplicated. At most 100, or 25 with `include_asins`. At most 100 items. |
| `start_date` | `string` | Required | Start date of the first period (a Sunday for weekly, the 1st for monthly), YYYY-MM-DD, no later than today in Los Angeles. Maximum length 10. |
| `end_date` | `string` | Optional | Start date of the last period, inclusive, YYYY-MM-DD. Defaults to `start_date`. Maximum length 10. |
| `interval` | `"weekly" \| "monthly"` | Required | Period length. |
| `include_asins` | `boolean` | Optional | Include `asin_1` to `asin_3` market-period details for each record. Default false. |

## Output

Read this object from the result's `structuredContent`. The result's `content` carries a text version for the model, which is not always the same JSON.

Fields of `data`:

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `marketplace` | `string` | Required |  |
| `start_date` | `string (date)` | Required |  |
| `end_date` | `string (date)` | Required |  |
| `interval` | `"weekly" \| "monthly"` | Required |  |
| `plan_history_window` | `object` | Required | The caller's plan history window for the requested marketplace and interval. Both bounds are period start dates. Plans with a history limit must stay between them; on other plans, periods outside them are missing from `records`. |
| `requested_keywords` | `string[]` | Required |  |
| `keywords` | `KeywordIntervalItem[]` | Required |  |

### `data.plan_history_window`

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `start_period` | `string (date)` | Required | Start date of the first readable period: the oldest stored period, or later when the plan limits history. Same value as `allowed_start_date` in period errors. |
| `latest_loaded_period` | `string (date)` | Required | Start date of the newest period Datarova has loaded for this marketplace and interval. |

### `data.keywords[]`

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `keyword` | `string` | Required |  |
| `records` | `KeywordIntervalRecord[]` | Required | One record per stored period. Empty when nothing is stored for the keyword. |

<details>
<summary>Full input and output JSON Schema</summary>

```json
{
  "inputSchema": {
    "type": "object",
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "properties": {
      "marketplace": {
        "type": "string",
        "maxLength": 2,
        "description": "Marketplace code: US, CA, MX, UK, DE, FR, IT, ES, AU."
      },
      "keywords": {
        "maxItems": 100,
        "type": "array",
        "items": {
          "type": "string",
          "maxLength": 1024
        },
        "description": "Keywords to read, one per item. Items are never split, so a keyword may contain commas. Trimmed, lowercased and deduplicated. At most 100, or 25 with include_asins."
      },
      "start_date": {
        "type": "string",
        "maxLength": 10,
        "description": "Start date of the first period (a Sunday for weekly, the 1st for monthly), YYYY-MM-DD, no later than today in Los Angeles."
      },
      "end_date": {
        "type": "string",
        "maxLength": 10,
        "description": "Start date of the last period, inclusive, YYYY-MM-DD. Defaults to start_date."
      },
      "interval": {
        "type": "string",
        "enum": [
          "weekly",
          "monthly"
        ],
        "description": "Period length."
      },
      "include_asins": {
        "description": "Include asin_1 to asin_3 market-period details for each record. Default false.",
        "type": "boolean"
      }
    },
    "required": [
      "marketplace",
      "keywords",
      "start_date",
      "interval"
    ],
    "additionalProperties": false
  },
  "outputSchema": {
    "type": "object",
    "required": [
      "data"
    ],
    "properties": {
      "data": {
        "type": "object",
        "required": [
          "marketplace",
          "start_date",
          "end_date",
          "interval",
          "plan_history_window",
          "requested_keywords",
          "keywords"
        ],
        "properties": {
          "marketplace": {
            "type": "string"
          },
          "start_date": {
            "type": "string",
            "format": "date"
          },
          "end_date": {
            "type": "string",
            "format": "date"
          },
          "interval": {
            "type": "string",
            "enum": [
              "weekly",
              "monthly"
            ]
          },
          "plan_history_window": {
            "type": "object",
            "description": "The caller's plan history window for the requested marketplace and interval. Both bounds are period start dates. Plans with a history limit must stay between them; on other plans, periods outside them are missing from `records`.",
            "required": [
              "start_period",
              "latest_loaded_period"
            ],
            "properties": {
              "start_period": {
                "type": "string",
                "format": "date",
                "description": "Start date of the first readable period: the oldest stored period, or later when the plan limits history. Same value as `allowed_start_date` in period errors."
              },
              "latest_loaded_period": {
                "type": "string",
                "format": "date",
                "description": "Start date of the newest period Datarova has loaded for this marketplace and interval."
              }
            }
          },
          "requested_keywords": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "keywords": {
            "type": "array",
            "items": {
              "$ref": "#/$defs/KeywordIntervalItem"
            }
          }
        }
      }
    },
    "$defs": {
      "KeywordIntervalItem": {
        "type": "object",
        "required": [
          "keyword",
          "records"
        ],
        "properties": {
          "keyword": {
            "type": "string"
          },
          "records": {
            "type": "array",
            "items": {
              "$ref": "#/$defs/KeywordIntervalRecord"
            },
            "description": "One record per stored period. Empty when nothing is stored for the keyword."
          }
        }
      },
      "KeywordIntervalRecord": {
        "type": "object",
        "required": [
          "date",
          "clicks",
          "sales",
          "conversion_rate"
        ],
        "properties": {
          "date": {
            "type": "string",
            "format": "date",
            "description": "Start date of the stored weekly or monthly period."
          },
          "clicks": {
            "type": "number",
            "description": "Amazon search clicks for the keyword in the period."
          },
          "sales": {
            "type": "number",
            "description": "Estimated Amazon search sales for the keyword in the period."
          },
          "conversion_rate": {
            "type": "number",
            "description": "Sales divided by clicks as a percentage."
          },
          "asin_1": {
            "$ref": "#/$defs/KeywordPositionRecord",
            "description": "First top-ASIN market slot for the period. Present only when ASIN details are requested. Not an organic position."
          },
          "asin_2": {
            "$ref": "#/$defs/KeywordPositionRecord",
            "description": "Second top-ASIN market slot. Present only when ASIN details are requested."
          },
          "asin_3": {
            "$ref": "#/$defs/KeywordPositionRecord",
            "description": "Third top-ASIN market slot. Present only when ASIN details are requested."
          }
        }
      },
      "KeywordPositionRecord": {
        "type": "object",
        "required": [
          "asin",
          "clicks",
          "sales",
          "conversion_rate"
        ],
        "properties": {
          "asin": {
            "type": [
              "string",
              "null"
            ]
          },
          "clicks": {
            "type": [
              "number",
              "null"
            ]
          },
          "sales": {
            "type": [
              "number",
              "null"
            ]
          },
          "conversion_rate": {
            "type": [
              "number",
              "null"
            ]
          }
        },
        "description": "One market-period ASIN slot. Fields are null when the slot is empty; stored numeric values may be normalized to 0."
      }
    }
  }
}
```

</details>
