NAVNavbar
Logo
php python csharp java

Get SimilarWeb Traffic Analytics Results by id


SimilarWeb Traffic Analytics API provides you with website traffic and competitors data. You will receive total website visits, website traffic by countries along with its sources, site ranks, and various competitor data. This data is especially useful for running competitor analysis and market intelligence campaigns. Note that you can get data only for websites with over 5,000 monthly visitors due to SimilarWeb restrictions.

Instead of ‘login’ and ‘password’ use your credentials from https://app.dataforseo.com/api-dashboard

<?php
// You can download this file from here https://cdn.dataforseo.com/v3/examples/php/php_RestClient.zip
require('RestClient.php');
$api_url = 'https://api.dataforseo.com/';
try {
	// Instead of 'login' and 'password' use your credentials from https://app.dataforseo.com/api-dashboard
	$client = new RestClient($api_url, null, 'login', 'password');
} catch (RestClientException $e) {
	echo "\n";
	print "HTTP code: {$e->getHttpCode()}\n";
	print "Error code: {$e->getCode()}\n";
	print "Message: {$e->getMessage()}\n";
	print  $e->getTraceAsString();
	echo "\n";
	exit();
}
try {
	$result = array();
	// #1 - using this method you can get a list of completed tasks
	// GET /v3/traffic_analytics/similarweb/tasks_ready
	$tasks_ready = $client->get('/v3/traffic_analytics/similarweb/tasks_ready');
	// you can find the full list of the response codes here https://docs.dataforseo.com/v3/appendix/errors
	if (isset($tasks_ready['status_code']) AND $tasks_ready['status_code'] === 20000) {
		foreach ($tasks_ready['tasks'] as $task) {
			if (isset($task['result'])) {
				foreach ($task['result'] as $task_ready) {
					// #2 - using this method you can get results of each completed task
					// GET /v3/traffic_analytics/similarweb/task_get/$id
					if (isset($task_ready['endpoint'])) {
						$result[] = $client->get($task_ready['endpoint']);
					}
					// #3 - another way to get the task results by id
					// GET /v3/traffic_analytics/similarweb/task_get/$id
					/*
					if (isset($task_ready['id'])) {
						$result[] = $client->get('/v3/traffic_analytics/similarweb/task_get/' . $task_ready['id']);
					}
					*/
				}
			}
		}
	}
	print_r($result);
	// do something with result
} catch (RestClientException $e) {
	echo "\n";
	print "HTTP code: {$e->getHttpCode()}\n";
	print "Error code: {$e->getCode()}\n";
	print "Message: {$e->getMessage()}\n";
	print  $e->getTraceAsString();
	echo "\n";
}
$client = null;
?>

The above command returns JSON structured like this:

{
  "version": "0.1.20200203",
  "status_code": 20000,
  "status_message": "Ok.",
  "time": "32.1978 sec.",
  "cost": 0.2,
  "tasks_count": 1,
  "tasks_error": 0,
  "tasks": [
    {
      "id": "02051234-0696-0003-0000-b96abe78199a",
      "status_code": 20000,
      "status_message": "Ok.",
      "time": "32.1717 sec.",
      "cost": 0.2,
      "result_count": 1,
      "path": [
        "v3",
        "traffic_analytics",
        "similarweb",
        "live"
      ],
      "data": {
        "api": "traffic_analytics",
        "function": "task_get",
        "se": "similarweb",
        "target": "inc.com"
      },
      "result": [
        {
          "site_url": "inc.com",
          "site_description": "visit inc.com for the latest issue of inc. magazine and get advice, tools, and services that help your small business grow.",
          "global_rank": {
            "rank": 3699
          },
          "country_rank": {
            "rank": 1148,
            "country": "United States"
          },
          "category_rank": {
            "rank": 14,
            "category": "Business_and_Consumer_Services/Business_Services"
          },
          "audience": {
            "visits": 20824935,
            "time_on_site_avg": "00:01:18",
            "page_views_avg": 1.5736041258396107,
            "bounce_rate": 75.67
          },
          "traffic": {
            "value": 20824935,
            "percent": 100,
            "countries": [
              {
                "country": "United States",
                "value": 11468067,
                "percent": 55.07
              },
              {
                "country": "India",
                "value": 1137090,
                "percent": 5.46
              },
              {
                "country": "Canada",
                "value": 1040579,
                "percent": 5
              },
              {
                "country": "United Kingdom",
                "value": 1012829,
                "percent": 4.86
              },
              {
                "country": "Australia",
                "value": 509972,
                "percent": 2.45
              },
              {
                "country": "other",
                "value": 5656052,
                "percent": 27.16
              }
            ],
            "sources": {
              "direct": {
                "value": 3540896,
                "percent": 17
              },
              "search_organic": {
                "value": 13633269,
                "percent": 65.47,
                "top_keywords": [
                  {
                    "keyword": "fbi smart tv warning",
                    "value": 211315,
                    "percent": 1.55
                  },
                  {
                    "keyword": "common interview questions",
                    "value": 145875,
                    "percent": 1.07
                  },
                  {
                    "keyword": "visa gas station hackers",
                    "value": 94069,
                    "percent": 0.69
                  },
                  {
                    "keyword": "executive summary",
                    "value": 70892,
                    "percent": 0.52
                  },
                  {
                    "keyword": "elon musk",
                    "value": 70892,
                    "percent": 0.52
                  }
                ]
              },
              "search_ad": {
                "value": 1363,
                "percent": 0.01,
                "top_keywords": [
                  {
                    "keyword": "original vintage igloo marine fishing cooler with rope handles",
                    "value": 0,
                    "percent": 0.01
                  },
                  {
                    "keyword": "inc 5000 list",
                    "value": 0,
                    "percent": 0
                  },
                  {
                    "keyword": "inc5000",
                    "value": 0,
                    "percent": 0
                  }
                ]
              },
              "referring": {
                "value": 762478,
                "percent": 3.66,
                "top_referring": [
                  {
                    "site": "askamanager.org",
                    "value": 241184,
                    "percent": 31.63
                  },
                  {
                    "site": "flipboard.com",
                    "value": 224021,
                    "percent": 29.38
                  },
                  {
                    "site": "feedly.com",
                    "value": 30383,
                    "percent": 3.98
                  },
                  {
                    "site": "apple.news",
                    "value": 20813,
                    "percent": 2.73
                  },
                  {
                    "site": "mix.com",
                    "value": 19463,
                    "percent": 2.55
                  }
                ]
              },
              "referral_destination": {
                "top_destinations": [
                  {
                    "site": "fastcompany.com"
                  },
                  {
                    "site": "usefulinterweb.com"
                  },
                  {
                    "site": "cnn.com"
                  },
                  {
                    "site": "politico.com"
                  },
                  {
                    "site": "bigthink.com"
                  }
                ]
              },
              "social": {
                "value": 2705900,
                "percent": 12.99,
                "top_socials": [
                  {
                    "site": "Facebook",
                    "value": 1545068,
                    "percent": 57.1
                  },
                  {
                    "site": "Linkedin",
                    "value": 407779,
                    "percent": 15.07
                  },
                  {
                    "site": "Twitter",
                    "value": 349061,
                    "percent": 12.9
                  },
                  {
                    "site": "Pocket",
                    "value": 343919,
                    "percent": 12.71
                  },
                  {
                    "site": "Reddit",
                    "value": 19753,
                    "percent": 0.73
                  }
                ]
              },
              "mobile_apps": {
                "google_play_store": [
                  {
                    "app_id": "com.maz.combo426",
                    "app_title": "Inc. Must Reads and Magazine",
                    "app_price": "Free",
                    "app_rating": "75.55%",
                    "app_link": "play.google.com/store/apps/details?id=com.maz.combo426"
                  },
                  {
                    "app_id": "mobile.appkHO6S29Ycf",
                    "app_title": "Inc. Live",
                    "app_price": "Free",
                    "app_rating": "0%",
                    "app_link": "play.google.com/store/apps/details?id=mobile.appkHO6S29Ycf"
                  },
                  {
                    "app_id": "com.maz.combo655",
                    "app_title": "Fast Company",
                    "app_price": "Free",
                    "app_rating": "70.7%",
                    "app_link": "play.google.com/store/apps/details?id=com.maz.combo655"
                  },
                  {
                    "app_id": "com.techno.batto",
                    "app_title": "Batto Buy & Sell Simple",
                    "app_price": "Free",
                    "app_rating": "101%",
                    "app_link": "play.google.com/store/apps/details?id=com.techno.batto"
                  }
                ],
                "app_store": [
                  {
                    "app_id": "1437804605",
                    "app_title": "Inc. Live",
                    "app_price": "0.0 USD",
                    "app_rating": "0%",
                    "app_link": "itunes.apple.com/us/app/id1437804605"
                  },
                  {
                    "app_id": "503518270",
                    "app_title": "Inc. Must Reads and Magazine",
                    "app_price": "0.0 USD",
                    "app_rating": "80.8%",
                    "app_link": "itunes.apple.com/us/app/id503518270"
                  },
                  {
                    "app_id": "1238306363",
                    "app_title": "Sổ Tay Tiếng Anh Giao Tiếp Hàng...",
                    "app_price": "0.0 USD",
                    "app_rating": "90.9%",
                    "app_link": "itunes.apple.com/us/app/id1238306363"
                  },
                  {
                    "app_id": "1496540218",
                    "app_title": "Quotes Moto",
                    "app_price": "0.0 USD",
                    "app_rating": "0%",
                    "app_link": "itunes.apple.com/us/app/id1496540218"
                  }
                ]
              },
              "mail": {
                "value": 156641,
                "percent": 0.75
              }
            },
            "estimated": {
              "2019-07-01": 19058638,
              "2019-08-01": 24674200,
              "2019-09-01": 22686261,
              "2019-10-01": 22402744,
              "2019-11-01": 20402664,
              "2019-12-01": 20824935
            }
          },
          "sites": {
            "similar_sites": [
              {
                "site": "entrepreneur.com",
                "rank": 5340
              },
              {
                "site": "forbes.com",
                "rank": 438
              },
              {
                "site": "fastcompany.com",
                "rank": 5788
              },
              {
                "site": "thebalancesmb.com",
                "rank": 10306
              },
              {
                "site": "bplans.com",
                "rank": 47465
              },
              {
                "site": "morebusiness.com",
                "rank": 616230
              },
              {
                "site": "businessnewsdaily.com",
                "rank": 50400
              },
              {
                "site": "mindtools.com",
                "rank": 35138
              },
              {
                "site": "bizfluent.com",
                "rank": 25970
              },
              {
                "site": "entrepreneurship.org",
                "rank": 1268989
              }
            ],
            "similar_sites_by_rank": [
              {
                "site": "businessinsider.com"
              },
              {
                "site": "forbes.com"
              },
              {
                "site": "cnbc.com"
              },
              {
                "site": "shopify.com"
              },
              {
                "site": "fool.com"
              },
              {
                "site": "statista.com"
              },
              {
                "site": "entrepreneur.com"
              },
              {
                "site": "fastcompany.com"
              },
              {
                "site": "hootsuite.com"
              },
              {
                "site": "hbr.org"
              }
            ]
          },
          "date": "2019-12-01"
        }
      ]
    }
  ]
}

Description of the fields for sending a request:

Field name Type Description
id string task identifier
unique task identifier in our system in the UUID format
you will be able to use it within 30 days to request the results of the task at any time

‌‌‌‌As a response of the API server, you will receive JSON-encoded data containing a tasks array with the information specific to the set tasks.

Description of the fields in the results array:

Field name Type Description
version string the current version of the API
status_code integer general status code
you can find the full list of the response codes here
status_message string general informational message
you can find the full list of general informational messages here
time string execution time, seconds
cost float total tasks cost, USD
tasks_count integer the number of tasks in the tasks array
tasks_error integer the number of tasks in the tasks array returned with an error
tasks array array of tasks
        id string task identifier
unique task identifier in our system in the UUID format
        status_code integer status code of the task
generated by DataForSEO; can be within the following range: 10000-60000
you can find the full list of the response codes here
        status_message string informational message of the task
you can find the full list of general informational messages here
        time string execution time, seconds
        cost float cost of the task, USD
        result_count integer number of elements in the result array
        path array URL path
        data array contains the same parameters that you specified in the POST request
        result array array of results
            site_url string target url
targeted domain URL
            site_description string description metatag of the main page
            global_rank array traffic rank of a targeted domain
as compared to other domains in the world
                rank integer global rank value
            country_rank array traffic rank of a targeted domain
as compared to other domains in the leading country
                rank integer country rank value
                country string the leading country
            category_rank array traffic rank of a targeted domain
as compared to other domains in the main category
                rank integer category rank value
                category string the main category
            audience array overall traffic and engagement metrics
on desktop and mobile devices
                visits integer total monthly visits
                time_on_site_avg float time on site
average session duration
                page_views_avg float page views
average number of pages viewed during the session
                bounce_rate float bounce rate
the percentage of visitors who navigated away from the site after viewing only one page
            traffic array traffic and its sources
for desktop only
                value integer total traffic volume
                percent float total traffic volume percentage
                countries array traffic by countries
                    country array country
                    value integer traffic volume from a country
                    percent float percentage of total traffic
            sources array traffic sources
for desktop only
                direct array direct traffic
                    value integer direct traffic volume
                    percent float percentage of direct traffic
                search_organic array organic search traffic
                    value integer organic search traffic volume
                    percent float percentage of organic search traffic
                    top_keywords array top organic search keywords by traffic volume
                      keyword string organic search keyword
                      value integer organic searcht raffic volume brought by a keyword
                      percent float percentage of organic search traffic brought by a keyword
                search_ad array paid search traffic
                    value integer paid search traffic volume
                    percent float percentage of paid search traffic
                    top_keywords array top paid search keywords by traffic volume
                      keyword string paid search keyword
                      value integer paid search traffic volume brought by a keyword
                      percent float percentage of paid search traffic brought by a keyword
                referring array organic referral traffic
                    value integer organic referral traffic volume
                    percent float percentage of organic referral traffic
                    top_referring array top referring sites
                      site string referral site
                      value integer organic referral traffic volume from a site
                      percent float percentage of organic referral traffic volume from a site
                referral_destination array sites that a targeted domain refers to
                    top_destinations array top sites that a targeted domain refers to
                      site string destination site
                social array social traffic
                    value integer social traffic volume
                    percent float percentage of social traffic
                    top_socials array top social networks by traffic volume
                      site string social network
                      value integer traffic volume
                      percent float percentage of traffic volume
                mobile_apps array mobile apps related to the targeted domain
                    google_play_store array related mobile apps in Google Play Store
                      app_id string unique application ID
                      app_title string application title
                      app_price string application price
                      app_rating string application rating
                      app_link string application link in Google Play Store
                    app_store array related mobile apps in Apple Store
                      app_id string unique application ID
                      app_title string application title
                      app_price string application price
                      app_rating string application rating
                      app_link string application link in Apple Store
                mail array traffic from email campaigns
                    value integer mail traffic value
                    percent float mail traffic percentage
            estimated array estimated traffic in previous months
for desktop only
                $month integer monthly traffic value
            sites array competitors and similar sites
                similar_sites array sites similar to the targeted site
sites that share the same audience, or compete for the same keywords, or have сommon links to and from the compared sites, or share similar content
                    site string similar site
                    rank integer global rank of a site
                similar_sites_by_rank array sites similar to the targeted site
sites that have close global rank values
                    site string similar site

‌‌