Skip to content

Commit efaadc7

Browse files
committed
Get Backlinks + reusing props
1 parent a818abc commit efaadc7

File tree

4 files changed

+173
-31
lines changed

4 files changed

+173
-31
lines changed

components/dataforseo/actions/get-backlink-summary/get-backlink-summary.mjs

Lines changed: 22 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import dataforseo from "../../dataforseo.app.mjs";
2+
import { parseObjectEntries } from "../../common/utils.mjs";
23

34
export default {
45
key: "dataforseo-get-backlink-summary",
56
name: "Get Backlink Summary",
67
description:
7-
"Get an overview of backlinks data available for a given domain, subdomain, or webpage. [See the documentation](https://docs.dataforseo.com/v3/business_data/business_listings/search/live/?bash)",
8-
version: "0.0.2",
8+
"Get an overview of backlinks data available for a given domain, subdomain, or webpage. [See the documentation](https://docs.dataforseo.com/v3/backlinks/summary/live/?bash)",
9+
version: "0.0.1",
910
type: "action",
1011
methods: {
1112
getBacklinkSummary(args = {}) {
@@ -45,15 +46,6 @@ export default {
4546
"Indicates if internal backlinks from subdomains to the target will be excluded from the results. Default is `true`",
4647
optional: true,
4748
},
48-
internalListLimit: {
49-
type: "integer",
50-
label: "Internal List Limit",
51-
description:
52-
"Maximum number of elements within internal arrays. [See the documentation](https://docs.dataforseo.com/v3/backlinks/summary/live/?bash#internal_list_limit) for more information",
53-
default: 10,
54-
max: 1000,
55-
optional: true,
56-
},
5749
backlinksStatusType: {
5850
type: "string",
5951
label: "Include Indirect Links",
@@ -78,30 +70,29 @@ export default {
7870
default: "live",
7971
},
8072
backlinksFilters: {
81-
type: "string[]",
82-
label: "Backlinks Filters",
83-
description:
84-
"You can use this field to filter the initial backlinks that will be included in the dataset for aggregated metrics for your target. [See the documentation](https://docs.dataforseo.com/v3/backlinks/summary/live/?bash#backlinks_filters) for more information. Example: `[\"dofollow\", \"=\", true]`",
85-
optional: true,
73+
propDefinition: [
74+
dataforseo,
75+
"backlinksFilters",
76+
],
8677
},
8778
rankScale: {
88-
type: "string",
89-
label: "Rank Scale",
90-
description:
91-
"Whether rank values are presented on a 0-100 or 0-1000 scale",
92-
optional: true,
93-
options: [
94-
"one_hundred",
95-
"one_thousand",
79+
propDefinition: [
80+
dataforseo,
81+
"rankScale",
9682
],
97-
default: "one_thousand",
9883
},
9984
tag: {
100-
type: "string",
101-
label: "Tag",
102-
description:
103-
"You can use this parameter to identify the task and match it with the result.",
104-
optional: true,
85+
propDefinition: [
86+
dataforseo,
87+
"tag",
88+
],
89+
},
90+
additionalOptions: {
91+
propDefinition: [
92+
dataforseo,
93+
"additionalOptions",
94+
],
95+
description: "Additional parameters to send in the request. [See the documentation](https://docs.dataforseo.com/v3/backlinks/summary/live/?bash) for all available parameters. Values will be parsed as JSON where applicable.",
10596
},
10697
},
10798
async run({ $ }) {
@@ -113,11 +104,11 @@ export default {
113104
include_subdomains: this.includeSubdomains,
114105
include_indirect_links: this.includeIndirectLinks,
115106
exclude_internal_backlinks: this.excludeInternalBacklinks,
116-
internal_list_limit: this.internalListLimit,
117107
backlinks_status_type: this.backlinksStatusType,
118108
backlinks_filters: this.backlinksFilters,
119109
rank_scale: this.rankScale,
120110
tag: this.tag,
111+
...parseObjectEntries(this.additionalOptions),
121112
},
122113
],
123114
});
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
import { parseObjectEntries } from "../../common/utils.mjs";
2+
import dataforseo from "../../dataforseo.app.mjs";
3+
4+
export default {
5+
key: "dataforseo-get-backlinks",
6+
name: "Get Backlinks",
7+
description:
8+
"Get a list of backlinks and relevant data for a given domain, subdomain, or webpage. [See the documentation](https://docs.dataforseo.com/v3/backlinks/backlinks/live/?bash)",
9+
version: "0.0.1",
10+
type: "action",
11+
methods: {
12+
getBacklinks(args = {}) {
13+
return this._makeRequest({
14+
path: "/backlinks/backlinks/live",
15+
method: "post",
16+
...args,
17+
});
18+
},
19+
},
20+
props: {
21+
dataforseo,
22+
target: {
23+
propDefinition: [
24+
dataforseo,
25+
"backlinksTarget",
26+
],
27+
},
28+
mode: {
29+
type: "string",
30+
label: "Mode",
31+
description: "Select the mode of grouping the results",
32+
options: [
33+
{
34+
value: "as_is",
35+
label: "returns all backlinks",
36+
},
37+
{
38+
value: "one_per_domain",
39+
label: "returns one backlink per domain",
40+
},
41+
{
42+
value: "one_per_anchor",
43+
label: "returns one backlink per anchor",
44+
},
45+
],
46+
default: "as_is",
47+
},
48+
filters: {
49+
propDefinition: [
50+
dataforseo,
51+
"backlinksFilters",
52+
],
53+
},
54+
order_by: {
55+
type: "string[]",
56+
label: "Order By",
57+
description: "One or more rules to sort results with, with each entry being a field and a direction (`asc` for ascending or `desc` for descending). Example: [\"domain_from_rank,desc\",\"page_from_rank,asc\"]",
58+
},
59+
rankScale: {
60+
propDefinition: [
61+
dataforseo,
62+
"rankScale",
63+
],
64+
},
65+
tag: {
66+
propDefinition: [
67+
dataforseo,
68+
"tag",
69+
],
70+
},
71+
additionalOptions: {
72+
propDefinition: [
73+
dataforseo,
74+
"additionalOptions",
75+
],
76+
description: "Additional parameters to send in the request. [See the documentation](https://docs.dataforseo.com/v3/backlinks/backlinks/live/?bash) for all available parameters. Values will be parsed as JSON where applicable.",
77+
},
78+
},
79+
async run({ $ }) {
80+
const response = await this.getBacklinkSummary({
81+
$,
82+
data: [
83+
{
84+
target: this.target,
85+
mode: this.mode,
86+
filters: this.filters,
87+
order_by: this.order_by,
88+
rank_scale: this.rankScale,
89+
tag: this.tag,
90+
...parseObjectEntries(this.additionalOptions),
91+
},
92+
],
93+
});
94+
$.export("$summary", "Successfully retrieved backlink summary");
95+
return response;
96+
},
97+
};
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
function optionalParseAsJSON(value) {
2+
try {
3+
return JSON.parse(value);
4+
} catch (e) {
5+
return value;
6+
}
7+
}
8+
9+
export function parseObjectEntries(value = {}) {
10+
const obj = typeof value === "string"
11+
? JSON.parse(value)
12+
: value;
13+
return Object.fromEntries(
14+
Object.entries(obj).map(([
15+
key,
16+
value,
17+
]) => [
18+
key,
19+
optionalParseAsJSON(value),
20+
]),
21+
);
22+
}

components/dataforseo/dataforseo.app.mjs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,38 @@ export default {
9292
label: "Keywords",
9393
description: "Target Keywords. The maximum number of keywords is 1000",
9494
},
95+
backlinksFilters: {
96+
type: "string[]",
97+
label: "Backlinks Filters",
98+
description:
99+
"You can use this field to filter the initial backlinks that will be included in the dataset for aggregated metrics for your target. [See the documentation](https://docs.dataforseo.com/v3/backlinks/filters/?bash) for more information. Example: `[\"dofollow\", \"=\", true]`",
100+
optional: true,
101+
},
102+
rankScale: {
103+
type: "string",
104+
label: "Rank Scale",
105+
description:
106+
"Whether rank values are presented on a 0-100 or 0-1000 scale",
107+
optional: true,
108+
options: [
109+
"one_hundred",
110+
"one_thousand",
111+
],
112+
default: "one_thousand",
113+
},
114+
tag: {
115+
type: "string",
116+
label: "Tag",
117+
description:
118+
"You can use this parameter to identify the task and match it with the result.",
119+
optional: true,
120+
},
121+
additionalOptions: {
122+
type: "object",
123+
label: "Additional Options",
124+
description: "Additional parameters to send in the request. [See the documentation](https://developers.ringcentral.com/api-reference/External-Contacts/createContact) for all available parameters. Values will be parsed as JSON where applicable.",
125+
optional: true,
126+
},
95127
},
96128
methods: {
97129
_baseUrl() {

0 commit comments

Comments
 (0)