# 關鍵字密度

**API:** Data API

**Endpoint:** `POST /v1/beta/dataforseo/on_page/keyword_density`

**Tags:** DataForSEO

一次爬取中的詞頻與短語頻率，`keyword_length` 決定 n-gram 的大小。傳回 `total_items_count`、`items_count` 與 `items`。讀取已完成的爬取，因此需要 `post_dataforseo_on_page_submit` 傳回的 `id`，並傳回 `crawl_progress` 以及 `crawl_status`（`max_crawl_pages`、`pages_in_queue` 與 `pages_crawled`）——在採信偏少的結果前先檢查這些欄位，因為仍在進行的爬取能回報的內容本來就少。這裡描述的是網站對自身的陳述；若要了解網路如何評價它，請使用 `post_dataforseo_backlinks_anchors_live`；若要了解人們在搜尋什麼，請使用 `post_dataforseo_keywords_gads_search_volume_live`。💰 上游免費：查詢已完成的爬取不產生費用，只有爬取本身計費。

### 計費參考

- 計量方式：依回報的回應成本計量。
- 參考請求估算：0.012 美元。
- 參考客戶倍率：1.0。不得對已結算的客戶金額再次套用。

僅供參考的中繼資料，並非帳戶報價、保證價格或消費上限。資源額度並非 Felo 額度。最終費用依 Felo 計費記錄為準。

## Base URL

- `https://openapi.felo.ai`

## Authentication

- `FeloBearerAuth` (http bearer, bearer format Felo API Key)
- `FeloApiKey` (apiKey in header `X-API-Key`)

## Request body

Required: **no**

### application/json

Schema:

```json
{
  "type": "array",
  "items": {
    "type": [
      "object",
      "null"
    ],
    "oneOf": [
      {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "<em>任務 ID</em><br><strong>必填欄位</strong><br>你可以在 <a href=\"/v3/on_page/task_post/\">Task POST</a> 端點的回應中取得此 ID<br>範例：<br>\"07131248-1535-0216-1000-17384017ad04\""
          },
          "keyword_length": {
            "type": "integer",
            "description": "<em>關鍵字的字數</em><br><strong>必填欄位</strong><br>可能的值：<br><code>1</code>、<code>2</code>、<code>3</code>、<code>4</code>、<code>5</code>"
          },
          "url": {
            "type": [
              "string",
              "null"
            ],
            "description": "<em>頁面 URL</em><br>選填欄位<br><strong>如果你未在此處指定頁面，將提供整個網站的結果</strong><br>如果使用此欄位，API 回應將僅包含指定頁面的關鍵字<br>頁面應使用絕對 URL 指定（包含 <code>http://</code> 或 <code>https://</code>）"
          },
          "limit": {
            "type": [
              "integer",
              "null"
            ],
            "description": "<em>傳回關鍵字數量上限</em><br>選填欄位<br>預設值：<code>100</code><br>最大值：<code>1000</code>"
          },
          "filters": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": [
                "object",
                "null"
              ]
            },
            "description": "<em>結果篩選參數陣列</em><br>選填欄位<br><strong>可同時新增多個篩選條件（最多 8 個）</strong><br>應在條件之間設定邏輯運算子 <code>and</code>、<code>or</code><br>支援以下運算子：<br><code>regex</code>、<code>not_regex</code>、<code>=</code>、<code>&lt;&gt;</code>、<code>in</code>、<code>not_in</code>、<code>like</code>、<code>not_like</code><br>可在 <code>like</code> 與 <code>not_like</code> 中使用 <code>%</code> 運算子，比對任意長度（零個或多個字元）的字串<br>範例：<br><code>[\"keyword\",\"=\",\"%seo%\"]</code><p><code>[[\"keyword\",\"=\",\"%seo%\"],<br>\"and\",<br>[\"frequency\",\"&lt;\",\"6\"]]</code><p><code>[[\"keyword\",\"not_like\",\"%seo%\"],<br>\"and\",<br>[[\"frequency\",\"&gt;\",\"6\"],\"or\",[\"density\",\"&gt;\",\"0.02\"]]]</code><p>完整可用的篩選條件清單請見<a href=\"/v3/on_page/filters_and_thresholds/?bash\" target=\"_blank\" rel=\"noopener noreferrer\">此連結。</a>"
          },
          "order_by": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            },
            "description": "<em>結果排序規則</em><br>選填欄位<br>可使用與 <code>filters</code> 陣列相同的值排序結果<br>可能的排序類型：<br><code>asc</code> - 結果將依遞增順序排列<br><code>desc</code> - 結果將依遞減順序排列<br>應使用逗號設定排序參數<br>範例：<br><code>[\"frequency,desc\"]</code><br><strong>請注意，單次請求中最多可設定三條排序規則</strong><br>應使用逗號分隔多條排序規則<br>範例：<br><code>[\"keyword,asc\",\"frequency,desc\"]</code>"
          },
          "tag": {
            "type": [
              "string",
              "null"
            ],
            "description": "<em>使用者自訂任務識別碼</em><br>選填欄位<br><em>字元數上限為 255</em><br>可使用此參數識別任務，並將其與結果對應<br>可在回應的 <code>data</code> 物件中找到指定的 <code>tag</code> 值"
          }
        },
        "example": [
          {
            "id": "09101923-1535-0216-0000-2389a8854b70",
            "url": "https://dataforseo.com/",
            "keyword_length": 2,
            "filters": [
              "frequency",
              ">",
              5
            ]
          }
        ]
      }
    ]
  },
  "example": [
    {
      "id": "09101923-1535-0216-0000-2389a8854b70",
      "url": "https://dataforseo.com/",
      "keyword_length": 2,
      "filters": [
        "frequency",
        ">",
        5
      ]
    }
  ]
}
```

## Responses

### 200 — 操作成功

Headers:
- `X-Request-Id` (string) — 聯絡 Felo 支援時需提供的請求識別碼。

**application/json**

Schema: object | null

```json
{
  "type": [
    "object",
    "null"
  ],
  "oneOf": [
    {
      "$ref": "#/components/schemas/Response36Afe1097B20_OnPageKeywordDensityResponseInfo"
    }
  ]
}
```

### 400 — 無法處理該要求。請檢查請求參數。

### 401 — 需要有效的 Felo API 金鑰。

### 402 — 由於未符合計費要求，要求無法繼續。

### 403 — 該帳戶無權執行此操作。

### 429 — 已達到要求或支出上限。

### 502 — 服務無法完成該要求。

### 503 — API 或計費服務暫時無法使用。

### 504 — 服務在處理要求時逾時。

### default — 錯誤回應；上游透傳回應可能採用供應商格式

**application/json**

Schema:

```json
{}
```

## Schema definitions

### Response36Afe1097B20_BaseResponseInfo

`#/components/schemas/Response36Afe1097B20_BaseResponseInfo`

```json
{
  "properties": {
    "version": {
      "type": [
        "string",
        "null"
      ],
      "description": "API 的目前版本"
    },
    "status_code": {
      "type": [
        "integer",
        "null"
      ],
      "description": "一般狀態碼\n完整回應碼清單請見此處"
    },
    "status_message": {
      "type": [
        "string",
        "null"
      ],
      "description": "一般資訊訊息\n完整的一般資訊訊息清單請見此處"
    },
    "time": {
      "type": [
        "string",
        "null"
      ],
      "description": "總執行時間，秒"
    },
    "cost": {
      "type": [
        "number",
        "null"
      ],
      "description": "任務總費用，美元",
      "format": "double"
    },
    "tasks_count": {
      "type": [
        "integer",
        "null"
      ],
      "description": "tasks 陣列中的任務數",
      "format": "int64"
    },
    "tasks_error": {
      "type": [
        "integer",
        "null"
      ],
      "description": "tasks 陣列中傳回錯誤的任務數",
      "format": "int64"
    }
  }
}
```

### Response36Afe1097B20_BaseResponseTaskInfo

`#/components/schemas/Response36Afe1097B20_BaseResponseTaskInfo`

```json
{
  "properties": {
    "id": {
      "type": [
        "string",
        "null"
      ],
      "description": "任務識別碼\n我們系統中 UUID 格式的唯一任務識別碼"
    },
    "status_code": {
      "type": [
        "integer",
        "null"
      ],
      "description": "任務的狀態碼\n由 DataForSEO 產生，範圍如下：10000-60000\n完整回應碼清單請見此處"
    },
    "status_message": {
      "type": [
        "string",
        "null"
      ],
      "description": "任務的資訊訊息\n完整的一般資訊訊息清單請見此處"
    },
    "time": {
      "type": [
        "string",
        "null"
      ],
      "description": "執行時間，秒"
    },
    "cost": {
      "type": [
        "number",
        "null"
      ],
      "description": "任務總費用，美元",
      "format": "double"
    },
    "result_count": {
      "type": [
        "integer",
        "null"
      ],
      "description": "result 陣列中的元素數",
      "format": "int64"
    },
    "path": {
      "type": [
        "array",
        "null"
      ],
      "items": {
        "type": [
          "string",
          "null"
        ]
      },
      "description": "URL 路徑"
    },
    "data": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": {
        "type": [
          "object",
          "null"
        ]
      },
      "description": "包含你在 POST 請求中指定的相同參數"
    }
  }
}
```

### Response36Afe1097B20_CrawlStatusInfo

`#/components/schemas/Response36Afe1097B20_CrawlStatusInfo`

```json
{
  "type": "object",
  "properties": {
    "max_crawl_pages": {
      "type": [
        "integer",
        "null"
      ],
      "description": "擷取頁面數上限\n 表示設定任務時指定的 max_crawl_pages 限制",
      "format": "int64"
    },
    "pages_in_queue": {
      "type": [
        "integer",
        "null"
      ],
      "description": "目前位於擷取佇列中的頁面數量",
      "format": "int64"
    },
    "pages_crawled": {
      "type": [
        "integer",
        "null"
      ],
      "description": "已擷取的頁面數量",
      "format": "int64"
    }
  }
}
```

### Response36Afe1097B20_OnPageKeywordDensityItem

`#/components/schemas/Response36Afe1097B20_OnPageKeywordDensityItem`

```json
{
  "type": "object",
  "properties": {
    "keyword": {
      "type": [
        "string",
        "null"
      ],
      "description": "<em>傳回的關鍵字</em>"
    },
    "frequency": {
      "type": [
        "integer",
        "null"
      ],
      "description": "<em>關鍵字頻率</em><br>關鍵字在網站上（若指定了 <code>url</code>，則為網頁上）出現的次數"
    },
    "density": {
      "type": [
        "number",
        "null"
      ],
      "description": "<em>關鍵字密度</em><br>以 <code>frequency</code> 與網頁或網站上設定了 <code>keyword_length</code> 的關鍵字總數之比計算"
    }
  }
}
```

### Response36Afe1097B20_OnPageKeywordDensityResponseInfo

`#/components/schemas/Response36Afe1097B20_OnPageKeywordDensityResponseInfo`

```json
{
  "type": "object",
  "allOf": [
    {
      "$ref": "#/components/schemas/Response36Afe1097B20_BaseResponseInfo"
    },
    {
      "type": "object",
      "properties": {
        "tasks": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "type": [
              "object",
              "null"
            ],
            "oneOf": [
              {
                "$ref": "#/components/schemas/Response36Afe1097B20_OnPageKeywordDensityTaskInfo"
              }
            ]
          },
          "description": "<em>任務陣列</em>"
        }
      }
    }
  ]
}
```

### Response36Afe1097B20_OnPageKeywordDensityResultInfo

`#/components/schemas/Response36Afe1097B20_OnPageKeywordDensityResultInfo`

```json
{
  "type": "object",
  "properties": {
    "crawl_progress": {
      "type": [
        "string",
        "null"
      ],
      "description": "<em>擷取工作階段的狀態</em><br>可能的值：<code>in_progress</code>、<code>finished</code>"
    },
    "crawl_status": {
      "type": [
        "object",
        "null"
      ],
      "oneOf": [
        {
          "$ref": "#/components/schemas/Response36Afe1097B20_CrawlStatusInfo"
        }
      ],
      "description": "<em>擷取工作階段的詳細資料</em>"
    },
    "total_items_count": {
      "type": [
        "integer",
        "null"
      ],
      "description": "<em>相關項目的總數</em><br>指定網站或網頁上符合所設 <code>keyword_length</code> 與 <code>filters</code> 的關鍵字總數",
      "format": "int64"
    },
    "items_count": {
      "type": [
        "integer",
        "null"
      ],
      "description": "<em>結果陣列中的項目數</em>",
      "format": "int64"
    },
    "items": {
      "type": [
        "array",
        "null"
      ],
      "items": {
        "type": [
          "object",
          "null"
        ],
        "oneOf": [
          {
            "$ref": "#/components/schemas/Response36Afe1097B20_OnPageKeywordDensityItem"
          }
        ]
      },
      "description": "<em>項目陣列</em>"
    }
  }
}
```

### Response36Afe1097B20_OnPageKeywordDensityTaskInfo

`#/components/schemas/Response36Afe1097B20_OnPageKeywordDensityTaskInfo`

```json
{
  "type": "object",
  "allOf": [
    {
      "$ref": "#/components/schemas/Response36Afe1097B20_BaseResponseTaskInfo"
    },
    {
      "type": "object",
      "properties": {
        "result": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "type": [
              "object",
              "null"
            ],
            "oneOf": [
              {
                "$ref": "#/components/schemas/Response36Afe1097B20_OnPageKeywordDensityResultInfo"
              }
            ]
          },
          "description": "<em>結果陣列</em>"
        }
      }
    }
  ]
}
```
