universal-mcp 0.1.7rc1__py3-none-any.whl → 0.1.8__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- universal_mcp/__init__.py +0 -2
- universal_mcp/analytics.py +75 -0
- universal_mcp/applications/ahrefs/README.md +76 -0
- universal_mcp/applications/ahrefs/app.py +2291 -0
- universal_mcp/applications/application.py +95 -5
- universal_mcp/applications/calendly/README.md +78 -0
- universal_mcp/applications/calendly/__init__.py +0 -0
- universal_mcp/applications/calendly/app.py +1195 -0
- universal_mcp/applications/coda/README.md +133 -0
- universal_mcp/applications/coda/__init__.py +0 -0
- universal_mcp/applications/coda/app.py +3671 -0
- universal_mcp/applications/e2b/app.py +14 -28
- universal_mcp/applications/figma/README.md +74 -0
- universal_mcp/applications/figma/__init__.py +0 -0
- universal_mcp/applications/figma/app.py +1261 -0
- universal_mcp/applications/firecrawl/app.py +38 -35
- universal_mcp/applications/github/app.py +127 -85
- universal_mcp/applications/google_calendar/app.py +62 -138
- universal_mcp/applications/google_docs/app.py +47 -52
- universal_mcp/applications/google_drive/app.py +119 -113
- universal_mcp/applications/google_mail/app.py +124 -50
- universal_mcp/applications/google_sheet/app.py +89 -91
- universal_mcp/applications/markitdown/app.py +9 -8
- universal_mcp/applications/notion/app.py +254 -134
- universal_mcp/applications/perplexity/app.py +13 -41
- universal_mcp/applications/reddit/app.py +94 -85
- universal_mcp/applications/resend/app.py +12 -13
- universal_mcp/applications/{serp → serpapi}/app.py +14 -25
- universal_mcp/applications/tavily/app.py +11 -18
- universal_mcp/applications/wrike/README.md +71 -0
- universal_mcp/applications/wrike/__init__.py +0 -0
- universal_mcp/applications/wrike/app.py +1372 -0
- universal_mcp/applications/youtube/README.md +82 -0
- universal_mcp/applications/youtube/__init__.py +0 -0
- universal_mcp/applications/youtube/app.py +1428 -0
- universal_mcp/applications/zenquotes/app.py +12 -2
- universal_mcp/exceptions.py +9 -2
- universal_mcp/integrations/__init__.py +24 -1
- universal_mcp/integrations/agentr.py +27 -4
- universal_mcp/integrations/integration.py +146 -32
- universal_mcp/logger.py +3 -56
- universal_mcp/servers/__init__.py +6 -14
- universal_mcp/servers/server.py +201 -146
- universal_mcp/stores/__init__.py +7 -2
- universal_mcp/stores/store.py +103 -40
- universal_mcp/tools/__init__.py +3 -0
- universal_mcp/tools/adapters.py +43 -0
- universal_mcp/tools/func_metadata.py +213 -0
- universal_mcp/tools/tools.py +342 -0
- universal_mcp/utils/docgen.py +325 -119
- universal_mcp/utils/docstring_parser.py +179 -0
- universal_mcp/utils/dump_app_tools.py +33 -23
- universal_mcp/utils/installation.py +201 -10
- universal_mcp/utils/openapi.py +229 -46
- {universal_mcp-0.1.7rc1.dist-info → universal_mcp-0.1.8.dist-info}/METADATA +9 -5
- universal_mcp-0.1.8.dist-info/RECORD +81 -0
- universal_mcp-0.1.7rc1.dist-info/RECORD +0 -58
- /universal_mcp/{utils/bridge.py → applications/ahrefs/__init__.py} +0 -0
- /universal_mcp/applications/{serp → serpapi}/README.md +0 -0
- {universal_mcp-0.1.7rc1.dist-info → universal_mcp-0.1.8.dist-info}/WHEEL +0 -0
- {universal_mcp-0.1.7rc1.dist-info → universal_mcp-0.1.8.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,2291 @@
|
|
1
|
+
from typing import Any
|
2
|
+
|
3
|
+
from universal_mcp.applications import APIApplication
|
4
|
+
from universal_mcp.integrations import Integration
|
5
|
+
|
6
|
+
|
7
|
+
class AhrefsApp(APIApplication):
|
8
|
+
def __init__(self, integration: Integration = None, **kwargs) -> None:
|
9
|
+
super().__init__(name="ahrefs", integration=integration, **kwargs)
|
10
|
+
self.base_url = "https://api.ahrefs.com/v3"
|
11
|
+
|
12
|
+
def crawler_ips(self, output=None) -> dict[str, Any]:
|
13
|
+
"""
|
14
|
+
Retrieve the list of public crawler IP addresses from the API.
|
15
|
+
|
16
|
+
Args:
|
17
|
+
output: Optional; the desired format of the output. If provided, it is included as a query parameter in the request.
|
18
|
+
|
19
|
+
Returns:
|
20
|
+
A dictionary containing the API response with crawler IP information.
|
21
|
+
|
22
|
+
Raises:
|
23
|
+
requests.HTTPError: If the HTTP request to the API fails or returns a non-success status code.
|
24
|
+
|
25
|
+
Tags:
|
26
|
+
fetch, crawler-ips, api
|
27
|
+
"""
|
28
|
+
url = f"{self.base_url}/public/crawler-ips"
|
29
|
+
query_params = {k: v for k, v in [("output", output)] if v is not None}
|
30
|
+
response = self._get(url, params=query_params)
|
31
|
+
response.raise_for_status()
|
32
|
+
return response.json()
|
33
|
+
|
34
|
+
def crawler_ip_ranges(self, output=None) -> dict[str, Any]:
|
35
|
+
"""
|
36
|
+
Fetches the current public crawler IP ranges from the API, optionally specifying output format.
|
37
|
+
|
38
|
+
Args:
|
39
|
+
output: Optional output format for the IP ranges list. If None, the default format is used.
|
40
|
+
|
41
|
+
Returns:
|
42
|
+
A dictionary containing the crawler IP ranges as provided by the API.
|
43
|
+
|
44
|
+
Raises:
|
45
|
+
requests.HTTPError: If the HTTP request to the API fails or returns an unsuccessful status code.
|
46
|
+
|
47
|
+
Tags:
|
48
|
+
fetch, crawler-ip, network, api, important
|
49
|
+
"""
|
50
|
+
url = f"{self.base_url}/public/crawler-ip-ranges"
|
51
|
+
query_params = {k: v for k, v in [("output", output)] if v is not None}
|
52
|
+
response = self._get(url, params=query_params)
|
53
|
+
response.raise_for_status()
|
54
|
+
return response.json()
|
55
|
+
|
56
|
+
def limits_and_usage(self, output=None) -> dict[str, Any]:
|
57
|
+
"""
|
58
|
+
Retrieves current API subscription limits and usage statistics from the service.
|
59
|
+
|
60
|
+
Args:
|
61
|
+
output: Optional; specifies the output format or filter for the request. If None, default output is used.
|
62
|
+
|
63
|
+
Returns:
|
64
|
+
A dictionary containing details about subscription limits and current usage statistics.
|
65
|
+
|
66
|
+
Raises:
|
67
|
+
HTTPError: If the HTTP request to the subscription-info endpoint fails or returns an error status.
|
68
|
+
|
69
|
+
Tags:
|
70
|
+
fetch, limits, usage, subscription, api
|
71
|
+
"""
|
72
|
+
url = f"{self.base_url}/subscription-info/limits-and-usage"
|
73
|
+
query_params = {k: v for k, v in [("output", output)] if v is not None}
|
74
|
+
response = self._get(url, params=query_params)
|
75
|
+
response.raise_for_status()
|
76
|
+
return response.json()
|
77
|
+
|
78
|
+
def batch_analysis(
|
79
|
+
self,
|
80
|
+
select,
|
81
|
+
targets,
|
82
|
+
order_by=None,
|
83
|
+
country=None,
|
84
|
+
volume_mode=None,
|
85
|
+
output=None,
|
86
|
+
) -> dict[str, Any]:
|
87
|
+
"""
|
88
|
+
Submits a batch analysis request with specified parameters and returns the analysis results as a dictionary.
|
89
|
+
|
90
|
+
Args:
|
91
|
+
select: The fields to be selected in the batch analysis request. Must not be None.
|
92
|
+
targets: A list or structure specifying the analysis targets. Must not be None.
|
93
|
+
order_by: Optional. Specifies sorting for the analysis output.
|
94
|
+
country: Optional. Country code filter for the analysis.
|
95
|
+
volume_mode: Optional. Analysis mode related to volume calculation.
|
96
|
+
output: Optional. Specifies the desired output format or configuration.
|
97
|
+
|
98
|
+
Returns:
|
99
|
+
A dictionary containing the batch analysis results returned by the API.
|
100
|
+
|
101
|
+
Raises:
|
102
|
+
ValueError: Raised if either 'select' or 'targets' is None.
|
103
|
+
requests.HTTPError: Raised if the HTTP request to the batch analysis endpoint fails.
|
104
|
+
|
105
|
+
Tags:
|
106
|
+
batch-analysis, submit, ai, management, async_job
|
107
|
+
"""
|
108
|
+
if select is None:
|
109
|
+
raise ValueError("Missing required parameter 'select'")
|
110
|
+
if targets is None:
|
111
|
+
raise ValueError("Missing required parameter 'targets'")
|
112
|
+
request_body = {
|
113
|
+
"select": select,
|
114
|
+
"order_by": order_by,
|
115
|
+
"country": country,
|
116
|
+
"volume_mode": volume_mode,
|
117
|
+
"targets": targets,
|
118
|
+
"output": output,
|
119
|
+
}
|
120
|
+
request_body = {k: v for k, v in request_body.items() if v is not None}
|
121
|
+
url = f"{self.base_url}/batch-analysis/batch-analysis"
|
122
|
+
query_params = {}
|
123
|
+
response = self._post(url, data=request_body, params=query_params)
|
124
|
+
response.raise_for_status()
|
125
|
+
return response.json()
|
126
|
+
|
127
|
+
def serp_overview(
|
128
|
+
self, select, country, keyword, top_positions=None, date=None, output=None
|
129
|
+
) -> dict[str, Any]:
|
130
|
+
"""
|
131
|
+
Retrieves a SERP (Search Engine Results Page) overview report based on specified selection, country, and keyword criteria.
|
132
|
+
|
133
|
+
Args:
|
134
|
+
select: str. The type of overview or metrics to retrieve. Required.
|
135
|
+
country: str. The country code indicating the region for the SERP data. Required.
|
136
|
+
keyword: str. The target keyword for which to fetch the SERP overview. Required.
|
137
|
+
top_positions: Optional[int]. The number of top-ranking positions to include in the results. Defaults to None.
|
138
|
+
date: Optional[str]. The specific date for the SERP data in YYYY-MM-DD format. Defaults to None.
|
139
|
+
output: Optional[str]. Output format or preferences for the response. Defaults to None.
|
140
|
+
|
141
|
+
Returns:
|
142
|
+
dict[str, Any]: A dictionary containing the SERP overview results as returned by the external API.
|
143
|
+
|
144
|
+
Raises:
|
145
|
+
ValueError: If any of the required parameters ('select', 'country', or 'keyword') are missing or None.
|
146
|
+
requests.HTTPError: If the HTTP request to the API fails or an invalid response is received.
|
147
|
+
|
148
|
+
Tags:
|
149
|
+
serp, overview, fetch, search, report, important
|
150
|
+
"""
|
151
|
+
if select is None:
|
152
|
+
raise ValueError("Missing required parameter 'select'")
|
153
|
+
if country is None:
|
154
|
+
raise ValueError("Missing required parameter 'country'")
|
155
|
+
if keyword is None:
|
156
|
+
raise ValueError("Missing required parameter 'keyword'")
|
157
|
+
url = f"{self.base_url}/serp-overview/serp-overview"
|
158
|
+
query_params = {
|
159
|
+
k: v
|
160
|
+
for k, v in [
|
161
|
+
("select", select),
|
162
|
+
("top_positions", top_positions),
|
163
|
+
("date", date),
|
164
|
+
("country", country),
|
165
|
+
("keyword", keyword),
|
166
|
+
("output", output),
|
167
|
+
]
|
168
|
+
if v is not None
|
169
|
+
}
|
170
|
+
response = self._get(url, params=query_params)
|
171
|
+
response.raise_for_status()
|
172
|
+
return response.json()
|
173
|
+
|
174
|
+
def overview(
|
175
|
+
self,
|
176
|
+
select,
|
177
|
+
date,
|
178
|
+
device,
|
179
|
+
project_id,
|
180
|
+
timeout=None,
|
181
|
+
offset=None,
|
182
|
+
limit=None,
|
183
|
+
order_by=None,
|
184
|
+
where=None,
|
185
|
+
date_compared=None,
|
186
|
+
volume_mode=None,
|
187
|
+
output=None,
|
188
|
+
) -> dict[str, Any]:
|
189
|
+
"""
|
190
|
+
Retrieves rank tracking overview data for a specified project, date, and device.
|
191
|
+
|
192
|
+
Args:
|
193
|
+
select: Fields to include in the response (required).
|
194
|
+
date: Date for which to retrieve data (required).
|
195
|
+
device: Device type to filter data by (required).
|
196
|
+
project_id: ID of the project to retrieve data for (required).
|
197
|
+
timeout: Maximum time to wait for the response in seconds.
|
198
|
+
offset: Number of items to skip in the result set.
|
199
|
+
limit: Maximum number of items to return.
|
200
|
+
order_by: Field to sort results by.
|
201
|
+
where: Filter condition for the results.
|
202
|
+
date_compared: Date to compare results against.
|
203
|
+
volume_mode: Mode for volume calculations.
|
204
|
+
output: Output format of the response.
|
205
|
+
|
206
|
+
Returns:
|
207
|
+
A dictionary containing rank tracking overview data.
|
208
|
+
|
209
|
+
Raises:
|
210
|
+
ValueError: Raised when any of the required parameters (select, date, device, project_id) is not provided.
|
211
|
+
|
212
|
+
Tags:
|
213
|
+
retrieve, overview, rank-tracker, data, api
|
214
|
+
"""
|
215
|
+
if select is None:
|
216
|
+
raise ValueError("Missing required parameter 'select'")
|
217
|
+
if date is None:
|
218
|
+
raise ValueError("Missing required parameter 'date'")
|
219
|
+
if device is None:
|
220
|
+
raise ValueError("Missing required parameter 'device'")
|
221
|
+
if project_id is None:
|
222
|
+
raise ValueError("Missing required parameter 'project_id'")
|
223
|
+
url = f"{self.base_url}/rank-tracker/overview"
|
224
|
+
query_params = {
|
225
|
+
k: v
|
226
|
+
for k, v in [
|
227
|
+
("timeout", timeout),
|
228
|
+
("offset", offset),
|
229
|
+
("limit", limit),
|
230
|
+
("order_by", order_by),
|
231
|
+
("where", where),
|
232
|
+
("select", select),
|
233
|
+
("date_compared", date_compared),
|
234
|
+
("date", date),
|
235
|
+
("device", device),
|
236
|
+
("project_id", project_id),
|
237
|
+
("volume_mode", volume_mode),
|
238
|
+
("output", output),
|
239
|
+
]
|
240
|
+
if v is not None
|
241
|
+
}
|
242
|
+
response = self._get(url, params=query_params)
|
243
|
+
response.raise_for_status()
|
244
|
+
return response.json()
|
245
|
+
|
246
|
+
def competitors_overview(
|
247
|
+
self,
|
248
|
+
select,
|
249
|
+
date,
|
250
|
+
device,
|
251
|
+
project_id,
|
252
|
+
timeout=None,
|
253
|
+
offset=None,
|
254
|
+
limit=None,
|
255
|
+
order_by=None,
|
256
|
+
where=None,
|
257
|
+
date_compared=None,
|
258
|
+
volume_mode=None,
|
259
|
+
output=None,
|
260
|
+
) -> dict[str, Any]:
|
261
|
+
"""
|
262
|
+
Retrieves an overview of competitor rankings for a specified project and criteria.
|
263
|
+
|
264
|
+
Args:
|
265
|
+
select: Fields to retrieve in the overview; required.
|
266
|
+
date: Date for which the overview is requested (format: YYYY-MM-DD); required.
|
267
|
+
device: Device type to filter ranking data (e.g., 'desktop', 'mobile'); required.
|
268
|
+
project_id: Unique identifier for the target project; required.
|
269
|
+
timeout: Optional request timeout in seconds.
|
270
|
+
offset: Optional pagination offset for the result set.
|
271
|
+
limit: Optional maximum number of records to return.
|
272
|
+
order_by: Optional sorting order of the results.
|
273
|
+
where: Optional filter expression for result narrowing.
|
274
|
+
date_compared: Optional comparison date for historical ranking comparison.
|
275
|
+
volume_mode: Optional mode for search volume calculation.
|
276
|
+
output: Optional format for the output data.
|
277
|
+
|
278
|
+
Returns:
|
279
|
+
A dictionary containing the competitors overview data retrieved from the rank tracker service.
|
280
|
+
|
281
|
+
Raises:
|
282
|
+
ValueError: If any of the required parameters ('select', 'date', 'device', or 'project_id') are missing.
|
283
|
+
requests.HTTPError: If the HTTP request to the underlying service fails or returns an error response.
|
284
|
+
|
285
|
+
Tags:
|
286
|
+
competitors-overview, fetch, api, management, batch
|
287
|
+
"""
|
288
|
+
if select is None:
|
289
|
+
raise ValueError("Missing required parameter 'select'")
|
290
|
+
if date is None:
|
291
|
+
raise ValueError("Missing required parameter 'date'")
|
292
|
+
if device is None:
|
293
|
+
raise ValueError("Missing required parameter 'device'")
|
294
|
+
if project_id is None:
|
295
|
+
raise ValueError("Missing required parameter 'project_id'")
|
296
|
+
url = f"{self.base_url}/rank-tracker/competitors-overview"
|
297
|
+
query_params = {
|
298
|
+
k: v
|
299
|
+
for k, v in [
|
300
|
+
("timeout", timeout),
|
301
|
+
("offset", offset),
|
302
|
+
("limit", limit),
|
303
|
+
("order_by", order_by),
|
304
|
+
("where", where),
|
305
|
+
("select", select),
|
306
|
+
("date_compared", date_compared),
|
307
|
+
("date", date),
|
308
|
+
("device", device),
|
309
|
+
("project_id", project_id),
|
310
|
+
("volume_mode", volume_mode),
|
311
|
+
("output", output),
|
312
|
+
]
|
313
|
+
if v is not None
|
314
|
+
}
|
315
|
+
response = self._get(url, params=query_params)
|
316
|
+
response.raise_for_status()
|
317
|
+
return response.json()
|
318
|
+
|
319
|
+
def projects(self, output=None) -> dict[str, Any]:
|
320
|
+
"""
|
321
|
+
Retrieves a list of site audit projects from the configured base URL, optionally specifying an output format.
|
322
|
+
|
323
|
+
Args:
|
324
|
+
output: Optional; the desired output format for the project list (e.g., 'json', 'csv'). If None, defaults to the API's standard format.
|
325
|
+
|
326
|
+
Returns:
|
327
|
+
A dictionary containing project information returned by the site audit projects API.
|
328
|
+
|
329
|
+
Raises:
|
330
|
+
HTTPError: Raised if the HTTP request to retrieve the project list encounters an unsuccessful status code.
|
331
|
+
|
332
|
+
Tags:
|
333
|
+
list, projects, api, http-get, site-audit
|
334
|
+
"""
|
335
|
+
url = f"{self.base_url}/site-audit/projects"
|
336
|
+
query_params = {k: v for k, v in [("output", output)] if v is not None}
|
337
|
+
response = self._get(url, params=query_params)
|
338
|
+
response.raise_for_status()
|
339
|
+
return response.json()
|
340
|
+
|
341
|
+
def domain_rating(self, target, date, protocol=None, output=None) -> dict[str, Any]:
|
342
|
+
"""
|
343
|
+
Fetches the domain rating and related metrics for a specified target and date.
|
344
|
+
|
345
|
+
Args:
|
346
|
+
target: str. The domain or URL to analyze. Required.
|
347
|
+
date: str. The date for which to retrieve the domain rating data. Required.
|
348
|
+
protocol: str or None. The protocol (e.g., 'http', 'https') to use for the request. Optional.
|
349
|
+
output: str or None. The output format for the response, if applicable. Optional.
|
350
|
+
|
351
|
+
Returns:
|
352
|
+
dict[str, Any]: A dictionary containing domain rating data and associated metrics for the given target and date.
|
353
|
+
|
354
|
+
Raises:
|
355
|
+
ValueError: If 'target' or 'date' parameters are missing.
|
356
|
+
requests.HTTPError: If the HTTP request fails or an error response is returned by the server.
|
357
|
+
|
358
|
+
Tags:
|
359
|
+
fetch, domain-rating, api, management
|
360
|
+
"""
|
361
|
+
if target is None:
|
362
|
+
raise ValueError("Missing required parameter 'target'")
|
363
|
+
if date is None:
|
364
|
+
raise ValueError("Missing required parameter 'date'")
|
365
|
+
url = f"{self.base_url}/site-explorer/domain-rating"
|
366
|
+
query_params = {
|
367
|
+
k: v
|
368
|
+
for k, v in [
|
369
|
+
("protocol", protocol),
|
370
|
+
("target", target),
|
371
|
+
("date", date),
|
372
|
+
("output", output),
|
373
|
+
]
|
374
|
+
if v is not None
|
375
|
+
}
|
376
|
+
response = self._get(url, params=query_params)
|
377
|
+
response.raise_for_status()
|
378
|
+
return response.json()
|
379
|
+
|
380
|
+
def backlinks_stats(
|
381
|
+
self, target, date, protocol=None, mode=None, output=None
|
382
|
+
) -> dict[str, Any]:
|
383
|
+
"""
|
384
|
+
Retrieves backlink statistics for a specified target and date, with optional filters for protocol, mode, and output format.
|
385
|
+
|
386
|
+
Args:
|
387
|
+
target: str. The target domain or URL for which to retrieve backlink statistics.
|
388
|
+
date: str. The date for which the backlink statistics are requested (typically in 'YYYY-MM-DD' format).
|
389
|
+
protocol: Optional[str]. Type of protocol filter to apply (e.g., 'http', 'https'). Defaults to None.
|
390
|
+
mode: Optional[str]. The analysis mode or additional filter to refine results. Defaults to None.
|
391
|
+
output: Optional[str]. The output format for the results. Defaults to None.
|
392
|
+
|
393
|
+
Returns:
|
394
|
+
dict[str, Any]: A dictionary containing the backlink statistics data retrieved from the API.
|
395
|
+
|
396
|
+
Raises:
|
397
|
+
ValueError: Raised if the required 'target' or 'date' parameters are missing.
|
398
|
+
requests.HTTPError: Raised if the HTTP request to the underlying API fails or returns a non-success status code.
|
399
|
+
|
400
|
+
Tags:
|
401
|
+
fetch, backlinks, stats, seo, important
|
402
|
+
"""
|
403
|
+
if target is None:
|
404
|
+
raise ValueError("Missing required parameter 'target'")
|
405
|
+
if date is None:
|
406
|
+
raise ValueError("Missing required parameter 'date'")
|
407
|
+
url = f"{self.base_url}/site-explorer/backlinks-stats"
|
408
|
+
query_params = {
|
409
|
+
k: v
|
410
|
+
for k, v in [
|
411
|
+
("protocol", protocol),
|
412
|
+
("target", target),
|
413
|
+
("mode", mode),
|
414
|
+
("date", date),
|
415
|
+
("output", output),
|
416
|
+
]
|
417
|
+
if v is not None
|
418
|
+
}
|
419
|
+
response = self._get(url, params=query_params)
|
420
|
+
response.raise_for_status()
|
421
|
+
return response.json()
|
422
|
+
|
423
|
+
def outlinks_stats(
|
424
|
+
self, target, protocol=None, mode=None, output=None
|
425
|
+
) -> dict[str, Any]:
|
426
|
+
"""
|
427
|
+
Retrieves outbound link statistics for the specified target from the site explorer API.
|
428
|
+
|
429
|
+
Args:
|
430
|
+
target: str. The required target (such as a domain or URL) for which to fetch outlink statistics.
|
431
|
+
protocol: Optional[str]. The protocol filter to apply (e.g., 'http', 'https'). Defaults to None.
|
432
|
+
mode: Optional[str]. The mode of operation or data retrieval (if supported by the API). Defaults to None.
|
433
|
+
output: Optional[str]. The desired output format, if applicable. Defaults to None.
|
434
|
+
|
435
|
+
Returns:
|
436
|
+
dict[str, Any]: A dictionary containing the outlink statistics retrieved from the API.
|
437
|
+
|
438
|
+
Raises:
|
439
|
+
ValueError: If the required 'target' parameter is not provided.
|
440
|
+
requests.HTTPError: If the API request fails or returns a non-success status code.
|
441
|
+
|
442
|
+
Tags:
|
443
|
+
outlinks, fetch, site-explorer, stats, api
|
444
|
+
"""
|
445
|
+
if target is None:
|
446
|
+
raise ValueError("Missing required parameter 'target'")
|
447
|
+
url = f"{self.base_url}/site-explorer/outlinks-stats"
|
448
|
+
query_params = {
|
449
|
+
k: v
|
450
|
+
for k, v in [
|
451
|
+
("protocol", protocol),
|
452
|
+
("mode", mode),
|
453
|
+
("target", target),
|
454
|
+
("output", output),
|
455
|
+
]
|
456
|
+
if v is not None
|
457
|
+
}
|
458
|
+
response = self._get(url, params=query_params)
|
459
|
+
response.raise_for_status()
|
460
|
+
return response.json()
|
461
|
+
|
462
|
+
def metrics(
|
463
|
+
self,
|
464
|
+
target,
|
465
|
+
date,
|
466
|
+
volume_mode=None,
|
467
|
+
country=None,
|
468
|
+
protocol=None,
|
469
|
+
mode=None,
|
470
|
+
output=None,
|
471
|
+
) -> dict[str, Any]:
|
472
|
+
"""
|
473
|
+
Retrieves metrics data from the site explorer API endpoint.
|
474
|
+
|
475
|
+
Args:
|
476
|
+
target: The target website or URL to retrieve metrics for.
|
477
|
+
date: The date for which to retrieve metrics data.
|
478
|
+
volume_mode: Optional. The volume mode parameter for filtering results.
|
479
|
+
country: Optional. The country code to filter results by.
|
480
|
+
protocol: Optional. The protocol (e.g., 'http', 'https') to filter results by.
|
481
|
+
mode: Optional. The mode parameter for controlling the type of metrics returned.
|
482
|
+
output: Optional. The format of the output data.
|
483
|
+
|
484
|
+
Returns:
|
485
|
+
A dictionary containing the metrics data retrieved from the API.
|
486
|
+
|
487
|
+
Raises:
|
488
|
+
ValueError: Raised when required parameters 'target' or 'date' are missing.
|
489
|
+
HTTPError: Raised when the API request fails (via raise_for_status()).
|
490
|
+
|
491
|
+
Tags:
|
492
|
+
retrieve, metrics, site-explorer, api, data
|
493
|
+
"""
|
494
|
+
if target is None:
|
495
|
+
raise ValueError("Missing required parameter 'target'")
|
496
|
+
if date is None:
|
497
|
+
raise ValueError("Missing required parameter 'date'")
|
498
|
+
url = f"{self.base_url}/site-explorer/metrics"
|
499
|
+
query_params = {
|
500
|
+
k: v
|
501
|
+
for k, v in [
|
502
|
+
("volume_mode", volume_mode),
|
503
|
+
("country", country),
|
504
|
+
("protocol", protocol),
|
505
|
+
("target", target),
|
506
|
+
("mode", mode),
|
507
|
+
("date", date),
|
508
|
+
("output", output),
|
509
|
+
]
|
510
|
+
if v is not None
|
511
|
+
}
|
512
|
+
response = self._get(url, params=query_params)
|
513
|
+
response.raise_for_status()
|
514
|
+
return response.json()
|
515
|
+
|
516
|
+
def refdomains_history(
|
517
|
+
self,
|
518
|
+
date_from,
|
519
|
+
target,
|
520
|
+
history_grouping=None,
|
521
|
+
date_to=None,
|
522
|
+
protocol=None,
|
523
|
+
mode=None,
|
524
|
+
output=None,
|
525
|
+
) -> dict[str, Any]:
|
526
|
+
"""
|
527
|
+
Retrieves the historical data of reference domains from a specified site.
|
528
|
+
|
529
|
+
Args:
|
530
|
+
date_from: The start date for retrieving historical data.
|
531
|
+
target: The target for which to retrieve reference domains data.
|
532
|
+
history_grouping: Optional parameter to specify how the history should be grouped.
|
533
|
+
date_to: Optional end date for retrieving historical data.
|
534
|
+
protocol: Optional protocol to filter the data.
|
535
|
+
mode: Optional mode to use for the query.
|
536
|
+
output: Optional format of the output.
|
537
|
+
|
538
|
+
Returns:
|
539
|
+
A dictionary containing historical reference domains data.
|
540
|
+
|
541
|
+
Raises:
|
542
|
+
ValueError: Raised if either 'date_from' or 'target' parameter is missing.
|
543
|
+
|
544
|
+
Tags:
|
545
|
+
search, history , management, ai
|
546
|
+
"""
|
547
|
+
if date_from is None:
|
548
|
+
raise ValueError("Missing required parameter 'date_from'")
|
549
|
+
if target is None:
|
550
|
+
raise ValueError("Missing required parameter 'target'")
|
551
|
+
url = f"{self.base_url}/site-explorer/refdomains-history"
|
552
|
+
query_params = {
|
553
|
+
k: v
|
554
|
+
for k, v in [
|
555
|
+
("history_grouping", history_grouping),
|
556
|
+
("date_to", date_to),
|
557
|
+
("date_from", date_from),
|
558
|
+
("protocol", protocol),
|
559
|
+
("target", target),
|
560
|
+
("mode", mode),
|
561
|
+
("output", output),
|
562
|
+
]
|
563
|
+
if v is not None
|
564
|
+
}
|
565
|
+
response = self._get(url, params=query_params)
|
566
|
+
response.raise_for_status()
|
567
|
+
return response.json()
|
568
|
+
|
569
|
+
def domain_rating_history(
|
570
|
+
self, date_from, target, history_grouping=None, date_to=None, output=None
|
571
|
+
) -> dict[str, Any]:
|
572
|
+
"""
|
573
|
+
Retrieves historical domain rating data for a specified target within a given date range.
|
574
|
+
|
575
|
+
Args:
|
576
|
+
date_from: str. The start date for the domain rating history range (format: YYYY-MM-DD). Required.
|
577
|
+
target: str. The domain or target for which the rating history is requested. Required.
|
578
|
+
history_grouping: Optional[str]. Granularity for grouping history data (e.g., by day, week, or month).
|
579
|
+
date_to: Optional[str]. The end date for the domain rating history range (format: YYYY-MM-DD).
|
580
|
+
output: Optional[str]. Desired output format or additional output options.
|
581
|
+
|
582
|
+
Returns:
|
583
|
+
dict[str, Any]: Parsed JSON response containing domain rating history data for the specified parameters.
|
584
|
+
|
585
|
+
Raises:
|
586
|
+
ValueError: If 'date_from' or 'target' is not provided.
|
587
|
+
requests.HTTPError: If the HTTP request to the API fails or returns an error status.
|
588
|
+
|
589
|
+
Tags:
|
590
|
+
fetch, domain-rating, history, api
|
591
|
+
"""
|
592
|
+
if date_from is None:
|
593
|
+
raise ValueError("Missing required parameter 'date_from'")
|
594
|
+
if target is None:
|
595
|
+
raise ValueError("Missing required parameter 'target'")
|
596
|
+
url = f"{self.base_url}/site-explorer/domain-rating-history"
|
597
|
+
query_params = {
|
598
|
+
k: v
|
599
|
+
for k, v in [
|
600
|
+
("history_grouping", history_grouping),
|
601
|
+
("date_to", date_to),
|
602
|
+
("date_from", date_from),
|
603
|
+
("target", target),
|
604
|
+
("output", output),
|
605
|
+
]
|
606
|
+
if v is not None
|
607
|
+
}
|
608
|
+
response = self._get(url, params=query_params)
|
609
|
+
response.raise_for_status()
|
610
|
+
return response.json()
|
611
|
+
|
612
|
+
def url_rating_history(
|
613
|
+
self, date_from, target, history_grouping=None, date_to=None, output=None
|
614
|
+
) -> dict[str, Any]:
|
615
|
+
"""
|
616
|
+
Retrieves URL rating history data for a specified target within a date range.
|
617
|
+
|
618
|
+
Args:
|
619
|
+
date_from: Required string representing the start date for the rating history query.
|
620
|
+
target: Required string representing the URL target for which to retrieve rating history.
|
621
|
+
history_grouping: Optional parameter to specify how the history data should be grouped or aggregated.
|
622
|
+
date_to: Optional string representing the end date for the rating history query. If not provided, likely defaults to current date.
|
623
|
+
output: Optional parameter to specify the format or structure of the output data.
|
624
|
+
|
625
|
+
Returns:
|
626
|
+
A dictionary containing the URL rating history data for the specified target and date range.
|
627
|
+
|
628
|
+
Raises:
|
629
|
+
ValueError: Raised when required parameters 'date_from' or 'target' are not provided (None).
|
630
|
+
HTTPError: Raised when the API request fails, as triggered by response.raise_for_status().
|
631
|
+
|
632
|
+
Tags:
|
633
|
+
retrieve, rating, history, url, query, api
|
634
|
+
"""
|
635
|
+
if date_from is None:
|
636
|
+
raise ValueError("Missing required parameter 'date_from'")
|
637
|
+
if target is None:
|
638
|
+
raise ValueError("Missing required parameter 'target'")
|
639
|
+
url = f"{self.base_url}/site-explorer/url-rating-history"
|
640
|
+
query_params = {
|
641
|
+
k: v
|
642
|
+
for k, v in [
|
643
|
+
("history_grouping", history_grouping),
|
644
|
+
("date_to", date_to),
|
645
|
+
("date_from", date_from),
|
646
|
+
("target", target),
|
647
|
+
("output", output),
|
648
|
+
]
|
649
|
+
if v is not None
|
650
|
+
}
|
651
|
+
response = self._get(url, params=query_params)
|
652
|
+
response.raise_for_status()
|
653
|
+
return response.json()
|
654
|
+
|
655
|
+
def pages_history(
|
656
|
+
self,
|
657
|
+
date_from,
|
658
|
+
target,
|
659
|
+
history_grouping=None,
|
660
|
+
date_to=None,
|
661
|
+
country=None,
|
662
|
+
protocol=None,
|
663
|
+
mode=None,
|
664
|
+
output=None,
|
665
|
+
) -> dict[str, Any]:
|
666
|
+
"""
|
667
|
+
Retrieves historical page data for a target using specified filters.
|
668
|
+
|
669
|
+
Args:
|
670
|
+
date_from: str. The start date for the historical data in YYYY-MM-DD format. Required.
|
671
|
+
target: str. The URL or identifier of the website or resource to retrieve history for. Required.
|
672
|
+
history_grouping: str, optional. The method for grouping historical data, such as by day, week, or month.
|
673
|
+
date_to: str, optional. The end date for the historical data in YYYY-MM-DD format.
|
674
|
+
country: str, optional. The country code (e.g., 'US', 'GB') to filter data by region.
|
675
|
+
protocol: str, optional. The protocol to filter results, such as 'http' or 'https'.
|
676
|
+
mode: str, optional. The operation mode for the request, specifying data type or level.
|
677
|
+
output: str, optional. The desired output format or additional output controls.
|
678
|
+
|
679
|
+
Returns:
|
680
|
+
dict[str, Any]: A dictionary containing the JSON response with the historical page data matching the filters.
|
681
|
+
|
682
|
+
Raises:
|
683
|
+
ValueError: If 'date_from' or 'target' is not provided.
|
684
|
+
requests.HTTPError: If the underlying HTTP request fails or returns an unsuccessful status code.
|
685
|
+
|
686
|
+
Tags:
|
687
|
+
fetch, history, site-explorer, data, management
|
688
|
+
"""
|
689
|
+
if date_from is None:
|
690
|
+
raise ValueError("Missing required parameter 'date_from'")
|
691
|
+
if target is None:
|
692
|
+
raise ValueError("Missing required parameter 'target'")
|
693
|
+
url = f"{self.base_url}/site-explorer/pages-history"
|
694
|
+
query_params = {
|
695
|
+
k: v
|
696
|
+
for k, v in [
|
697
|
+
("history_grouping", history_grouping),
|
698
|
+
("date_to", date_to),
|
699
|
+
("date_from", date_from),
|
700
|
+
("country", country),
|
701
|
+
("protocol", protocol),
|
702
|
+
("target", target),
|
703
|
+
("mode", mode),
|
704
|
+
("output", output),
|
705
|
+
]
|
706
|
+
if v is not None
|
707
|
+
}
|
708
|
+
response = self._get(url, params=query_params)
|
709
|
+
response.raise_for_status()
|
710
|
+
return response.json()
|
711
|
+
|
712
|
+
def metrics_history(
|
713
|
+
self,
|
714
|
+
date_from,
|
715
|
+
target,
|
716
|
+
select=None,
|
717
|
+
volume_mode=None,
|
718
|
+
history_grouping=None,
|
719
|
+
date_to=None,
|
720
|
+
country=None,
|
721
|
+
protocol=None,
|
722
|
+
mode=None,
|
723
|
+
output=None,
|
724
|
+
) -> dict[str, Any]:
|
725
|
+
"""
|
726
|
+
Retrieves historical metrics based on specified parameters.
|
727
|
+
|
728
|
+
Args:
|
729
|
+
date_from: The start date for metrics history (required).
|
730
|
+
target: The target for which to retrieve metrics history (required).
|
731
|
+
select: Optional parameters to select which metrics to include.
|
732
|
+
volume_mode: Mode for handling volume data.
|
733
|
+
history_grouping: Grouping strategy for historical data.
|
734
|
+
date_to: The end date for metrics history.
|
735
|
+
country: Country filter for metrics.
|
736
|
+
protocol: Protocol filter for metrics.
|
737
|
+
mode: Mode for the request.
|
738
|
+
output: Format of the output.
|
739
|
+
|
740
|
+
Returns:
|
741
|
+
A dictionary containing historical metrics.
|
742
|
+
|
743
|
+
Raises:
|
744
|
+
ValueError: Raised if either 'date_from' or 'target' is missing.
|
745
|
+
|
746
|
+
Tags:
|
747
|
+
metrics, history, data-retrieval, api-call
|
748
|
+
"""
|
749
|
+
if date_from is None:
|
750
|
+
raise ValueError("Missing required parameter 'date_from'")
|
751
|
+
if target is None:
|
752
|
+
raise ValueError("Missing required parameter 'target'")
|
753
|
+
url = f"{self.base_url}/site-explorer/metrics-history"
|
754
|
+
query_params = {
|
755
|
+
k: v
|
756
|
+
for k, v in [
|
757
|
+
("select", select),
|
758
|
+
("volume_mode", volume_mode),
|
759
|
+
("history_grouping", history_grouping),
|
760
|
+
("date_to", date_to),
|
761
|
+
("date_from", date_from),
|
762
|
+
("country", country),
|
763
|
+
("protocol", protocol),
|
764
|
+
("target", target),
|
765
|
+
("mode", mode),
|
766
|
+
("output", output),
|
767
|
+
]
|
768
|
+
if v is not None
|
769
|
+
}
|
770
|
+
response = self._get(url, params=query_params)
|
771
|
+
response.raise_for_status()
|
772
|
+
return response.json()
|
773
|
+
|
774
|
+
def keywords_history(
|
775
|
+
self,
|
776
|
+
date_from,
|
777
|
+
target,
|
778
|
+
select=None,
|
779
|
+
history_grouping=None,
|
780
|
+
date_to=None,
|
781
|
+
country=None,
|
782
|
+
protocol=None,
|
783
|
+
mode=None,
|
784
|
+
output=None,
|
785
|
+
) -> dict[str, Any]:
|
786
|
+
"""
|
787
|
+
Fetches the historical keyword rankings and performance data for a specified target within an optional date range and set of filters.
|
788
|
+
|
789
|
+
Args:
|
790
|
+
date_from: str. The start date for the historical data query (required).
|
791
|
+
target: str. The target for which keyword history is retrieved, such as a domain or URL (required).
|
792
|
+
select: Optional[str]. Specifies which metrics or fields to return in the results.
|
793
|
+
history_grouping: Optional[str]. Determines how the historical data is grouped, e.g., by keyword or date.
|
794
|
+
date_to: Optional[str]. The end date for the historical data query.
|
795
|
+
country: Optional[str]. Country code for filtering results.
|
796
|
+
protocol: Optional[str]. Protocol (http or https) to filter the target.
|
797
|
+
mode: Optional[str]. Mode or type of data retrieval as supported by the API.
|
798
|
+
output: Optional[str]. Specifies output format or additional retrieval instructions.
|
799
|
+
|
800
|
+
Returns:
|
801
|
+
dict[str, Any]: Parsed JSON response containing historical keyword data for the specified target.
|
802
|
+
|
803
|
+
Raises:
|
804
|
+
ValueError: Raised if either 'date_from' or 'target' is missing.
|
805
|
+
requests.HTTPError: Raised if the HTTP request fails or the API responds with an error status.
|
806
|
+
|
807
|
+
Tags:
|
808
|
+
fetch, retrieve, keywords-history, seo, analytics, api
|
809
|
+
"""
|
810
|
+
if date_from is None:
|
811
|
+
raise ValueError("Missing required parameter 'date_from'")
|
812
|
+
if target is None:
|
813
|
+
raise ValueError("Missing required parameter 'target'")
|
814
|
+
url = f"{self.base_url}/site-explorer/keywords-history"
|
815
|
+
query_params = {
|
816
|
+
k: v
|
817
|
+
for k, v in [
|
818
|
+
("select", select),
|
819
|
+
("history_grouping", history_grouping),
|
820
|
+
("date_to", date_to),
|
821
|
+
("date_from", date_from),
|
822
|
+
("country", country),
|
823
|
+
("protocol", protocol),
|
824
|
+
("target", target),
|
825
|
+
("mode", mode),
|
826
|
+
("output", output),
|
827
|
+
]
|
828
|
+
if v is not None
|
829
|
+
}
|
830
|
+
response = self._get(url, params=query_params)
|
831
|
+
response.raise_for_status()
|
832
|
+
return response.json()
|
833
|
+
|
834
|
+
def metrics_by_country(
|
835
|
+
self,
|
836
|
+
target,
|
837
|
+
date,
|
838
|
+
volume_mode=None,
|
839
|
+
limit=None,
|
840
|
+
protocol=None,
|
841
|
+
mode=None,
|
842
|
+
output=None,
|
843
|
+
) -> dict[str, Any]:
|
844
|
+
"""
|
845
|
+
Fetches site metrics grouped by country for a specified target and date.
|
846
|
+
|
847
|
+
Args:
|
848
|
+
target: str. The target domain or URL for which to retrieve country-based metrics. Required.
|
849
|
+
date: str. The date for which metrics should be retrieved, in YYYY-MM-DD format. Required.
|
850
|
+
volume_mode: Optional[str]. Controls how volume is calculated or presented. Defaults to None.
|
851
|
+
limit: Optional[int]. The maximum number of country results to return. Defaults to None.
|
852
|
+
protocol: Optional[str]. The protocol filter for the target (e.g., 'http', 'https'). Defaults to None.
|
853
|
+
mode: Optional[str]. The operational mode for the metric query. Defaults to None.
|
854
|
+
output: Optional[str]. The output format or type. Defaults to None.
|
855
|
+
|
856
|
+
Returns:
|
857
|
+
dict[str, Any]: A dictionary containing metrics data grouped by country for the specified target and date.
|
858
|
+
|
859
|
+
Raises:
|
860
|
+
ValueError: If 'target' or 'date' is not provided.
|
861
|
+
requests.HTTPError: If the HTTP request to the metrics API endpoint fails.
|
862
|
+
|
863
|
+
Tags:
|
864
|
+
fetch, metrics, country, site-explorer, api
|
865
|
+
"""
|
866
|
+
if target is None:
|
867
|
+
raise ValueError("Missing required parameter 'target'")
|
868
|
+
if date is None:
|
869
|
+
raise ValueError("Missing required parameter 'date'")
|
870
|
+
url = f"{self.base_url}/site-explorer/metrics-by-country"
|
871
|
+
query_params = {
|
872
|
+
k: v
|
873
|
+
for k, v in [
|
874
|
+
("volume_mode", volume_mode),
|
875
|
+
("limit", limit),
|
876
|
+
("protocol", protocol),
|
877
|
+
("target", target),
|
878
|
+
("mode", mode),
|
879
|
+
("date", date),
|
880
|
+
("output", output),
|
881
|
+
]
|
882
|
+
if v is not None
|
883
|
+
}
|
884
|
+
response = self._get(url, params=query_params)
|
885
|
+
response.raise_for_status()
|
886
|
+
return response.json()
|
887
|
+
|
888
|
+
def pages_by_traffic(
|
889
|
+
self,
|
890
|
+
target,
|
891
|
+
volume_mode=None,
|
892
|
+
country=None,
|
893
|
+
protocol=None,
|
894
|
+
mode=None,
|
895
|
+
output=None,
|
896
|
+
) -> dict[str, Any]:
|
897
|
+
"""
|
898
|
+
Retrieves a list of top pages for a specified target domain or URL, ranked by estimated organic search traffic.
|
899
|
+
|
900
|
+
Args:
|
901
|
+
target: str. The domain or URL for which to retrieve top pages by estimated organic traffic. Required.
|
902
|
+
volume_mode: str, optional. The search volume calculation model to use (e.g., monthly average, rolling average).
|
903
|
+
country: str, optional. The country code to filter organic traffic data (e.g., 'US', 'GB').
|
904
|
+
protocol: str, optional. The protocol to filter results by ('http', 'https').
|
905
|
+
mode: str, optional. The mode of data retrieval or analysis, if applicable.
|
906
|
+
output: str, optional. The desired format of the response output.
|
907
|
+
|
908
|
+
Returns:
|
909
|
+
dict. The JSON-decoded response containing details about top pages driving traffic to the target.
|
910
|
+
|
911
|
+
Raises:
|
912
|
+
ValueError: If the required 'target' parameter is not provided.
|
913
|
+
requests.HTTPError: If the HTTP request is unsuccessful or the API returns an error response.
|
914
|
+
|
915
|
+
Tags:
|
916
|
+
list, traffic, pages, analytics, batch
|
917
|
+
"""
|
918
|
+
if target is None:
|
919
|
+
raise ValueError("Missing required parameter 'target'")
|
920
|
+
url = f"{self.base_url}/site-explorer/pages-by-traffic"
|
921
|
+
query_params = {
|
922
|
+
k: v
|
923
|
+
for k, v in [
|
924
|
+
("volume_mode", volume_mode),
|
925
|
+
("country", country),
|
926
|
+
("protocol", protocol),
|
927
|
+
("target", target),
|
928
|
+
("mode", mode),
|
929
|
+
("output", output),
|
930
|
+
]
|
931
|
+
if v is not None
|
932
|
+
}
|
933
|
+
response = self._get(url, params=query_params)
|
934
|
+
response.raise_for_status()
|
935
|
+
return response.json()
|
936
|
+
|
937
|
+
def all_backlinks(
|
938
|
+
self,
|
939
|
+
select,
|
940
|
+
target,
|
941
|
+
timeout=None,
|
942
|
+
offset=None,
|
943
|
+
limit=None,
|
944
|
+
order_by=None,
|
945
|
+
where=None,
|
946
|
+
protocol=None,
|
947
|
+
mode=None,
|
948
|
+
aggregation=None,
|
949
|
+
history=None,
|
950
|
+
output=None,
|
951
|
+
) -> dict[str, Any]:
|
952
|
+
"""
|
953
|
+
Retrieves all backlinks information for a specified target using various query parameters.
|
954
|
+
|
955
|
+
Args:
|
956
|
+
select: Required. Specifies the fields to select in the response.
|
957
|
+
target: Required. The target URL or domain to retrieve backlinks for.
|
958
|
+
timeout: Optional. Maximum time in seconds to wait for the response.
|
959
|
+
offset: Optional. Number of items to skip before starting to collect the result set.
|
960
|
+
limit: Optional. Maximum number of items to return in the result set.
|
961
|
+
order_by: Optional. Field(s) to sort the results by.
|
962
|
+
where: Optional. Filter condition for the results.
|
963
|
+
protocol: Optional. Protocol filter (e.g., http, https).
|
964
|
+
mode: Optional. Mode of operation for the backlinks search.
|
965
|
+
aggregation: Optional. Aggregation method for the results.
|
966
|
+
history: Optional. Whether to include historical data.
|
967
|
+
output: Optional. Format of the output data.
|
968
|
+
|
969
|
+
Returns:
|
970
|
+
A dictionary containing the backlinks data with various attributes based on the selected fields.
|
971
|
+
|
972
|
+
Raises:
|
973
|
+
ValueError: Raised when required parameters 'select' or 'target' are missing.
|
974
|
+
HTTPError: Raised when the API request fails.
|
975
|
+
|
976
|
+
Tags:
|
977
|
+
backlinks, retrieve, search, api, site-explorer, important
|
978
|
+
"""
|
979
|
+
if select is None:
|
980
|
+
raise ValueError("Missing required parameter 'select'")
|
981
|
+
if target is None:
|
982
|
+
raise ValueError("Missing required parameter 'target'")
|
983
|
+
url = f"{self.base_url}/site-explorer/all-backlinks"
|
984
|
+
query_params = {
|
985
|
+
k: v
|
986
|
+
for k, v in [
|
987
|
+
("timeout", timeout),
|
988
|
+
("offset", offset),
|
989
|
+
("limit", limit),
|
990
|
+
("order_by", order_by),
|
991
|
+
("where", where),
|
992
|
+
("select", select),
|
993
|
+
("protocol", protocol),
|
994
|
+
("target", target),
|
995
|
+
("mode", mode),
|
996
|
+
("aggregation", aggregation),
|
997
|
+
("history", history),
|
998
|
+
("output", output),
|
999
|
+
]
|
1000
|
+
if v is not None
|
1001
|
+
}
|
1002
|
+
response = self._get(url, params=query_params)
|
1003
|
+
response.raise_for_status()
|
1004
|
+
return response.json()
|
1005
|
+
|
1006
|
+
def broken_backlinks(
|
1007
|
+
self,
|
1008
|
+
select,
|
1009
|
+
target,
|
1010
|
+
timeout=None,
|
1011
|
+
offset=None,
|
1012
|
+
limit=None,
|
1013
|
+
order_by=None,
|
1014
|
+
where=None,
|
1015
|
+
protocol=None,
|
1016
|
+
mode=None,
|
1017
|
+
aggregation=None,
|
1018
|
+
output=None,
|
1019
|
+
) -> dict[str, Any]:
|
1020
|
+
"""
|
1021
|
+
Fetches broken backlink data for the specified target from the site explorer API endpoint.
|
1022
|
+
|
1023
|
+
Args:
|
1024
|
+
select: str. Required. Specifies the fields to include in the response.
|
1025
|
+
target: str. Required. The target domain or URL to analyze for broken backlinks.
|
1026
|
+
timeout: Optional[int]. Maximum time in seconds to wait for the response.
|
1027
|
+
offset: Optional[int]. Index of the first result to return (for pagination).
|
1028
|
+
limit: Optional[int]. Maximum number of results to return.
|
1029
|
+
order_by: Optional[str]. Field(s) to order the results by.
|
1030
|
+
where: Optional[str]. Filter expression for narrowing the result set.
|
1031
|
+
protocol: Optional[str]. Protocol filter (e.g., 'http', 'https').
|
1032
|
+
mode: Optional[str]. Exploration mode (e.g., 'domain', 'url').
|
1033
|
+
aggregation: Optional[str]. Aggregation method for results.
|
1034
|
+
output: Optional[str]. Output format specifier.
|
1035
|
+
|
1036
|
+
Returns:
|
1037
|
+
dict[str, Any]: Parsed JSON data containing details about broken backlinks for the specified target.
|
1038
|
+
|
1039
|
+
Raises:
|
1040
|
+
ValueError: If either 'select' or 'target' is not provided.
|
1041
|
+
requests.HTTPError: If the HTTP request to the API endpoint fails.
|
1042
|
+
|
1043
|
+
Tags:
|
1044
|
+
fetch, broken-backlinks, site-explorer, api
|
1045
|
+
"""
|
1046
|
+
if select is None:
|
1047
|
+
raise ValueError("Missing required parameter 'select'")
|
1048
|
+
if target is None:
|
1049
|
+
raise ValueError("Missing required parameter 'target'")
|
1050
|
+
url = f"{self.base_url}/site-explorer/broken-backlinks"
|
1051
|
+
query_params = {
|
1052
|
+
k: v
|
1053
|
+
for k, v in [
|
1054
|
+
("timeout", timeout),
|
1055
|
+
("offset", offset),
|
1056
|
+
("limit", limit),
|
1057
|
+
("order_by", order_by),
|
1058
|
+
("where", where),
|
1059
|
+
("select", select),
|
1060
|
+
("protocol", protocol),
|
1061
|
+
("target", target),
|
1062
|
+
("mode", mode),
|
1063
|
+
("aggregation", aggregation),
|
1064
|
+
("output", output),
|
1065
|
+
]
|
1066
|
+
if v is not None
|
1067
|
+
}
|
1068
|
+
response = self._get(url, params=query_params)
|
1069
|
+
response.raise_for_status()
|
1070
|
+
return response.json()
|
1071
|
+
|
1072
|
+
def refdomains(
|
1073
|
+
self,
|
1074
|
+
select,
|
1075
|
+
target,
|
1076
|
+
timeout=None,
|
1077
|
+
offset=None,
|
1078
|
+
limit=None,
|
1079
|
+
order_by=None,
|
1080
|
+
where=None,
|
1081
|
+
protocol=None,
|
1082
|
+
mode=None,
|
1083
|
+
history=None,
|
1084
|
+
output=None,
|
1085
|
+
) -> dict[str, Any]:
|
1086
|
+
"""
|
1087
|
+
Retrieves referring domains data for a specified target using the Site Explorer API endpoint.
|
1088
|
+
|
1089
|
+
Args:
|
1090
|
+
select: Fields to include in the response; required.
|
1091
|
+
target: Target domain, URL, or entity to analyze; required.
|
1092
|
+
timeout: Maximum request time in seconds (optional).
|
1093
|
+
offset: Number of items to skip for pagination (optional).
|
1094
|
+
limit: Maximum number of results to return (optional).
|
1095
|
+
order_by: Specifies field(s) and order to sort results by (optional).
|
1096
|
+
where: Filter conditions in a query-like format (optional).
|
1097
|
+
protocol: Protocol filter (e.g., 'http', 'https') (optional).
|
1098
|
+
mode: Analysis mode or data scope (optional).
|
1099
|
+
history: Include historical data if specified (optional).
|
1100
|
+
output: Format of the response output (optional).
|
1101
|
+
|
1102
|
+
Returns:
|
1103
|
+
Dictionary representing the JSON response from the referring domains API endpoint.
|
1104
|
+
|
1105
|
+
Raises:
|
1106
|
+
ValueError: Raised if 'select' or 'target' parameters are missing.
|
1107
|
+
requests.HTTPError: Raised if the HTTP response contained an unsuccessful status code.
|
1108
|
+
|
1109
|
+
Tags:
|
1110
|
+
refdomains, fetch, api, site-explorer, data-retrieval
|
1111
|
+
"""
|
1112
|
+
if select is None:
|
1113
|
+
raise ValueError("Missing required parameter 'select'")
|
1114
|
+
if target is None:
|
1115
|
+
raise ValueError("Missing required parameter 'target'")
|
1116
|
+
url = f"{self.base_url}/site-explorer/refdomains"
|
1117
|
+
query_params = {
|
1118
|
+
k: v
|
1119
|
+
for k, v in [
|
1120
|
+
("timeout", timeout),
|
1121
|
+
("offset", offset),
|
1122
|
+
("limit", limit),
|
1123
|
+
("order_by", order_by),
|
1124
|
+
("where", where),
|
1125
|
+
("select", select),
|
1126
|
+
("protocol", protocol),
|
1127
|
+
("target", target),
|
1128
|
+
("mode", mode),
|
1129
|
+
("history", history),
|
1130
|
+
("output", output),
|
1131
|
+
]
|
1132
|
+
if v is not None
|
1133
|
+
}
|
1134
|
+
response = self._get(url, params=query_params)
|
1135
|
+
response.raise_for_status()
|
1136
|
+
return response.json()
|
1137
|
+
|
1138
|
+
def anchors(
|
1139
|
+
self,
|
1140
|
+
select,
|
1141
|
+
target,
|
1142
|
+
timeout=None,
|
1143
|
+
offset=None,
|
1144
|
+
limit=None,
|
1145
|
+
order_by=None,
|
1146
|
+
where=None,
|
1147
|
+
protocol=None,
|
1148
|
+
mode=None,
|
1149
|
+
history=None,
|
1150
|
+
output=None,
|
1151
|
+
) -> dict[str, Any]:
|
1152
|
+
"""
|
1153
|
+
Fetches anchor text distribution data for a specified target using given query parameters.
|
1154
|
+
|
1155
|
+
Args:
|
1156
|
+
select: str or list. Columns or fields to include in the response. Required.
|
1157
|
+
target: str. The target URL, domain, or identifier from which to retrieve anchor data. Required.
|
1158
|
+
timeout: Optional[int]. Maximum time in seconds to wait for the API response.
|
1159
|
+
offset: Optional[int]. Offset for paginated results.
|
1160
|
+
limit: Optional[int]. Maximum number of records to return.
|
1161
|
+
order_by: Optional[str]. Sorting order of the results.
|
1162
|
+
where: Optional[str]. Filter conditions for the query.
|
1163
|
+
protocol: Optional[str]. Protocol filter (e.g., 'http', 'https').
|
1164
|
+
mode: Optional[str]. Query mode or method.
|
1165
|
+
history: Optional[str]. Historical range or filter.
|
1166
|
+
output: Optional[str]. Desired output format.
|
1167
|
+
|
1168
|
+
Returns:
|
1169
|
+
dict[str, Any]: Parsed JSON response containing anchor text distribution data.
|
1170
|
+
|
1171
|
+
Raises:
|
1172
|
+
ValueError: If the required 'select' or 'target' parameter is missing.
|
1173
|
+
requests.HTTPError: If the HTTP request to the API endpoint fails or returns an error status.
|
1174
|
+
|
1175
|
+
Tags:
|
1176
|
+
anchors, fetch, api, site-explorer, management
|
1177
|
+
"""
|
1178
|
+
if select is None:
|
1179
|
+
raise ValueError("Missing required parameter 'select'")
|
1180
|
+
if target is None:
|
1181
|
+
raise ValueError("Missing required parameter 'target'")
|
1182
|
+
url = f"{self.base_url}/site-explorer/anchors"
|
1183
|
+
query_params = {
|
1184
|
+
k: v
|
1185
|
+
for k, v in [
|
1186
|
+
("timeout", timeout),
|
1187
|
+
("offset", offset),
|
1188
|
+
("limit", limit),
|
1189
|
+
("order_by", order_by),
|
1190
|
+
("where", where),
|
1191
|
+
("select", select),
|
1192
|
+
("protocol", protocol),
|
1193
|
+
("target", target),
|
1194
|
+
("mode", mode),
|
1195
|
+
("history", history),
|
1196
|
+
("output", output),
|
1197
|
+
]
|
1198
|
+
if v is not None
|
1199
|
+
}
|
1200
|
+
response = self._get(url, params=query_params)
|
1201
|
+
response.raise_for_status()
|
1202
|
+
return response.json()
|
1203
|
+
|
1204
|
+
def linkeddomains(
|
1205
|
+
self,
|
1206
|
+
select,
|
1207
|
+
target,
|
1208
|
+
timeout=None,
|
1209
|
+
offset=None,
|
1210
|
+
limit=None,
|
1211
|
+
order_by=None,
|
1212
|
+
where=None,
|
1213
|
+
protocol=None,
|
1214
|
+
mode=None,
|
1215
|
+
output=None,
|
1216
|
+
) -> dict[str, Any]:
|
1217
|
+
"""
|
1218
|
+
Retrieves linked domains for a specified target using the site explorer API endpoint.
|
1219
|
+
|
1220
|
+
Args:
|
1221
|
+
select: str. Specifies the fields to select in the response. Required.
|
1222
|
+
target: str. The entity (such as a domain or URL) for which to retrieve linked domains. Required.
|
1223
|
+
timeout: Optional[int]. Maximum time in seconds to wait for the API response.
|
1224
|
+
offset: Optional[int]. Number of records to skip before starting to return results.
|
1225
|
+
limit: Optional[int]. Maximum number of records to return.
|
1226
|
+
order_by: Optional[str]. Field by which to order the returned results.
|
1227
|
+
where: Optional[str]. Filter to apply to the results.
|
1228
|
+
protocol: Optional[str]. Protocol (e.g., 'http' or 'https') to filter the results.
|
1229
|
+
mode: Optional[str]. Operation mode for the query.
|
1230
|
+
output: Optional[str]. Specifies the format or type of output.
|
1231
|
+
|
1232
|
+
Returns:
|
1233
|
+
dict[str, Any]: Parsed JSON response containing linked domains data for the given target.
|
1234
|
+
|
1235
|
+
Raises:
|
1236
|
+
ValueError: If either 'select' or 'target' is not provided.
|
1237
|
+
requests.exceptions.HTTPError: If the API request returns an unsuccessful status code.
|
1238
|
+
|
1239
|
+
Tags:
|
1240
|
+
fetch, site-explorer, linkeddomains, api, batch
|
1241
|
+
"""
|
1242
|
+
if select is None:
|
1243
|
+
raise ValueError("Missing required parameter 'select'")
|
1244
|
+
if target is None:
|
1245
|
+
raise ValueError("Missing required parameter 'target'")
|
1246
|
+
url = f"{self.base_url}/site-explorer/linkeddomains"
|
1247
|
+
query_params = {
|
1248
|
+
k: v
|
1249
|
+
for k, v in [
|
1250
|
+
("timeout", timeout),
|
1251
|
+
("offset", offset),
|
1252
|
+
("limit", limit),
|
1253
|
+
("order_by", order_by),
|
1254
|
+
("where", where),
|
1255
|
+
("select", select),
|
1256
|
+
("protocol", protocol),
|
1257
|
+
("target", target),
|
1258
|
+
("mode", mode),
|
1259
|
+
("output", output),
|
1260
|
+
]
|
1261
|
+
if v is not None
|
1262
|
+
}
|
1263
|
+
response = self._get(url, params=query_params)
|
1264
|
+
response.raise_for_status()
|
1265
|
+
return response.json()
|
1266
|
+
|
1267
|
+
def linked_anchors_external(
|
1268
|
+
self,
|
1269
|
+
select,
|
1270
|
+
target,
|
1271
|
+
timeout=None,
|
1272
|
+
offset=None,
|
1273
|
+
limit=None,
|
1274
|
+
order_by=None,
|
1275
|
+
where=None,
|
1276
|
+
protocol=None,
|
1277
|
+
mode=None,
|
1278
|
+
output=None,
|
1279
|
+
) -> dict[str, Any]:
|
1280
|
+
"""
|
1281
|
+
Fetch linked external anchor data for a specified target using provided selection and filtering criteria.
|
1282
|
+
|
1283
|
+
Args:
|
1284
|
+
select: str. Specifies which fields to select in the result; required.
|
1285
|
+
target: str. The target entity (e.g., domain, URL) for which to fetch external anchor data; required.
|
1286
|
+
timeout: Optional[int]. Timeout for the request in seconds.
|
1287
|
+
offset: Optional[int]. Number of records to skip before starting to return results.
|
1288
|
+
limit: Optional[int]. Maximum number of records to return.
|
1289
|
+
order_by: Optional[str]. Field(s) to order results by.
|
1290
|
+
where: Optional[str]. Additional query/filter constraints in string format.
|
1291
|
+
protocol: Optional[str]. Protocol to use for fetching data, such as 'http' or 'https'.
|
1292
|
+
mode: Optional[str]. Mode of operation for the request.
|
1293
|
+
output: Optional[str]. Desired data output format.
|
1294
|
+
|
1295
|
+
Returns:
|
1296
|
+
dict[str, Any]: A dictionary containing the linked external anchor data matching the specified criteria.
|
1297
|
+
|
1298
|
+
Raises:
|
1299
|
+
ValueError: Raised if the required parameters 'select' or 'target' are not provided.
|
1300
|
+
requests.HTTPError: Raised if the HTTP request fails or returns an error response status.
|
1301
|
+
|
1302
|
+
Tags:
|
1303
|
+
fetch, list, anchors, external, site-explorer, api
|
1304
|
+
"""
|
1305
|
+
if select is None:
|
1306
|
+
raise ValueError("Missing required parameter 'select'")
|
1307
|
+
if target is None:
|
1308
|
+
raise ValueError("Missing required parameter 'target'")
|
1309
|
+
url = f"{self.base_url}/site-explorer/linked-anchors-external"
|
1310
|
+
query_params = {
|
1311
|
+
k: v
|
1312
|
+
for k, v in [
|
1313
|
+
("timeout", timeout),
|
1314
|
+
("offset", offset),
|
1315
|
+
("limit", limit),
|
1316
|
+
("order_by", order_by),
|
1317
|
+
("where", where),
|
1318
|
+
("select", select),
|
1319
|
+
("protocol", protocol),
|
1320
|
+
("target", target),
|
1321
|
+
("mode", mode),
|
1322
|
+
("output", output),
|
1323
|
+
]
|
1324
|
+
if v is not None
|
1325
|
+
}
|
1326
|
+
response = self._get(url, params=query_params)
|
1327
|
+
response.raise_for_status()
|
1328
|
+
return response.json()
|
1329
|
+
|
1330
|
+
def linked_anchors_internal(
|
1331
|
+
self,
|
1332
|
+
select,
|
1333
|
+
target,
|
1334
|
+
timeout=None,
|
1335
|
+
offset=None,
|
1336
|
+
limit=None,
|
1337
|
+
order_by=None,
|
1338
|
+
where=None,
|
1339
|
+
protocol=None,
|
1340
|
+
mode=None,
|
1341
|
+
output=None,
|
1342
|
+
) -> dict[str, Any]:
|
1343
|
+
"""
|
1344
|
+
Fetches internal linked anchor data for a specified target from the site explorer API, applying optional filtering and query parameters.
|
1345
|
+
|
1346
|
+
Args:
|
1347
|
+
select: List or string specifying which fields to retrieve from the results. Required.
|
1348
|
+
target: String indicating the target URL, domain, or identifier for which internal linked anchor data is requested. Required.
|
1349
|
+
timeout: Optional integer or float specifying the request timeout duration, in seconds.
|
1350
|
+
offset: Optional integer specifying the number of records to skip before starting to return results.
|
1351
|
+
limit: Optional integer specifying the maximum number of records to return.
|
1352
|
+
order_by: Optional string or list specifying the field(s) by which to sort the results.
|
1353
|
+
where: Optional string providing additional filter conditions for the query.
|
1354
|
+
protocol: Optional string to specify the protocol (e.g., 'http', 'https') to use in filtering.
|
1355
|
+
mode: Optional string indicating the exploration mode or data granularity.
|
1356
|
+
output: Optional string specifying the output format or data structure.
|
1357
|
+
|
1358
|
+
Returns:
|
1359
|
+
A dictionary containing the response data for internal linked anchors matching the specified criteria.
|
1360
|
+
|
1361
|
+
Raises:
|
1362
|
+
ValueError: Raised if the required 'select' or 'target' parameters are missing.
|
1363
|
+
requests.HTTPError: Raised if the HTTP request to the API fails or returns an error status.
|
1364
|
+
|
1365
|
+
Tags:
|
1366
|
+
site-explorer, linked-anchors, fetch, api, internal-links, management
|
1367
|
+
"""
|
1368
|
+
if select is None:
|
1369
|
+
raise ValueError("Missing required parameter 'select'")
|
1370
|
+
if target is None:
|
1371
|
+
raise ValueError("Missing required parameter 'target'")
|
1372
|
+
url = f"{self.base_url}/site-explorer/linked-anchors-internal"
|
1373
|
+
query_params = {
|
1374
|
+
k: v
|
1375
|
+
for k, v in [
|
1376
|
+
("timeout", timeout),
|
1377
|
+
("offset", offset),
|
1378
|
+
("limit", limit),
|
1379
|
+
("order_by", order_by),
|
1380
|
+
("where", where),
|
1381
|
+
("select", select),
|
1382
|
+
("protocol", protocol),
|
1383
|
+
("target", target),
|
1384
|
+
("mode", mode),
|
1385
|
+
("output", output),
|
1386
|
+
]
|
1387
|
+
if v is not None
|
1388
|
+
}
|
1389
|
+
response = self._get(url, params=query_params)
|
1390
|
+
response.raise_for_status()
|
1391
|
+
return response.json()
|
1392
|
+
|
1393
|
+
def organic_keywords(
|
1394
|
+
self,
|
1395
|
+
select,
|
1396
|
+
target,
|
1397
|
+
country,
|
1398
|
+
date,
|
1399
|
+
timeout=None,
|
1400
|
+
offset=None,
|
1401
|
+
limit=None,
|
1402
|
+
order_by=None,
|
1403
|
+
where=None,
|
1404
|
+
protocol=None,
|
1405
|
+
mode=None,
|
1406
|
+
date_compared=None,
|
1407
|
+
volume_mode=None,
|
1408
|
+
output=None,
|
1409
|
+
) -> dict[str, Any]:
|
1410
|
+
"""
|
1411
|
+
Retrieve organic keyword data for a specified target and date from the Site Explorer API endpoint.
|
1412
|
+
|
1413
|
+
Args:
|
1414
|
+
select: str. Comma-separated fields to include in the response. Required.
|
1415
|
+
target: str. The domain, URL, or path to retrieve keyword data for. Required.
|
1416
|
+
country: str. Country code specifying the regional database. Required.
|
1417
|
+
date: str. The date for which to fetch keyword data, in YYYY-MM-DD format. Required.
|
1418
|
+
timeout: int, optional. Request timeout in seconds.
|
1419
|
+
offset: int, optional. Number of items to skip before starting to collect the result set.
|
1420
|
+
limit: int, optional. Maximum number of results to return.
|
1421
|
+
order_by: str, optional. Field(s) to order results by.
|
1422
|
+
where: str, optional. Filter condition(s) for the query.
|
1423
|
+
protocol: str, optional. Protocol to filter by (e.g., 'http', 'https').
|
1424
|
+
mode: str, optional. SERP mode (e.g., 'domain', 'subdomain').
|
1425
|
+
date_compared: str, optional. A second date for comparison, in YYYY-MM-DD format.
|
1426
|
+
volume_mode: str, optional. Keyword search volume calculation mode.
|
1427
|
+
output: str, optional. Output format (e.g., 'json').
|
1428
|
+
|
1429
|
+
Returns:
|
1430
|
+
dict[str, Any]: Parsed JSON response containing organic keyword data.
|
1431
|
+
|
1432
|
+
Raises:
|
1433
|
+
ValueError: Raised when the required parameters 'select', 'target', 'country', or 'date' are missing.
|
1434
|
+
requests.HTTPError: Raised if the API request fails with an HTTP error status.
|
1435
|
+
|
1436
|
+
Tags:
|
1437
|
+
fetch, keywords, organic, site-explorer, batch , api
|
1438
|
+
"""
|
1439
|
+
if select is None:
|
1440
|
+
raise ValueError("Missing required parameter 'select'")
|
1441
|
+
if target is None:
|
1442
|
+
raise ValueError("Missing required parameter 'target'")
|
1443
|
+
if country is None:
|
1444
|
+
raise ValueError("Missing required parameter 'country'")
|
1445
|
+
if date is None:
|
1446
|
+
raise ValueError("Missing required parameter 'date'")
|
1447
|
+
url = f"{self.base_url}/site-explorer/organic-keywords"
|
1448
|
+
query_params = {
|
1449
|
+
k: v
|
1450
|
+
for k, v in [
|
1451
|
+
("timeout", timeout),
|
1452
|
+
("offset", offset),
|
1453
|
+
("limit", limit),
|
1454
|
+
("order_by", order_by),
|
1455
|
+
("where", where),
|
1456
|
+
("select", select),
|
1457
|
+
("protocol", protocol),
|
1458
|
+
("target", target),
|
1459
|
+
("mode", mode),
|
1460
|
+
("country", country),
|
1461
|
+
("date_compared", date_compared),
|
1462
|
+
("date", date),
|
1463
|
+
("volume_mode", volume_mode),
|
1464
|
+
("output", output),
|
1465
|
+
]
|
1466
|
+
if v is not None
|
1467
|
+
}
|
1468
|
+
response = self._get(url, params=query_params)
|
1469
|
+
response.raise_for_status()
|
1470
|
+
return response.json()
|
1471
|
+
|
1472
|
+
def organic_competitors(
|
1473
|
+
self,
|
1474
|
+
select,
|
1475
|
+
target,
|
1476
|
+
country,
|
1477
|
+
date,
|
1478
|
+
timeout=None,
|
1479
|
+
offset=None,
|
1480
|
+
limit=None,
|
1481
|
+
order_by=None,
|
1482
|
+
where=None,
|
1483
|
+
protocol=None,
|
1484
|
+
mode=None,
|
1485
|
+
date_compared=None,
|
1486
|
+
volume_mode=None,
|
1487
|
+
output=None,
|
1488
|
+
) -> dict[str, Any]:
|
1489
|
+
"""
|
1490
|
+
Retrieves organic competitors data for a specified target using the Site Explorer API.
|
1491
|
+
|
1492
|
+
Args:
|
1493
|
+
select: list[str]. The fields to be returned in the response. Required.
|
1494
|
+
target: str. The target domain, URL, or resource to analyze. Required.
|
1495
|
+
country: str. The country or region code for the data. Required.
|
1496
|
+
date: str. The date for which to retrieve competitor data, in the expected format (e.g., 'YYYY-MM-DD'). Required.
|
1497
|
+
timeout: Optional[int]. The maximum time in seconds to wait for the response.
|
1498
|
+
offset: Optional[int]. The starting point within the collection of returned results.
|
1499
|
+
limit: Optional[int]. The maximum number of records to return.
|
1500
|
+
order_by: Optional[str]. The sorting order for the results.
|
1501
|
+
where: Optional[str]. Additional filtering to apply to the query.
|
1502
|
+
protocol: Optional[str]. The protocol to use (e.g., 'http', 'https').
|
1503
|
+
mode: Optional[str]. The mode for the data retrieval.
|
1504
|
+
date_compared: Optional[str]. A comparison date for historical data analysis.
|
1505
|
+
volume_mode: Optional[str]. The volume calculation mode.
|
1506
|
+
output: Optional[str]. The desired output format (e.g., 'json').
|
1507
|
+
|
1508
|
+
Returns:
|
1509
|
+
dict[str, Any]: The JSON response from the API as a dictionary containing organic competitors data.
|
1510
|
+
|
1511
|
+
Raises:
|
1512
|
+
ValueError: If any of the required parameters ('select', 'target', 'country', or 'date') are missing.
|
1513
|
+
requests.HTTPError: If the HTTP request to the Site Explorer API fails or an error status code is returned.
|
1514
|
+
|
1515
|
+
Tags:
|
1516
|
+
fetch, organic-competitors, site-explorer, api, data-retrieva, important
|
1517
|
+
"""
|
1518
|
+
if select is None:
|
1519
|
+
raise ValueError("Missing required parameter 'select'")
|
1520
|
+
if target is None:
|
1521
|
+
raise ValueError("Missing required parameter 'target'")
|
1522
|
+
if country is None:
|
1523
|
+
raise ValueError("Missing required parameter 'country'")
|
1524
|
+
if date is None:
|
1525
|
+
raise ValueError("Missing required parameter 'date'")
|
1526
|
+
url = f"{self.base_url}/site-explorer/organic-competitors"
|
1527
|
+
query_params = {
|
1528
|
+
k: v
|
1529
|
+
for k, v in [
|
1530
|
+
("timeout", timeout),
|
1531
|
+
("offset", offset),
|
1532
|
+
("limit", limit),
|
1533
|
+
("order_by", order_by),
|
1534
|
+
("where", where),
|
1535
|
+
("select", select),
|
1536
|
+
("protocol", protocol),
|
1537
|
+
("target", target),
|
1538
|
+
("mode", mode),
|
1539
|
+
("country", country),
|
1540
|
+
("date_compared", date_compared),
|
1541
|
+
("date", date),
|
1542
|
+
("volume_mode", volume_mode),
|
1543
|
+
("output", output),
|
1544
|
+
]
|
1545
|
+
if v is not None
|
1546
|
+
}
|
1547
|
+
response = self._get(url, params=query_params)
|
1548
|
+
response.raise_for_status()
|
1549
|
+
return response.json()
|
1550
|
+
|
1551
|
+
def top_pages(
|
1552
|
+
self,
|
1553
|
+
select,
|
1554
|
+
target,
|
1555
|
+
date,
|
1556
|
+
timeout=None,
|
1557
|
+
offset=None,
|
1558
|
+
limit=None,
|
1559
|
+
order_by=None,
|
1560
|
+
where=None,
|
1561
|
+
protocol=None,
|
1562
|
+
mode=None,
|
1563
|
+
country=None,
|
1564
|
+
date_compared=None,
|
1565
|
+
volume_mode=None,
|
1566
|
+
output=None,
|
1567
|
+
) -> dict[str, Any]:
|
1568
|
+
"""
|
1569
|
+
Retrieves top pages data for a specified target and date from the site explorer API with customizable query parameters.
|
1570
|
+
|
1571
|
+
Args:
|
1572
|
+
select: Fields to include in the output. Must be specified.
|
1573
|
+
target: The target domain, URL, or resource to analyze. Must be specified.
|
1574
|
+
date: The date for which to retrieve top page data. Must be specified.
|
1575
|
+
timeout: Optional request timeout (in seconds).
|
1576
|
+
offset: Optional index of the first result to return, for pagination.
|
1577
|
+
limit: Optional maximum number of results to return.
|
1578
|
+
order_by: Optional sorting instructions for results.
|
1579
|
+
where: Optional filter conditions to apply to the results.
|
1580
|
+
protocol: Optional protocol filter (e.g., 'http', 'https').
|
1581
|
+
mode: Optional mode or metric for the analysis.
|
1582
|
+
country: Optional country code to filter results by geography.
|
1583
|
+
date_compared: Optional comparison date for comparative metrics.
|
1584
|
+
volume_mode: Optional volume mode or granularity.
|
1585
|
+
output: Optional output format for the API response.
|
1586
|
+
|
1587
|
+
Returns:
|
1588
|
+
A dictionary containing the top pages data retrieved from the API for the specified parameters.
|
1589
|
+
|
1590
|
+
Raises:
|
1591
|
+
ValueError: If 'select', 'target', or 'date' is not provided.
|
1592
|
+
requests.HTTPError: If the API request returns an unsuccessful HTTP status code.
|
1593
|
+
|
1594
|
+
Tags:
|
1595
|
+
fetch, top-pages, site-explorer, api, management
|
1596
|
+
"""
|
1597
|
+
if select is None:
|
1598
|
+
raise ValueError("Missing required parameter 'select'")
|
1599
|
+
if target is None:
|
1600
|
+
raise ValueError("Missing required parameter 'target'")
|
1601
|
+
if date is None:
|
1602
|
+
raise ValueError("Missing required parameter 'date'")
|
1603
|
+
url = f"{self.base_url}/site-explorer/top-pages"
|
1604
|
+
query_params = {
|
1605
|
+
k: v
|
1606
|
+
for k, v in [
|
1607
|
+
("timeout", timeout),
|
1608
|
+
("offset", offset),
|
1609
|
+
("limit", limit),
|
1610
|
+
("order_by", order_by),
|
1611
|
+
("where", where),
|
1612
|
+
("select", select),
|
1613
|
+
("protocol", protocol),
|
1614
|
+
("target", target),
|
1615
|
+
("mode", mode),
|
1616
|
+
("country", country),
|
1617
|
+
("date_compared", date_compared),
|
1618
|
+
("date", date),
|
1619
|
+
("volume_mode", volume_mode),
|
1620
|
+
("output", output),
|
1621
|
+
]
|
1622
|
+
if v is not None
|
1623
|
+
}
|
1624
|
+
response = self._get(url, params=query_params)
|
1625
|
+
response.raise_for_status()
|
1626
|
+
return response.json()
|
1627
|
+
|
1628
|
+
def paid_pages(
|
1629
|
+
self,
|
1630
|
+
select,
|
1631
|
+
target,
|
1632
|
+
date,
|
1633
|
+
timeout=None,
|
1634
|
+
offset=None,
|
1635
|
+
limit=None,
|
1636
|
+
order_by=None,
|
1637
|
+
where=None,
|
1638
|
+
protocol=None,
|
1639
|
+
mode=None,
|
1640
|
+
country=None,
|
1641
|
+
date_compared=None,
|
1642
|
+
volume_mode=None,
|
1643
|
+
output=None,
|
1644
|
+
) -> dict[str, Any]:
|
1645
|
+
"""
|
1646
|
+
Fetches paid pages data from the Site Explorer API based on specified filters.
|
1647
|
+
|
1648
|
+
Args:
|
1649
|
+
select: str. The fields to retrieve in the response. Required.
|
1650
|
+
target: str. The target domain, URL, or entity for which paid pages data is requested. Required.
|
1651
|
+
date: str. The reference date for the data. Required.
|
1652
|
+
timeout: Optional[int]. The request timeout in seconds.
|
1653
|
+
offset: Optional[int]. The number of items to skip before starting to collect the result set.
|
1654
|
+
limit: Optional[int]. Maximum number of records to retrieve.
|
1655
|
+
order_by: Optional[str]. Sorting order for the result set.
|
1656
|
+
where: Optional[str]. Filtering conditions for the results.
|
1657
|
+
protocol: Optional[str]. Protocol filter (e.g., 'http' or 'https').
|
1658
|
+
mode: Optional[str]. The exploration mode or analysis type.
|
1659
|
+
country: Optional[str]. Country code for regional data filtering.
|
1660
|
+
date_compared: Optional[str]. Secondary date for comparison analysis.
|
1661
|
+
volume_mode: Optional[str]. Mode used for volume calculations.
|
1662
|
+
output: Optional[str]. Desired response format (e.g., 'json').
|
1663
|
+
|
1664
|
+
Returns:
|
1665
|
+
dict[str, Any]: JSON response containing paid pages data matching the provided filters.
|
1666
|
+
|
1667
|
+
Raises:
|
1668
|
+
ValueError: If any of the required parameters ('select', 'target', or 'date') are missing.
|
1669
|
+
requests.HTTPError: If the HTTP request to the API fails or returns an error status code.
|
1670
|
+
|
1671
|
+
Tags:
|
1672
|
+
fetch, paid-pages, site-explorer, api, data-retrieval
|
1673
|
+
"""
|
1674
|
+
if select is None:
|
1675
|
+
raise ValueError("Missing required parameter 'select'")
|
1676
|
+
if target is None:
|
1677
|
+
raise ValueError("Missing required parameter 'target'")
|
1678
|
+
if date is None:
|
1679
|
+
raise ValueError("Missing required parameter 'date'")
|
1680
|
+
url = f"{self.base_url}/site-explorer/paid-pages"
|
1681
|
+
query_params = {
|
1682
|
+
k: v
|
1683
|
+
for k, v in [
|
1684
|
+
("timeout", timeout),
|
1685
|
+
("offset", offset),
|
1686
|
+
("limit", limit),
|
1687
|
+
("order_by", order_by),
|
1688
|
+
("where", where),
|
1689
|
+
("select", select),
|
1690
|
+
("protocol", protocol),
|
1691
|
+
("target", target),
|
1692
|
+
("mode", mode),
|
1693
|
+
("country", country),
|
1694
|
+
("date_compared", date_compared),
|
1695
|
+
("date", date),
|
1696
|
+
("volume_mode", volume_mode),
|
1697
|
+
("output", output),
|
1698
|
+
]
|
1699
|
+
if v is not None
|
1700
|
+
}
|
1701
|
+
response = self._get(url, params=query_params)
|
1702
|
+
response.raise_for_status()
|
1703
|
+
return response.json()
|
1704
|
+
|
1705
|
+
def best_by_external_links(
|
1706
|
+
self,
|
1707
|
+
select,
|
1708
|
+
target,
|
1709
|
+
timeout=None,
|
1710
|
+
offset=None,
|
1711
|
+
limit=None,
|
1712
|
+
order_by=None,
|
1713
|
+
where=None,
|
1714
|
+
protocol=None,
|
1715
|
+
mode=None,
|
1716
|
+
history=None,
|
1717
|
+
output=None,
|
1718
|
+
) -> dict[str, Any]:
|
1719
|
+
"""
|
1720
|
+
Fetches data about the best-performing pages of a target site based on external links, with various filtering and output options.
|
1721
|
+
|
1722
|
+
Args:
|
1723
|
+
select: str. Comma-separated list of fields to include in the response. Required.
|
1724
|
+
target: str. The target domain or URL to analyze. Required.
|
1725
|
+
timeout: Optional[int]. Maximum time in seconds to wait for the response.
|
1726
|
+
offset: Optional[int]. Number of items to skip before starting to collect the result set.
|
1727
|
+
limit: Optional[int]. Maximum number of results to return.
|
1728
|
+
order_by: Optional[str]. Field(s) to sort results by.
|
1729
|
+
where: Optional[str]. Filtering conditions to apply to the results.
|
1730
|
+
protocol: Optional[str]. Protocol to use (e.g., http, https) when target is a domain.
|
1731
|
+
mode: Optional[str]. Mode of analysis (if applicable).
|
1732
|
+
history: Optional[str]. Whether to include historical data.
|
1733
|
+
output: Optional[str]. Desired output format (e.g., json, csv).
|
1734
|
+
|
1735
|
+
Returns:
|
1736
|
+
dict[str, Any]: JSON response containing details about the best-by-external-links pages for the target.
|
1737
|
+
|
1738
|
+
Raises:
|
1739
|
+
ValueError: Raised if 'select' or 'target' parameters are missing.
|
1740
|
+
requests.HTTPError: Raised if the HTTP request to the external service fails.
|
1741
|
+
|
1742
|
+
Tags:
|
1743
|
+
fetch, list, site-explorer, external-links, api
|
1744
|
+
"""
|
1745
|
+
if select is None:
|
1746
|
+
raise ValueError("Missing required parameter 'select'")
|
1747
|
+
if target is None:
|
1748
|
+
raise ValueError("Missing required parameter 'target'")
|
1749
|
+
url = f"{self.base_url}/site-explorer/best-by-external-links"
|
1750
|
+
query_params = {
|
1751
|
+
k: v
|
1752
|
+
for k, v in [
|
1753
|
+
("timeout", timeout),
|
1754
|
+
("offset", offset),
|
1755
|
+
("limit", limit),
|
1756
|
+
("order_by", order_by),
|
1757
|
+
("where", where),
|
1758
|
+
("select", select),
|
1759
|
+
("protocol", protocol),
|
1760
|
+
("target", target),
|
1761
|
+
("mode", mode),
|
1762
|
+
("history", history),
|
1763
|
+
("output", output),
|
1764
|
+
]
|
1765
|
+
if v is not None
|
1766
|
+
}
|
1767
|
+
response = self._get(url, params=query_params)
|
1768
|
+
response.raise_for_status()
|
1769
|
+
return response.json()
|
1770
|
+
|
1771
|
+
def best_by_internal_links(
|
1772
|
+
self,
|
1773
|
+
select,
|
1774
|
+
target,
|
1775
|
+
timeout=None,
|
1776
|
+
offset=None,
|
1777
|
+
limit=None,
|
1778
|
+
order_by=None,
|
1779
|
+
where=None,
|
1780
|
+
protocol=None,
|
1781
|
+
mode=None,
|
1782
|
+
output=None,
|
1783
|
+
) -> dict[str, Any]:
|
1784
|
+
"""
|
1785
|
+
Retrieves the best-performing internal links for a specified target using the site explorer API endpoint.
|
1786
|
+
|
1787
|
+
Args:
|
1788
|
+
select: str. Comma-separated list of fields to include in the response. Required.
|
1789
|
+
target: str. The URL, domain, or path to analyze. Required.
|
1790
|
+
timeout: Optional[int]. Maximum time to wait for the API response, in seconds.
|
1791
|
+
offset: Optional[int]. Offset for paginated results.
|
1792
|
+
limit: Optional[int]. Maximum number of results to return.
|
1793
|
+
order_by: Optional[str]. Field by which to order the results.
|
1794
|
+
where: Optional[str]. Conditions to filter the results.
|
1795
|
+
protocol: Optional[str]. Protocol to use (e.g., 'http', 'https').
|
1796
|
+
mode: Optional[str]. Operational mode for the API request.
|
1797
|
+
output: Optional[str]. Desired response format (e.g., 'json').
|
1798
|
+
|
1799
|
+
Returns:
|
1800
|
+
dict[str, Any]: The JSON response from the API containing details about the best internal links for the specified target.
|
1801
|
+
|
1802
|
+
Raises:
|
1803
|
+
ValueError: If either 'select' or 'target' parameters are not provided.
|
1804
|
+
requests.HTTPError: If the API response contains an HTTP error status code.
|
1805
|
+
|
1806
|
+
Tags:
|
1807
|
+
fetch, internal-links, site-explorer, api
|
1808
|
+
"""
|
1809
|
+
if select is None:
|
1810
|
+
raise ValueError("Missing required parameter 'select'")
|
1811
|
+
if target is None:
|
1812
|
+
raise ValueError("Missing required parameter 'target'")
|
1813
|
+
url = f"{self.base_url}/site-explorer/best-by-internal-links"
|
1814
|
+
query_params = {
|
1815
|
+
k: v
|
1816
|
+
for k, v in [
|
1817
|
+
("timeout", timeout),
|
1818
|
+
("offset", offset),
|
1819
|
+
("limit", limit),
|
1820
|
+
("order_by", order_by),
|
1821
|
+
("where", where),
|
1822
|
+
("select", select),
|
1823
|
+
("protocol", protocol),
|
1824
|
+
("target", target),
|
1825
|
+
("mode", mode),
|
1826
|
+
("output", output),
|
1827
|
+
]
|
1828
|
+
if v is not None
|
1829
|
+
}
|
1830
|
+
response = self._get(url, params=query_params)
|
1831
|
+
response.raise_for_status()
|
1832
|
+
return response.json()
|
1833
|
+
|
1834
|
+
def total_search_volume_history(
|
1835
|
+
self,
|
1836
|
+
date_from,
|
1837
|
+
target,
|
1838
|
+
volume_mode=None,
|
1839
|
+
top_positions=None,
|
1840
|
+
history_grouping=None,
|
1841
|
+
date_to=None,
|
1842
|
+
country=None,
|
1843
|
+
protocol=None,
|
1844
|
+
mode=None,
|
1845
|
+
output=None,
|
1846
|
+
) -> dict[str, Any]:
|
1847
|
+
"""
|
1848
|
+
Fetches the total historical search volume data for a specified target within a given date range and optional filters.
|
1849
|
+
|
1850
|
+
Args:
|
1851
|
+
date_from: str. Start date for the search volume history (required).
|
1852
|
+
target: str. The target entity to retrieve data for, such as a domain or URL (required).
|
1853
|
+
volume_mode: Optional[str]. Specifies the search volume calculation mode.
|
1854
|
+
top_positions: Optional[int]. Limits results to a specific range of top search positions.
|
1855
|
+
history_grouping: Optional[str]. Determines how history data is grouped (e.g., daily, weekly, monthly).
|
1856
|
+
date_to: Optional[str]. End date for the search volume history.
|
1857
|
+
country: Optional[str]. Country code for filtering the data.
|
1858
|
+
protocol: Optional[str]. Protocol to use for the target (e.g., 'http', 'https').
|
1859
|
+
mode: Optional[str]. API mode or additional operation mode parameter.
|
1860
|
+
output: Optional[str]. Desired output format (e.g., 'json').
|
1861
|
+
|
1862
|
+
Returns:
|
1863
|
+
dict[str, Any]: A dictionary containing the requested search volume history data.
|
1864
|
+
|
1865
|
+
Raises:
|
1866
|
+
ValueError: Raised if either 'date_from' or 'target' is not provided.
|
1867
|
+
requests.HTTPError: Raised if the HTTP request to the API fails (non-2xx response).
|
1868
|
+
|
1869
|
+
Tags:
|
1870
|
+
fetch, search-volume, history, api, report
|
1871
|
+
"""
|
1872
|
+
if date_from is None:
|
1873
|
+
raise ValueError("Missing required parameter 'date_from'")
|
1874
|
+
if target is None:
|
1875
|
+
raise ValueError("Missing required parameter 'target'")
|
1876
|
+
url = f"{self.base_url}/site-explorer/total-search-volume-history"
|
1877
|
+
query_params = {
|
1878
|
+
k: v
|
1879
|
+
for k, v in [
|
1880
|
+
("volume_mode", volume_mode),
|
1881
|
+
("top_positions", top_positions),
|
1882
|
+
("history_grouping", history_grouping),
|
1883
|
+
("date_to", date_to),
|
1884
|
+
("date_from", date_from),
|
1885
|
+
("country", country),
|
1886
|
+
("protocol", protocol),
|
1887
|
+
("target", target),
|
1888
|
+
("mode", mode),
|
1889
|
+
("output", output),
|
1890
|
+
]
|
1891
|
+
if v is not None
|
1892
|
+
}
|
1893
|
+
response = self._get(url, params=query_params)
|
1894
|
+
response.raise_for_status()
|
1895
|
+
return response.json()
|
1896
|
+
|
1897
|
+
def keyword_explorer_overview(
|
1898
|
+
self,
|
1899
|
+
select,
|
1900
|
+
country,
|
1901
|
+
timeout=None,
|
1902
|
+
offset=None,
|
1903
|
+
limit=None,
|
1904
|
+
order_by=None,
|
1905
|
+
where=None,
|
1906
|
+
target_mode=None,
|
1907
|
+
target=None,
|
1908
|
+
target_position=None,
|
1909
|
+
search_engine=None,
|
1910
|
+
keywords=None,
|
1911
|
+
keyword_list_id=None,
|
1912
|
+
output=None,
|
1913
|
+
) -> dict[str, Any]:
|
1914
|
+
"""
|
1915
|
+
Retrieves an overview of keyword metrics and data from the keywords explorer API endpoint based on the specified filters and parameters.
|
1916
|
+
|
1917
|
+
Args:
|
1918
|
+
select: Fields to retrieve in the response (required).
|
1919
|
+
country: Country code or name for which keyword data is requested (required).
|
1920
|
+
timeout: Maximum time in seconds to wait for the response (optional).
|
1921
|
+
offset: Number of items to skip before starting to collect the result set (optional).
|
1922
|
+
limit: Maximum number of items to return in the response (optional).
|
1923
|
+
order_by: Field(s) to order the results by (optional).
|
1924
|
+
where: Additional filtering criteria for querying keywords (optional).
|
1925
|
+
target_mode: Specifies the targeting mode for analysis (optional).
|
1926
|
+
target: Target entity for the keyword analysis, such as a domain or URL (optional).
|
1927
|
+
target_position: Position or ranking target for the keyword analysis (optional).
|
1928
|
+
search_engine: Search engine specification for the query (optional).
|
1929
|
+
keywords: List of keywords or a single keyword to analyze (optional).
|
1930
|
+
keyword_list_id: ID of a saved keyword list to use for the query (optional).
|
1931
|
+
output: Desired format or structure of the output data (optional).
|
1932
|
+
|
1933
|
+
Returns:
|
1934
|
+
A dictionary containing keyword overview metrics and related data from the API response.
|
1935
|
+
|
1936
|
+
Raises:
|
1937
|
+
ValueError: Raised if the required parameter 'select' or 'country' is missing.
|
1938
|
+
requests.HTTPError: Raised if the HTTP request to the keywords explorer API fails or returns an error response.
|
1939
|
+
|
1940
|
+
Tags:
|
1941
|
+
keywords-explorer, overview, fetch, api
|
1942
|
+
"""
|
1943
|
+
if select is None:
|
1944
|
+
raise ValueError("Missing required parameter 'select'")
|
1945
|
+
if country is None:
|
1946
|
+
raise ValueError("Missing required parameter 'country'")
|
1947
|
+
url = f"{self.base_url}/keywords-explorer/overview"
|
1948
|
+
query_params = {
|
1949
|
+
k: v
|
1950
|
+
for k, v in [
|
1951
|
+
("timeout", timeout),
|
1952
|
+
("offset", offset),
|
1953
|
+
("limit", limit),
|
1954
|
+
("order_by", order_by),
|
1955
|
+
("where", where),
|
1956
|
+
("select", select),
|
1957
|
+
("target_mode", target_mode),
|
1958
|
+
("target", target),
|
1959
|
+
("target_position", target_position),
|
1960
|
+
("country", country),
|
1961
|
+
("search_engine", search_engine),
|
1962
|
+
("keywords", keywords),
|
1963
|
+
("keyword_list_id", keyword_list_id),
|
1964
|
+
("output", output),
|
1965
|
+
]
|
1966
|
+
if v is not None
|
1967
|
+
}
|
1968
|
+
response = self._get(url, params=query_params)
|
1969
|
+
response.raise_for_status()
|
1970
|
+
return response.json()
|
1971
|
+
|
1972
|
+
def volume_history(self, country, keyword, output=None) -> dict[str, Any]:
|
1973
|
+
"""
|
1974
|
+
Fetches the historical search volume for a given keyword in a specified country.
|
1975
|
+
|
1976
|
+
Args:
|
1977
|
+
country: str. The country code or name for which to retrieve keyword volume history. Must not be None.
|
1978
|
+
keyword: str. The keyword to query for historical volume data. Must not be None.
|
1979
|
+
output: Optional[str]. The desired output format or additional filter. Defaults to None.
|
1980
|
+
|
1981
|
+
Returns:
|
1982
|
+
dict[str, Any]: A dictionary containing the volume history data for the specified keyword and country.
|
1983
|
+
|
1984
|
+
Raises:
|
1985
|
+
ValueError: Raised if 'country' or 'keyword' parameters are not provided (i.e., are None).
|
1986
|
+
requests.HTTPError: Raised if the HTTP request fails or the remote server returns an error status code.
|
1987
|
+
|
1988
|
+
Tags:
|
1989
|
+
fetch, volume-history, keywords, analytics
|
1990
|
+
"""
|
1991
|
+
if country is None:
|
1992
|
+
raise ValueError("Missing required parameter 'country'")
|
1993
|
+
if keyword is None:
|
1994
|
+
raise ValueError("Missing required parameter 'keyword'")
|
1995
|
+
url = f"{self.base_url}/keywords-explorer/volume-history"
|
1996
|
+
query_params = {
|
1997
|
+
k: v
|
1998
|
+
for k, v in [("country", country), ("keyword", keyword), ("output", output)]
|
1999
|
+
if v is not None
|
2000
|
+
}
|
2001
|
+
response = self._get(url, params=query_params)
|
2002
|
+
response.raise_for_status()
|
2003
|
+
return response.json()
|
2004
|
+
|
2005
|
+
def volume_by_country(
|
2006
|
+
self, keyword, limit=None, search_engine=None, output=None
|
2007
|
+
) -> dict[str, Any]:
|
2008
|
+
"""
|
2009
|
+
Retrieves search volume by country for a given keyword.
|
2010
|
+
|
2011
|
+
Args:
|
2012
|
+
keyword: Required keyword to search for.
|
2013
|
+
limit: Optional limit for the results.
|
2014
|
+
search_engine: Optional search engine to use.
|
2015
|
+
output: Optional output format specification.
|
2016
|
+
|
2017
|
+
Returns:
|
2018
|
+
A dictionary containing the volume data by country.
|
2019
|
+
|
2020
|
+
Raises:
|
2021
|
+
ValueError: Raised when the 'keyword' parameter is missing.
|
2022
|
+
|
2023
|
+
Tags:
|
2024
|
+
search, scrape, volume, country
|
2025
|
+
"""
|
2026
|
+
if keyword is None:
|
2027
|
+
raise ValueError("Missing required parameter 'keyword'")
|
2028
|
+
url = f"{self.base_url}/keywords-explorer/volume-by-country"
|
2029
|
+
query_params = {
|
2030
|
+
k: v
|
2031
|
+
for k, v in [
|
2032
|
+
("limit", limit),
|
2033
|
+
("search_engine", search_engine),
|
2034
|
+
("keyword", keyword),
|
2035
|
+
("output", output),
|
2036
|
+
]
|
2037
|
+
if v is not None
|
2038
|
+
}
|
2039
|
+
response = self._get(url, params=query_params)
|
2040
|
+
response.raise_for_status()
|
2041
|
+
return response.json()
|
2042
|
+
|
2043
|
+
def matching_terms(
|
2044
|
+
self,
|
2045
|
+
select,
|
2046
|
+
country,
|
2047
|
+
timeout=None,
|
2048
|
+
offset=None,
|
2049
|
+
limit=None,
|
2050
|
+
order_by=None,
|
2051
|
+
where=None,
|
2052
|
+
search_engine=None,
|
2053
|
+
keywords=None,
|
2054
|
+
keyword_list_id=None,
|
2055
|
+
match_mode=None,
|
2056
|
+
terms=None,
|
2057
|
+
output=None,
|
2058
|
+
) -> dict[str, Any]:
|
2059
|
+
"""
|
2060
|
+
Retrieves matching keyword terms from the keywords explorer API based on specified filters and search parameters.
|
2061
|
+
|
2062
|
+
Args:
|
2063
|
+
select: Fields to include in the response; required.
|
2064
|
+
country: Country code to filter results; required.
|
2065
|
+
timeout: Request timeout in seconds.
|
2066
|
+
offset: Starting offset for paginated results.
|
2067
|
+
limit: Maximum number of results to return.
|
2068
|
+
order_by: Field(s) to sort the result by.
|
2069
|
+
where: Additional filters to apply to the query.
|
2070
|
+
search_engine: Search engine to use for keyword matching.
|
2071
|
+
keywords: Seed keywords to search for matching terms.
|
2072
|
+
keyword_list_id: ID of a predefined keyword list to use as a seed.
|
2073
|
+
match_mode: Mode of keyword matching (e.g., broad, exact).
|
2074
|
+
terms: Specific terms to match in keywords.
|
2075
|
+
output: Output format or additional output options.
|
2076
|
+
|
2077
|
+
Returns:
|
2078
|
+
A dictionary containing the API response with the matching keyword terms and associated metadata.
|
2079
|
+
|
2080
|
+
Raises:
|
2081
|
+
ValueError: If the 'select' or 'country' parameter is missing.
|
2082
|
+
requests.HTTPError: If the API request fails or returns a non-success status code.
|
2083
|
+
|
2084
|
+
Tags:
|
2085
|
+
list, keywords, search, api, management
|
2086
|
+
"""
|
2087
|
+
if select is None:
|
2088
|
+
raise ValueError("Missing required parameter 'select'")
|
2089
|
+
if country is None:
|
2090
|
+
raise ValueError("Missing required parameter 'country'")
|
2091
|
+
url = f"{self.base_url}/keywords-explorer/matching-terms"
|
2092
|
+
query_params = {
|
2093
|
+
k: v
|
2094
|
+
for k, v in [
|
2095
|
+
("timeout", timeout),
|
2096
|
+
("offset", offset),
|
2097
|
+
("limit", limit),
|
2098
|
+
("order_by", order_by),
|
2099
|
+
("where", where),
|
2100
|
+
("select", select),
|
2101
|
+
("country", country),
|
2102
|
+
("search_engine", search_engine),
|
2103
|
+
("keywords", keywords),
|
2104
|
+
("keyword_list_id", keyword_list_id),
|
2105
|
+
("match_mode", match_mode),
|
2106
|
+
("terms", terms),
|
2107
|
+
("output", output),
|
2108
|
+
]
|
2109
|
+
if v is not None
|
2110
|
+
}
|
2111
|
+
response = self._get(url, params=query_params)
|
2112
|
+
response.raise_for_status()
|
2113
|
+
return response.json()
|
2114
|
+
|
2115
|
+
def related_terms(
|
2116
|
+
self,
|
2117
|
+
select,
|
2118
|
+
country,
|
2119
|
+
timeout=None,
|
2120
|
+
offset=None,
|
2121
|
+
limit=None,
|
2122
|
+
order_by=None,
|
2123
|
+
where=None,
|
2124
|
+
keywords=None,
|
2125
|
+
keyword_list_id=None,
|
2126
|
+
view_for=None,
|
2127
|
+
terms=None,
|
2128
|
+
output=None,
|
2129
|
+
) -> dict[str, Any]:
|
2130
|
+
"""
|
2131
|
+
Retrieves related keyword terms for a given selection and country, with optional filtering and pagination.
|
2132
|
+
|
2133
|
+
Args:
|
2134
|
+
select: str. Fields to be returned for each related term. Required.
|
2135
|
+
country: str. Country code or identifier specifying the market context. Required.
|
2136
|
+
timeout: Optional[int]. Timeout value for the request in seconds.
|
2137
|
+
offset: Optional[int]. Number of records to skip for pagination.
|
2138
|
+
limit: Optional[int]. Maximum number of results to return.
|
2139
|
+
order_by: Optional[str]. Field(s) by which to order the returned results.
|
2140
|
+
where: Optional[Any]. Filtering conditions for the related terms.
|
2141
|
+
keywords: Optional[str]. Comma-separated string of keywords to find related terms for.
|
2142
|
+
keyword_list_id: Optional[str]. Identifier for a list of keywords to use as the basis for the search.
|
2143
|
+
view_for: Optional[str]. View context for the related terms (e.g., user-specific).
|
2144
|
+
terms: Optional[Any]. Specific terms for refining the related terms search.
|
2145
|
+
output: Optional[Any]. Output formatting or additional output options.
|
2146
|
+
|
2147
|
+
Returns:
|
2148
|
+
dict. The JSON response containing related keyword terms and associated metadata.
|
2149
|
+
|
2150
|
+
Raises:
|
2151
|
+
ValueError: If the required 'select' or 'country' parameter is missing.
|
2152
|
+
|
2153
|
+
Tags:
|
2154
|
+
related-terms, search, keywords, api-call, management
|
2155
|
+
"""
|
2156
|
+
if select is None:
|
2157
|
+
raise ValueError("Missing required parameter 'select'")
|
2158
|
+
if country is None:
|
2159
|
+
raise ValueError("Missing required parameter 'country'")
|
2160
|
+
url = f"{self.base_url}/keywords-explorer/related-terms"
|
2161
|
+
query_params = {
|
2162
|
+
k: v
|
2163
|
+
for k, v in [
|
2164
|
+
("timeout", timeout),
|
2165
|
+
("offset", offset),
|
2166
|
+
("limit", limit),
|
2167
|
+
("order_by", order_by),
|
2168
|
+
("where", where),
|
2169
|
+
("select", select),
|
2170
|
+
("country", country),
|
2171
|
+
("keywords", keywords),
|
2172
|
+
("keyword_list_id", keyword_list_id),
|
2173
|
+
("view_for", view_for),
|
2174
|
+
("terms", terms),
|
2175
|
+
("output", output),
|
2176
|
+
]
|
2177
|
+
if v is not None
|
2178
|
+
}
|
2179
|
+
response = self._get(url, params=query_params)
|
2180
|
+
response.raise_for_status()
|
2181
|
+
return response.json()
|
2182
|
+
|
2183
|
+
def search_suggestions(
|
2184
|
+
self,
|
2185
|
+
select,
|
2186
|
+
country,
|
2187
|
+
timeout=None,
|
2188
|
+
offset=None,
|
2189
|
+
limit=None,
|
2190
|
+
order_by=None,
|
2191
|
+
where=None,
|
2192
|
+
search_engine=None,
|
2193
|
+
keywords=None,
|
2194
|
+
keyword_list_id=None,
|
2195
|
+
output=None,
|
2196
|
+
) -> dict[str, Any]:
|
2197
|
+
"""
|
2198
|
+
Fetches keyword search suggestions from the keywords explorer API based on the provided filtering and query parameters.
|
2199
|
+
|
2200
|
+
Args:
|
2201
|
+
select: str. The fields to retrieve in the search results. Required.
|
2202
|
+
country: str. The country code for which to fetch suggestions. Required.
|
2203
|
+
timeout: Optional[int]. Maximum time in seconds to wait for the API response.
|
2204
|
+
offset: Optional[int]. Number of results to skip before starting to return results.
|
2205
|
+
limit: Optional[int]. Maximum number of results to return.
|
2206
|
+
order_by: Optional[str]. Sorting parameter for the search results.
|
2207
|
+
where: Optional[str]. Additional filtering conditions for the search.
|
2208
|
+
search_engine: Optional[str]. The search engine to use for suggestions.
|
2209
|
+
keywords: Optional[str]. Keywords to search for suggestions.
|
2210
|
+
keyword_list_id: Optional[str]. Identifier for a saved keyword list to filter suggestions.
|
2211
|
+
output: Optional[str]. Output format or additional output options.
|
2212
|
+
|
2213
|
+
Returns:
|
2214
|
+
dict[str, Any]: JSON response containing the list of search suggestions and associated metadata.
|
2215
|
+
|
2216
|
+
Raises:
|
2217
|
+
ValueError: If the required parameter 'select' or 'country' is missing.
|
2218
|
+
HTTPError: If the HTTP request to the keywords explorer API fails.
|
2219
|
+
|
2220
|
+
Tags:
|
2221
|
+
search, keywords, api, suggestions
|
2222
|
+
"""
|
2223
|
+
if select is None:
|
2224
|
+
raise ValueError("Missing required parameter 'select'")
|
2225
|
+
if country is None:
|
2226
|
+
raise ValueError("Missing required parameter 'country'")
|
2227
|
+
url = f"{self.base_url}/keywords-explorer/search-suggestions"
|
2228
|
+
query_params = {
|
2229
|
+
k: v
|
2230
|
+
for k, v in [
|
2231
|
+
("timeout", timeout),
|
2232
|
+
("offset", offset),
|
2233
|
+
("limit", limit),
|
2234
|
+
("order_by", order_by),
|
2235
|
+
("where", where),
|
2236
|
+
("select", select),
|
2237
|
+
("country", country),
|
2238
|
+
("search_engine", search_engine),
|
2239
|
+
("keywords", keywords),
|
2240
|
+
("keyword_list_id", keyword_list_id),
|
2241
|
+
("output", output),
|
2242
|
+
]
|
2243
|
+
if v is not None
|
2244
|
+
}
|
2245
|
+
response = self._get(url, params=query_params)
|
2246
|
+
response.raise_for_status()
|
2247
|
+
return response.json()
|
2248
|
+
|
2249
|
+
def list_tools(self):
|
2250
|
+
return [
|
2251
|
+
self.crawler_ips,
|
2252
|
+
self.crawler_ip_ranges,
|
2253
|
+
self.limits_and_usage,
|
2254
|
+
self.batch_analysis,
|
2255
|
+
self.serp_overview,
|
2256
|
+
self.overview,
|
2257
|
+
self.competitors_overview,
|
2258
|
+
self.projects,
|
2259
|
+
self.domain_rating,
|
2260
|
+
self.backlinks_stats,
|
2261
|
+
self.outlinks_stats,
|
2262
|
+
self.metrics,
|
2263
|
+
self.refdomains_history,
|
2264
|
+
self.domain_rating_history,
|
2265
|
+
self.url_rating_history,
|
2266
|
+
self.pages_history,
|
2267
|
+
self.metrics_history,
|
2268
|
+
self.keywords_history,
|
2269
|
+
self.metrics_by_country,
|
2270
|
+
self.pages_by_traffic,
|
2271
|
+
self.all_backlinks,
|
2272
|
+
self.broken_backlinks,
|
2273
|
+
self.refdomains,
|
2274
|
+
self.anchors,
|
2275
|
+
self.linkeddomains,
|
2276
|
+
self.linked_anchors_external,
|
2277
|
+
self.linked_anchors_internal,
|
2278
|
+
self.organic_keywords,
|
2279
|
+
self.organic_competitors,
|
2280
|
+
self.top_pages,
|
2281
|
+
self.paid_pages,
|
2282
|
+
self.best_by_external_links,
|
2283
|
+
self.best_by_internal_links,
|
2284
|
+
self.total_search_volume_history,
|
2285
|
+
self.keyword_explorer_overview,
|
2286
|
+
self.volume_history,
|
2287
|
+
self.volume_by_country,
|
2288
|
+
self.matching_terms,
|
2289
|
+
self.related_terms,
|
2290
|
+
self.search_suggestions,
|
2291
|
+
]
|