{"id":10408,"date":"2021-09-10T17:03:55","date_gmt":"2021-09-10T17:03:55","guid":{"rendered":"https:\/\/docs_v3.dataforseo.com\/v3\/?page_id=10408"},"modified":"2025-04-23T13:17:57","modified_gmt":"2025-04-23T13:17:57","slug":"on_page-keyword_density","status":"publish","type":"page","link":"https:\/\/docs.dataforseo.com\/v3\/on_page-keyword_density\/","title":{"rendered":"on_page\/keyword_density"},"content":{"rendered":"<div class=\"wpb-content-wrapper\"><p>[vc_row][vc_column][vc_column_text]<\/p>\n<h2 id=\"setting-serp-tasks\">Keyword Density<\/h2>\n<p>\u200c\u200c<br \/>\nThis endpoint will provide you with keyword density and keyword frequency data for terms appearing on the specified website or web page. You can filter and sort the data that will be retrieved with this API call.<\/p>\n<p><strong>Note:<\/strong> to use this endpoint, make sure the <code>calculate_keyword_density<\/code> parameter in the <a href=\"\/v3\/on_page\/task_post\/\">Task Post<\/a> request is set to <code>true<\/code><\/p>\n<p>[\/vc_column_text]    <div class=\"endpoint\">\n        <img decoding=\"async\" class=\"endpoint__icon\" src=\"https:\/\/docs.dataforseo.com\/v3\/wp-content\/themes\/dataforseo\/assets\/img\/icons\/checked-circle.svg\" alt=\"checked\">\n\n                    POST            <button class=\"btn-reset button-link copy-button\" data-href=\"https:\/\/api.dataforseo.com\/v3\/on_page\/keyword_density\">\n                https:\/\/api.dataforseo.com\/v3\/on_page\/keyword_density                <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\">\n                    <use href=\"https:\/\/docs.dataforseo.com\/v3\/wp-content\/themes\/dataforseo\/assets\/img\/icons\/sprite.svg#layers\"><\/use>\n                <\/svg>\n            <\/button>\n            <\/div>\n    \t<article class=\"info-card info-card--yellow\">\n\t\t<header class=\"info-card__header\">\n\t\t\t<div class=\"info-card__icon\">\n\t\t\t\t<svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\">\n\t\t\t\t\t<use href=\"https:\/\/docs.dataforseo.com\/v3\/wp-content\/themes\/dataforseo\/assets\/img\/icons\/sprite.svg#label\"><\/use>\n\t\t\t\t<\/svg>\n\t\t\t<\/div>\n\t\t\t<div class=\"info-card__title\">Pricing<\/div>\n\t\t<\/header>\n\t\t<div class=\"info-card__content\">\n\t\t\t<p> Your account will not be charged for using this function. You can get the results of the task within the next 30 days for free.<br \/>\nThe cost can be calculated on the <a title=\"Pricing\" href=\"https:\/\/dataforseo.com\/pricing\/on-page\/onpage-api\" target=\"_blank\" rel=\"noopener noreferrer\">Pricing<\/a> page.<\/p>\n\t\t<\/div>\n\t<\/article>\n\t[vc_column_text]All POST data should be sent in the <a href=\"https:\/\/en.wikipedia.org\/wiki\/JSON\">JSON<\/a> format (UTF-8 encoding). The task setting is done using the POST method. When setting a task, you should send all task parameters in the task array of the generic POST array.<\/p>\n<p><strong>Description of the fields for setting a task:<\/strong><\/p>\n<table style=\"width: 100%; height: 1765px;\">\n<thead>\n<tr style=\"height: 24px;\">\n<th style=\"width: 12.4003%; height: 24px;\">Field name<\/th>\n<th style=\"width: 3.91588%; height: 24px;\">Type<\/th>\n<th style=\"width: 82.9587%; height: 24px;\">Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr style=\"height: 144px;\">\n<td style=\"width: 12.4003%; height: 144px;\"><code>id<\/code><\/td>\n<td style=\"width: 3.91588%; height: 144px;\">string<\/td>\n<td style=\"width: 82.9587%; height: 144px;\"><em>ID of the task<\/em><br \/>\n<strong>required field<\/strong><br \/>\nyou can get this ID in the response of the <a href=\"\/v3\/on_page\/task_post\/\">Task POST<\/a> endpoint<br \/>\nexample:<br \/>\n&#8220;07131248-1535-0216-1000-17384017ad04&#8221;<\/td>\n<\/tr>\n<tr style=\"height: 144px;\">\n<td style=\"width: 12.4003%; height: 144px;\"><code>keyword_length<\/code><\/td>\n<td style=\"width: 3.91588%; height: 144px;\">integer<\/td>\n<td style=\"width: 82.9587%; height: 144px;\"><em>number of words for a keyword<\/em><br \/>\n<strong>required field<\/strong><br \/>\npossible values:<br \/>\n<code>1<\/code>, <code>2<\/code>, <code>3<\/code>, <code>4<\/code>, <code>5<\/code><\/td>\n<\/tr>\n<tr style=\"height: 144px;\">\n<td style=\"width: 12.4003%; height: 144px;\"><code>url<\/code><\/td>\n<td style=\"width: 3.91588%; height: 144px;\">string<\/td>\n<td style=\"width: 82.9587%; height: 144px;\"><em>page URL<\/em><br \/>\noptional field<br \/>\n<strong>if you do not specify a page here, the results will be provided for the whole website<\/strong><br \/>\nif you use this field, the API response will contain only keywords from the specified page<br \/>\na page should be specified with absolute URL (including <code>http:\/\/<\/code> or <code>https:\/\/<\/code>)<\/td>\n<\/tr>\n<tr style=\"height: 192px;\">\n<td style=\"width: 12.4003%; height: 169px;\"><code>limit<\/code><\/td>\n<td style=\"width: 3.91588%; height: 169px;\">integer<\/td>\n<td style=\"width: 82.9587%; height: 169px;\"><em>the maximum number of returned keywords<\/em><br \/>\noptional field<br \/>\ndefault value: <code>100<\/code><br \/>\nmaximum value: <code>1000<\/code><\/td>\n<\/tr>\n<tr style=\"height: 48px;\">\n<td style=\"width: 12.4003%; height: 48px;\"><code>filters<\/code><\/td>\n<td style=\"width: 3.91588%; height: 48px;\">array<\/td>\n<td style=\"width: 82.9587%; height: 48px;\"><em>array of results filtering parameters<\/em><br \/>\noptional field<br \/>\n<strong>you can add several filters at once (8 filters maximum)<\/strong><br \/>\nyou should set a logical operator <code>and<\/code>, <code>or<\/code> between the conditions<br \/>\nthe following operators are supported:<br \/>\n<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 \/>\nyou can use the <code>%<\/code> operator with <code>like<\/code> and <code>not_like<\/code> to match any string of zero or more characters<br \/>\nexample:<br \/>\n<code>[\"keyword\",\"=\",\"%seo%\"]<\/code><\/p>\n<p><code>[[\"keyword\",\"=\",\"%seo%\"],<br \/>\n\"and\",<br \/>\n[\"frequency\",\"&lt;\",\"6\"]]<\/code><\/p>\n<p><code>[[\"keyword\",\"not_like\",\"%seo%\"],<br \/>\n\"and\",<br \/>\n[[\"frequency\",\"&gt;\",\"6\"],\"or\",[\"density\",\"&gt;\",\"0.02\"]]]<\/code><\/p>\n<p>The full list of possible filters is available <a href=\"\/v3\/on_page\/filters_and_thresholds\/?bash\" target=\"_blank\" rel=\"noopener noreferrer\">by this link.<\/a><\/td>\n<\/tr>\n<tr style=\"height: 48px;\">\n<td style=\"width: 12.4003%; height: 48px;\"><code>order_by<\/code><\/td>\n<td style=\"width: 3.91588%; height: 48px;\">array<\/td>\n<td style=\"width: 82.9587%; height: 48px;\"><em>results sorting rules<\/em><br \/>\noptional field<br \/>\nyou can use the same values as in the <code>filters<\/code> array to sort the results<br \/>\npossible sorting types:<br \/>\n<code>asc<\/code> &#8211; results will be sorted in the ascending order<br \/>\n<code>desc<\/code> &#8211; results will be sorted in the descending order<br \/>\nyou should use a comma to set up a sorting type<br \/>\nexample:<br \/>\n<code>[\"frequency,desc\"]<\/code><br \/>\n<strong>note that you can set no more than three sorting rules in a single request<\/strong><br \/>\nyou should use a comma to separate several sorting rules<br \/>\nexample:<br \/>\n<code>[\"keyword,asc\",\"frequency,desc\"]<\/code><\/td>\n<\/tr>\n<tr style=\"height: 96px;\">\n<td style=\"width: 12.4003%; height: 96px;\"><code>tag<\/code><\/td>\n<td style=\"width: 3.9884%; height: 96px;\">string<\/td>\n<td style=\"width: 82.8862%; height: 96px;\"><em>user-defined task identifier<\/em><br \/>\noptional field<br \/>\n<em>the character limit is 255<\/em><br \/>\nyou can use this parameter to identify the task and match it with the result<br \/>\nyou will find the specified <code>tag<\/code> value in the <code>data<\/code> object of the response<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u200c\u200c\u200c\u200c\u200c\u200c<br \/>\nAs a response of the API server, you will receive <a href=\"https:\/\/en.wikipedia.org\/wiki\/JSON\">JSON<\/a>-encoded data containing a <code>tasks<\/code> array with the information specific to the set tasks.<\/p>\n<p><strong>Description of the fields in the results array:<\/strong><\/p>\n<table style=\"width: 77.3646%; height: 552px;\">\n<thead>\n<tr style=\"height: 24px;\">\n<th style=\"width: 38.423%; height: 24px;\">Field name<\/th>\n<th style=\"width: 1.25156%; height: 24px;\">Type<\/th>\n<th style=\"width: 61.7021%; height: 24px;\">Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr style=\"height: 48px;\">\n<td style=\"width: 24.3517%; height: 48px;\"><code>version<\/code><\/td>\n<td style=\"width: 6.19209%; height: 48px;\">string<\/td>\n<td style=\"width: 79.8065%; height: 48px;\"><em>the current version of the API<\/em><\/td>\n<\/tr>\n<tr style=\"height: 48px;\">\n<td style=\"width: 38.423%; height: 48px;\"><code>status_code<\/code><\/td>\n<td style=\"width: 1.75219%; height: 48px;\">integer<\/td>\n<td style=\"width: 61.2015%; height: 48px;\"><i>general status code<\/i><br \/>\nyou can find the full list of the response codes <a href=\"\/v3\/appendix\/errors\">here<\/a><br \/>\n<strong>Note:<\/strong> we strongly recommend designing a necessary system for handling related exceptional or error conditions<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 24.3517%; height: 24px;\"><code>status_message<\/code><\/td>\n<td style=\"width: 6.19209%; height: 24px;\">string<\/td>\n<td style=\"width: 79.8065%; height: 24px;\"><em>general informational message<\/em><br \/>\nyou can find the full list of general informational messages <a href=\"\/v3\/appendix\/errors\">here<\/a><\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 24.3517%; height: 24px;\"><code>time<\/code><\/td>\n<td style=\"width: 6.19209%; height: 24px;\">string<\/td>\n<td style=\"width: 79.8065%; height: 24px;\"><em>execution time, seconds<\/em><\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 24.3517%; height: 24px;\"><code>cost<\/code><\/td>\n<td style=\"width: 6.19209%; height: 24px;\">float<\/td>\n<td style=\"width: 79.8065%; height: 24px;\"><em>total <i>tasks<\/i> cost, USD<\/em><\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 24.3517%; height: 24px;\"><code>tasks_count<\/code><\/td>\n<td style=\"width: 6.19209%; height: 24px;\">integer<\/td>\n<td style=\"width: 79.8065%; height: 24px;\"><em>the number of tasks in the <strong><code>tasks<\/code><\/strong> array<\/em><\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 24.3517%; height: 24px;\"><code>tasks_error<\/code><\/td>\n<td style=\"width: 6.19209%; height: 24px;\">integer<\/td>\n<td style=\"width: 79.8065%; height: 24px;\"><em>the number of tasks in the <strong><code>tasks<\/code><\/strong> array returned with an error<\/em><\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 24.3517%; height: 24px;\"><strong><code>tasks<\/code><\/strong><\/td>\n<td style=\"width: 6.19209%; height: 24px;\">array<\/td>\n<td style=\"width: 79.8065%; height: 24px;\"><em>array of tasks<\/em><\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 24.3517%; height: 24px;\">\u00a0 \u00a0 \u00a0 \u00a0 <code>id<\/code><\/td>\n<td style=\"width: 6.19209%; height: 24px;\">string<\/td>\n<td style=\"width: 79.8065%; height: 24px;\"><em>task identifier<\/em><br \/>\n<strong>unique task identifier in our system in the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Universally_unique_identifier\">UUID<\/a> format<\/strong><\/td>\n<\/tr>\n<tr style=\"height: 48px;\">\n<td style=\"width: 24.3517%; height: 48px;\">\u00a0 \u00a0 \u00a0 \u00a0 <code>status_code<\/code><\/td>\n<td style=\"width: 6.19209%; height: 48px;\">integer<\/td>\n<td style=\"width: 79.8065%; height: 48px;\"><em>status code of the task<\/em><br \/>\ngenerated by DataForSEO; can be within the following range: 10000-60000<br \/>\nyou can find the full list of the response codes <a href=\"\/v3\/appendix\/errors\">here<\/a><\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 24.3517%; height: 24px;\">\u00a0 \u00a0 \u00a0 \u00a0 <code>status_message<\/code><\/td>\n<td style=\"width: 6.19209%; height: 24px;\">string<\/td>\n<td style=\"width: 79.8065%; height: 24px;\"><em>informational message of the task<\/em><br \/>\nyou can find the full list of general informational messages <a href=\"\/v3\/appendix\/errors\">here<\/a><\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 24.3517%; height: 24px;\">\u00a0 \u00a0 \u00a0 \u00a0 <code>time<\/code><\/td>\n<td style=\"width: 6.19209%; height: 24px;\">string<\/td>\n<td style=\"width: 79.8065%; height: 24px;\"><em>execution time, seconds<\/em><\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 24.3517%; height: 24px;\">\u00a0 \u00a0 \u00a0 \u00a0 <code>cost<\/code><\/td>\n<td style=\"width: 6.19209%; height: 24px;\">float<\/td>\n<td style=\"width: 79.8065%; height: 24px;\"><em>cost of the task, USD<\/em><\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 24.3517%; height: 24px;\">\u00a0 \u00a0 \u00a0 \u00a0 <code>result_count<\/code><\/td>\n<td style=\"width: 6.19209%; height: 24px;\">integer<\/td>\n<td style=\"width: 79.8065%; height: 24px;\"><em>number of elements in the <code>result<\/code> array<\/em><\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 24.3517%; height: 24px;\">\u00a0 \u00a0 \u00a0 \u00a0 <code>path<\/code><\/td>\n<td style=\"width: 6.19209%; height: 24px;\">array<\/td>\n<td style=\"width: 79.8065%; height: 24px;\"><em>URL path<\/em><\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 24.3517%; height: 24px;\">\u00a0 \u00a0 \u00a0 \u00a0 <code>data<\/code><\/td>\n<td style=\"width: 6.19209%; height: 24px;\">object<\/td>\n<td style=\"width: 79.8065%; height: 24px;\"><em>contains the same parameters that you specified in the POST request<br \/>\n<\/em><\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 24.3517%; height: 24px;\">\u00a0 \u00a0 <strong>\u00a0 \u00a0 <code>result<\/code><\/strong><\/td>\n<td style=\"width: 6.19209%; height: 24px;\">array<\/td>\n<td style=\"width: 79.8065%; height: 24px;\"><em>array of results<\/em><\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 24.3517%; height: 24px;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 <code>crawl_progress<\/code><\/td>\n<td style=\"width: 6.19209%; height: 24px;\">string<\/td>\n<td style=\"width: 79.8065%; height: 24px;\"><em>status of the crawling session<\/em><br \/>\npossible values: <code>in_progress<\/code>, <code>finished<\/code><\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 24.3517%; height: 24px;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 <code>crawl_status<\/code><\/td>\n<td style=\"width: 6.19209%; height: 24px;\">object<\/td>\n<td style=\"width: 79.8065%; height: 24px;\"><em>details of the crawling session<\/em><\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 24.3517%; height: 24px;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0 \u00a0  \u00a0 <code>max_crawl_pages<\/code><\/td>\n<td style=\"width: 6.19209%; height: 24px;\">integer<\/td>\n<td style=\"width: 79.8065%; height: 24px;\"><em>maximum number of pages to crawl<\/em><br \/>\nindicates the <code>max_crawl_pages<\/code> limit you specified when setting a task<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 24.3517%; height: 24px;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0 \u00a0  \u00a0 <code>pages_in_queue<\/code><\/td>\n<td style=\"width: 6.19209%; height: 24px;\">integer<\/td>\n<td style=\"width: 79.8065%; height: 24px;\"><em>number of pages that are currently in the crawling queue<\/em><\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 24.3517%; height: 24px;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0 \u00a0  \u00a0 <code>pages_crawled<\/code><\/td>\n<td style=\"width: 6.19209%; height: 24px;\">integer<\/td>\n<td style=\"width: 79.8065%; height: 24px;\"><em>number of crawled pages<\/em><\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 24.3517%; height: 24px;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 <code>total_items_count<\/code><\/td>\n<td style=\"width: 6.19209%; height: 24px;\">integer<\/td>\n<td style=\"width: 79.8065%; height: 24px;\"><em>total number of relevant items<\/em><br \/>\ntotal number of keywords on the specified website or web page matching the set <code>keyword_length<\/code> and <code>filters<\/code><\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 24.3517%; height: 24px;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 <code>items_count<\/code><\/td>\n<td style=\"width: 6.19209%; height: 24px;\">integer<\/td>\n<td style=\"width: 79.8065%; height: 24px;\"><em>number of items in the results array<\/em>\n<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 24.3517%; height: 24px;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 <strong><code>items<\/code><\/strong><\/td>\n<td style=\"width: 6.19209%; height: 24px;\">array<\/td>\n<td style=\"width: 79.8065%; height: 24px;\"><em>items array<\/em>\n<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 24.3517%; height: 24px;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 <code>keyword<\/code><\/td>\n<td style=\"width: 6.19209%; height: 24px;\">string<\/td>\n<td style=\"width: 79.8065%; height: 24px;\"><em>returned keyword<\/em><\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 24.3517%; height: 24px;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 <code>frequency<\/code><\/td>\n<td style=\"width: 6.19209%; height: 24px;\">integer<\/td>\n<td style=\"width: 79.8065%; height: 24px;\"><em>keyword frequency<\/em><br \/>\nnumber of times the keyword appears on the website (or webpage if you specified a <code>url<\/code>)<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 24.3517%; height: 24px;\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 <code>density<\/code><\/td>\n<td style=\"width: 6.19209%; height: 24px;\">integer<\/td>\n<td style=\"width: 79.8065%; height: 24px;\"><em>keyword density<\/em><br \/>\ncalculated as a ratio of <code>frequency<\/code> to the total count of keywords with the set <code>keyword_length<\/code> on the web page or website<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u200c\u200c[\/vc_column_text][\/vc_column][\/vc_row]<\/p>\n<blockquote><p>Instead of \u2018login\u2019 and \u2018password\u2019 use your credentials from https:\/\/app.dataforseo.com\/api-access<\/p><\/blockquote><div id=\"curl\" class=\"tab-content example__content\"><div class=\"example__code\"><pre><code class=\"language-bash hljs\"># Instead of &#039;login&#039; and &#039;password&#039; use your credentials from https:\/\/app.dataforseo.com\/api-access \r\nlogin=&quot;login&quot; \r\npassword=&quot;password&quot; \r\ncred=&quot;$(printf ${login}:${password} | base64)&quot; \r\ncurl --location --request POST &quot;https:\/\/api.dataforseo.com\/v3\/on_page\/keyword_density&quot; \r\n--header &quot;Authorization: Basic ${cred}&quot;  \r\n--header &quot;Content-Type: application\/json&quot; \r\n--data-raw &#039;[\r\n    {\r\n        &quot;id&quot;: &quot;09101923-1535-0216-0000-2389a8854b70&quot;,\r\n        &quot;url&quot;: &quot;https:\/\/dataforseo.com\/&quot;,\r\n        &quot;keyword_length&quot;: 2,\r\n        &quot;filters&quot;: [\r\n            &quot;frequency&quot;,\r\n            &quot;&gt;&quot;,\r\n            5\r\n        ]\r\n    }\r\n]&#039;<\/code><\/pre><\/div><\/div><div id=\"php\" class=\"tab-content example__content\"><div class=\"example__code\"><pre><code class=\"language-php hljs\">&lt;?php\r\n\/\/ You can download this file from here https:\/\/cdn.dataforseo.com\/v3\/examples\/php\/php_RestClient.zip\r\nrequire(&#039;RestClient.php&#039;);\r\n$api_url = &#039;https:\/\/api.dataforseo.com\/&#039;;\r\n\/\/ Instead of &#039;login&#039; and &#039;password&#039; use your credentials from https:\/\/app.dataforseo.com\/api-access\r\n$client = new RestClient($api_url, null, &#039;login&#039;, &#039;password&#039;);\r\n\r\n$post_array = array();\r\n\/\/ simple way to get a result\r\n$post_array[] = array(\r\n   &quot;id&quot; =&gt; &quot;09101923-1535-0216-0000-2389a8854b70&quot;,\r\n   &quot;url&quot; =&gt; &quot;https:\/\/dataforseo.com\/&quot;,\r\n   &quot;keyword_length&quot; =&gt; 2,\r\n   &quot;filters&quot; =&gt;  [\r\n            &quot;frequency&quot;,\r\n            &quot;&gt;&quot;,\r\n            5\r\n        ]\r\n);\r\ntry {\r\n   \/\/ POST \/v3\/on_page\/keyword_density\r\n   \/\/ the full list of possible parameters is available in documentation\r\n   $result = $client-&gt;post(&#039;\/v3\/on_page\/keyword_density&#039;, $post_array);\r\n   print_r($result);\r\n   \/\/ do something with post result\r\n} catch (RestClientException $e) {\r\n   echo &quot;n&quot;;\r\n   print &quot;HTTP code: {$e-&gt;getHttpCode()}n&quot;;\r\n   print &quot;Error code: {$e-&gt;getCode()}n&quot;;\r\n   print &quot;Message: {$e-&gt;getMessage()}n&quot;;\r\n   print  $e-&gt;getTraceAsString();\r\n   echo &quot;n&quot;;\r\n}\r\n$client = null;\r\n?&gt;<\/code><\/pre><\/div><\/div><div id=\"javascript\" class=\"tab-content example__content\"><div class=\"example__code\"><pre><code class=\"language-javascript hljs\">const post_array = [];\r\n\r\npost_array.push({\r\n  &quot;id&quot;: &quot;09101923-1535-0216-0000-2389a8854b70&quot;,\r\n  &quot;url&quot;: &quot;https:\/\/dataforseo.com\/&quot;,\r\n  &quot;keyword_length&quot;: 2,    \r\n  &quot;filters&quot;: [&quot;frequency&quot;, &quot;&gt;&quot;, 5]\r\n});\r\n\r\nconst axios = require(&#039;axios&#039;);\r\n\r\naxios({\r\n  method: &#039;post&#039;,\r\n  url: &#039;https:\/\/api.dataforseo.com\/v3\/on_page\/keyword_density&#039;,\r\n  auth: {\r\n    username: &#039;login&#039;,\r\n    password: &#039;password&#039;\r\n  },\r\n  data: post_array,\r\n  headers: {\r\n    &#039;content-type&#039;: &#039;application\/json&#039;\r\n  }\r\n}).then(function (response) {\r\n  var result = response[&#039;data&#039;][&#039;tasks&#039;];\r\n  \/\/ Result data\r\n  console.log(result);\r\n}).catch(function (error) {\r\n  console.log(error);\r\n});<\/code><\/pre><\/div><\/div><div id=\"python\" class=\"tab-content example__content\"><div class=\"example__code\"><pre><code class=\"language-python hljs\">from random import Random\r\nfrom client import RestClient\r\n# You can download this file from here https:\/\/api.dataforseo.com\/v3\/_examples\/python\/_python_Client.zip\r\nclient = RestClient(&quot;login&quot;, &quot;password&quot;)\r\n\r\npost_data = dict()\r\n# simple way to get a result\r\npost_data[len(post_data)] = dict(\r\n    id=&quot;09101923-1535-0216-0000-2389a8854b70&quot;,\r\n    url=&quot;https:\/\/dataforseo.com\/&quot;,\r\n    keyword_length: 2,\r\n    filters=[&quot;frequency&quot;, &quot;&gt;&quot;, 5]\r\n)\r\n# POST \/v3\/on_page\/keyword_density\r\n# the full list of possible parameters is available in documentation\r\nresponse = client.post(&quot;\/v3\/on_page\/keyword_density&quot;, post_data)\r\n# you can find the full list of the response codes here https:\/\/docs.dataforseo.com\/v3\/appendix\/errors\r\nif response[&quot;status_code&quot;] == 20000:\r\n    print(response)\r\n    # do something with result\r\nelse:\r\n    print(&quot;error. Code: %d Message: %s&quot; % (response[&quot;status_code&quot;], response[&quot;status_message&quot;]))<\/code><\/pre><\/div><\/div><div id=\"csharp\" class=\"tab-content example__content\"><div class=\"example__code\"><pre><code class=\"language-csharp hljs\">using Newtonsoft.Json;\r\nusing System;\r\nusing System.Collections.Generic;\r\nusing System.Net.Http;\r\nusing System.Net.Http.Headers;\r\nusing System.Text;\r\nusing System.Threading.Tasks;\r\n\r\nnamespace DataForSeoDemos\r\n{\r\n    public static partial class Demos\r\n    {\r\n        public static async Task on_page_keyword_density()\r\n        {\r\n            var httpClient = new HttpClient\r\n            {\r\n                BaseAddress = new Uri(&quot;https:\/\/api.dataforseo.com\/&quot;),\r\n                \/\/ Instead of &#039;login&#039; and &#039;password&#039; use your credentials from https:\/\/app.dataforseo.com\/api-access\r\n                DefaultRequestHeaders = { Authorization = new AuthenticationHeaderValue(&quot;Basic&quot;, Convert.ToBase64String(Encoding.ASCII.GetBytes(&quot;login:password&quot;))) }\r\n            };\r\n            var postData = new List&lt;object&gt;();\r\n            \/\/ simple way to get a result\r\n            postData.Add(new\r\n            {\r\n                id = &quot;07281559-0695-0216-0000-c269be8b7592&quot;,\r\n                page_from = &quot;\/apis\/google-trends-api&quot;,\r\n                keyword_length: 2,    \r\n                filters = new object[]\r\n                { \r\n                    new object[] { &quot;frequency&quot;, &quot;&gt;&quot;, 5 }\r\n                }\r\n            });\r\n            \/\/ POST \/v3\/on_page\/keyword_density\r\n            \/\/ the full list of possible parameters is available in documentation\r\n            var taskPostResponse = await httpClient.PostAsync(&quot;\/v3\/on_page\/keyword_density&quot;, new StringContent(JsonConvert.SerializeObject(postData)));\r\n            var result = JsonConvert.DeserializeObject&lt;dynamic&gt;(await taskPostResponse.Content.ReadAsStringAsync());\r\n            \/\/ you can find the full list of the response codes here https:\/\/docs.dataforseo.com\/v3\/appendix\/errors\r\n            if (result.status_code == 20000)\r\n            {\r\n                \/\/ do something with result\r\n                Console.WriteLine(result);\r\n            }\r\n            else\r\n                Console.WriteLine($&quot;error. Code: {result.status_code} Message: {result.status_message}&quot;);\r\n        }\r\n    }\r\n}<\/code><\/pre><\/div><\/div><blockquote><p>The above command returns JSON structured like this:<\/p><\/blockquote><div class=\"example example--json\"><div class=\"example__content\"><div class=\"example__code example__code-json\"><pre><code class=\"language-json hljs\">{\r\n  &quot;version&quot;: &quot;0.1.20210907&quot;,\r\n  &quot;status_code&quot;: 20000,\r\n  &quot;status_message&quot;: &quot;Ok.&quot;,\r\n  &quot;time&quot;: &quot;0.2239 sec.&quot;,\r\n  &quot;cost&quot;: 0,\r\n  &quot;tasks_count&quot;: 1,\r\n  &quot;tasks_error&quot;: 0,\r\n  &quot;tasks&quot;: [\r\n    {\r\n      &quot;id&quot;: &quot;09101923-1535-0216-0000-2389a8854b70&quot;,\r\n      &quot;status_code&quot;: 20000,\r\n      &quot;status_message&quot;: &quot;Ok.&quot;,\r\n      &quot;time&quot;: &quot;0.1548 sec.&quot;,\r\n      &quot;cost&quot;: 0,\r\n      &quot;result_count&quot;: 1,\r\n      &quot;path&quot;: [\r\n        &quot;v3&quot;,\r\n        &quot;on_page&quot;,\r\n        &quot;keyword_density&quot;\r\n      ],\r\n      &quot;data&quot;: {\r\n        &quot;api&quot;: &quot;on_page&quot;,\r\n        &quot;function&quot;: &quot;keyword_density&quot;,\r\n        &quot;url&quot;: &quot;https:\/\/dataforseo.com\/&quot;,\r\n        &quot;keyword_length&quot;: 2,\r\n        &quot;order_by&quot;: [\r\n          &quot;frequency,desc&quot;\r\n        ],\r\n        &quot;filters&quot;: [\r\n          &quot;frequency&quot;,\r\n          &quot;&gt;&quot;,\r\n          5\r\n        ],\r\n        &quot;target&quot;: &quot;dataforseo.com&quot;,\r\n        &quot;max_crawl_pages&quot;: 10,\r\n        &quot;calculate_keyword_density&quot;: true\r\n      },\r\n      &quot;result&quot;: [\r\n        {\r\n          &quot;crawl_progress&quot;: &quot;finished&quot;,\r\n          &quot;crawl_status&quot;: {\r\n            &quot;max_crawl_pages&quot;: 10,\r\n            &quot;pages_in_queue&quot;: 0,\r\n            &quot;pages_crawled&quot;: 10\r\n          },\r\n          &quot;total_items_count&quot;: 10,\r\n          &quot;items_count&quot;: 10,\r\n          &quot;items&quot;: [\r\n            {\r\n              &quot;keyword&quot;: &quot;read more&quot;,\r\n              &quot;frequency&quot;: 9,\r\n              &quot;density&quot;: 0.007569386038687973\r\n            },\r\n            {\r\n              &quot;keyword&quot;: &quot;data api&quot;,\r\n              &quot;frequency&quot;: 8,\r\n              &quot;density&quot;: 0.00672834314550042\r\n            },\r\n            {\r\n              &quot;keyword&quot;: &quot;we can&quot;,\r\n              &quot;frequency&quot;: 8,\r\n              &quot;density&quot;: 0.00672834314550042\r\n            },\r\n            {\r\n              &quot;keyword&quot;: &quot;serp api&quot;,\r\n              &quot;frequency&quot;: 6,\r\n              &quot;density&quot;: 0.005046257359125316\r\n            },\r\n            {\r\n              &quot;keyword&quot;: &quot;docs api&quot;,\r\n              &quot;frequency&quot;: 6,\r\n              &quot;density&quot;: 0.005046257359125316\r\n            },\r\n            {\r\n              &quot;keyword&quot;: &quot;see success&quot;,\r\n              &quot;frequency&quot;: 6,\r\n              &quot;density&quot;: 0.005046257359125316\r\n            },\r\n            {\r\n              &quot;keyword&quot;: &quot;seo software&quot;,\r\n              &quot;frequency&quot;: 6,\r\n              &quot;density&quot;: 0.005046257359125316\r\n            },\r\n            {\r\n              &quot;keyword&quot;: &quot;analytics api&quot;,\r\n              &quot;frequency&quot;: 6,\r\n              &quot;density&quot;: 0.005046257359125316\r\n            },\r\n            {\r\n              &quot;keyword&quot;: &quot;success story&quot;,\r\n              &quot;frequency&quot;: 6,\r\n              &quot;density&quot;: 0.005046257359125316\r\n            },\r\n            {\r\n              &quot;keyword&quot;: &quot;google shopping&quot;,\r\n              &quot;frequency&quot;: 6,\r\n              &quot;density&quot;: 0.005046257359125316\r\n            }\r\n          ]\r\n        }\r\n      ]\r\n    }\r\n  ]\r\n}<\/code><\/pre><\/div><\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>[vc_row][vc_column][vc_column_text] Keyword Density \u200c\u200c This endpoint will provide you with keyword density and keyword frequency data for terms appearing on the specified website or web page. You can filter and sort the data that will be retrieved with this API call. Note: to use this endpoint, make sure the calculate_keyword_density parameter in the Task Post [&hellip;]<\/p>\n","protected":false},"author":17,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"template.php","meta":{"apibase_doc_request_yaml":"","apibase_doc_request_additional_yaml":"","apibase_doc_response_yaml":"","footnotes":""},"class_list":["post-10408","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/docs.dataforseo.com\/v3\/wp-json\/wp\/v2\/pages\/10408","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/docs.dataforseo.com\/v3\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/docs.dataforseo.com\/v3\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/docs.dataforseo.com\/v3\/wp-json\/wp\/v2\/users\/17"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.dataforseo.com\/v3\/wp-json\/wp\/v2\/comments?post=10408"}],"version-history":[{"count":17,"href":"https:\/\/docs.dataforseo.com\/v3\/wp-json\/wp\/v2\/pages\/10408\/revisions"}],"predecessor-version":[{"id":21468,"href":"https:\/\/docs.dataforseo.com\/v3\/wp-json\/wp\/v2\/pages\/10408\/revisions\/21468"}],"wp:attachment":[{"href":"https:\/\/docs.dataforseo.com\/v3\/wp-json\/wp\/v2\/media?parent=10408"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}