@adobe/spacecat-shared-ahrefs-client 1.6.5 → 1.6.6
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.
- package/CHANGELOG.md +7 -0
- package/package.json +1 -1
- package/src/index.d.ts +7 -1
- package/src/index.js +11 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [@adobe/spacecat-shared-ahrefs-client-v1.6.6](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-ahrefs-client-v1.6.5...@adobe/spacecat-shared-ahrefs-client-v1.6.6) (2025-02-12)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **ahrefs-client:** enhance organic keywords query to use in HOTLCTR opportunity ([#589](https://github.com/adobe/spacecat-shared/issues/589)) ([23aef2e](https://github.com/adobe/spacecat-shared/commit/23aef2eef7a2e44b3d68ec8ba64378e8d4a3b605))
|
|
7
|
+
|
|
1
8
|
# [@adobe/spacecat-shared-ahrefs-client-v1.6.5](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-ahrefs-client-v1.6.4...@adobe/spacecat-shared-ahrefs-client-v1.6.5) (2025-02-08)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -73,7 +73,13 @@ export default class AhrefsAPIClient {
|
|
|
73
73
|
|
|
74
74
|
/**
|
|
75
75
|
* Asynchronous method to get organic keywords.
|
|
76
|
+
* @param url
|
|
77
|
+
* @param country
|
|
78
|
+
* @param keywordFilter
|
|
79
|
+
* @param limit
|
|
80
|
+
* @param mode
|
|
76
81
|
*/
|
|
77
|
-
getOrganicKeywords(url: string, country?: string, keywordFilter?: string[],
|
|
82
|
+
getOrganicKeywords(url: string, country?: string, keywordFilter?: string[],
|
|
83
|
+
limit?: number, mode?: string):
|
|
78
84
|
Promise<{ result: object, fullAuditRef: string }>;
|
|
79
85
|
}
|
package/src/index.js
CHANGED
|
@@ -172,7 +172,7 @@ export default class AhrefsAPIClient {
|
|
|
172
172
|
return this.sendRequest('/site-explorer/metrics-history', queryParams);
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
-
async getOrganicKeywords(url, country = 'us', keywordFilter = [], limit =
|
|
175
|
+
async getOrganicKeywords(url, country = 'us', keywordFilter = [], limit = 10, mode = 'prefix') {
|
|
176
176
|
if (!hasText(url)) {
|
|
177
177
|
throw new Error(`Invalid URL: ${url}`);
|
|
178
178
|
}
|
|
@@ -185,18 +185,25 @@ export default class AhrefsAPIClient {
|
|
|
185
185
|
if (!Number.isInteger(limit) || limit < 1) {
|
|
186
186
|
throw new Error(`Invalid limit: ${limit}`);
|
|
187
187
|
}
|
|
188
|
+
if (!['prefix', 'exact'].includes(mode)) {
|
|
189
|
+
throw new Error(`Invalid mode: ${mode}`);
|
|
190
|
+
}
|
|
191
|
+
|
|
188
192
|
const queryParams = {
|
|
189
193
|
country,
|
|
190
194
|
date: new Date().toISOString().split('T')[0],
|
|
191
195
|
select: [
|
|
192
196
|
'keyword',
|
|
193
197
|
'sum_traffic',
|
|
194
|
-
'
|
|
198
|
+
'volume',
|
|
199
|
+
'best_position',
|
|
200
|
+
'cpc',
|
|
201
|
+
'is_branded',
|
|
195
202
|
].join(','),
|
|
196
203
|
order_by: 'sum_traffic:desc',
|
|
197
204
|
target: url,
|
|
198
|
-
limit: getLimit(limit,
|
|
199
|
-
mode
|
|
205
|
+
limit: getLimit(limit, 100),
|
|
206
|
+
mode,
|
|
200
207
|
output: 'json',
|
|
201
208
|
};
|
|
202
209
|
if (keywordFilter.length > 0) {
|