List of URLs that compete with a queried page (url_competitors)
url_competitors — method returns the list of URLs that compete with a queried URL in organic search.
Metrics | Description |
result | Encapsulates the answer |
total | Number of keywords for which URL ranks in top-10 |
Number of keywords for which URL ranks in top-10 | |
domain | Competitor's domain |
url | Competitor's URL |
status_msg | Response "OK" or "Error" report on a successful or unsuccessful request |
status_code | Response code "200" — successful request. Errors occur when limits are exceeded (number of simultaneous requests or account limits) |
left_lines | Number of remaining API queries |
Part of the API response, for which 1 limit is charged:
{
"cnt": 27,
"domain": "wikipedia.org",
"url": "https://en.wikipedia.org/wiki/Example.com"
}
{
"result": {
"total": 1,
"hits": [
{
"cnt": 27,
"domain": "wikipedia.org",
"url": "https://en.wikipedia.org/wiki/Example.com"
},
{
"cnt": 8,
"domain": "sitepoint.com",
"url": "https://www.sitepoint.com/examplecom-vs-wwwexamplecom-trouble/"
},
{
"cnt": 8,
"domain": "digitalocean.com",
"url": "https://www.digitalocean.com/community/questions/redirecting-from-http-example-com-to-https-www-example-com"
}
]
},
"status_msg": "OK",
"status_code": 200,
"left_lines": 343979
}
<?php
// This example works on serpstat-sdk only
// https://github.com/SerpstatGlobal/serpstat-sdk
require_once __DIR__ . '/../vendor/autoload.php';
// configure your application
$config = [
'token' => '19666fc1ae1724da1d5ea2f3a99d5f5a',
];
$url = 'http://example.com/page1/';
// init client with your serpstat api token
$apiClient = new \Serpstat\Sdk\Core\ApiGuzzleHttpClient($config['token']);
// create instance of any api method class
// list of methods classes in folder src\Methods
$apiMethod = new \Serpstat\Sdk\Methods\UrlCompetitorsMethod(
$url,
\Serpstat\Sdk\Interfaces\IApiClient::SE_GOOGLE_RU
);
try {
// try call api method
$response = $apiClient->call($apiMethod);
} catch (\Exception $e) {
// catch api error
$response = $e->getMessage();
}
import codecs
import json
import pprint
import urllib.request as urlrequest
from urllib.parse import urlencode
host = 'http://api.serpstat.com/v3'
method = 'url_competitors'
params = {
'query': 'http%3A%2F%2Fwww.amazon.com%2FWinter-Is-Coming%2Fdp%2FB007HJ84ZK', # string for get info
'se': 'g_us', # string search engine
'token': 'ijmiom4f5m34905g03um8342dm04923lre3w', # string personal token
}
api_url = "{host}/{method}?{params}".format(
host=host,
method=method,
params=urlencode(params)
)
try:
json_data = urlrequest.urlopen(api_url).read()
except Exception as e0:
print("API request error: {error}".format(error=e0))
data = json.loads(json_data)
pprint.pprint(data)