Skip to content

Commit 65ce00c

Browse files
authored
Merging pull request #15491
* Added actions * Done requests changes
1 parent e946d84 commit 65ce00c

File tree

7 files changed

+306
-8
lines changed

7 files changed

+306
-8
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import app from "../../dataforseo.app.mjs";
2+
3+
export default {
4+
key: "dataforseo-get-business-listings",
5+
name: "Get Business Listings",
6+
description: "Get Business Listings. [See the documentation](https://docs.dataforseo.com/v3/business_data/business_listings/search/live/?bash)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
locationCoordinate: {
12+
propDefinition: [
13+
app,
14+
"locationCoordinate",
15+
],
16+
},
17+
categories: {
18+
propDefinition: [
19+
app,
20+
"categories",
21+
],
22+
},
23+
title: {
24+
propDefinition: [
25+
app,
26+
"title",
27+
],
28+
},
29+
description: {
30+
propDefinition: [
31+
app,
32+
"description",
33+
],
34+
},
35+
isClaimed: {
36+
propDefinition: [
37+
app,
38+
"isClaimed",
39+
],
40+
},
41+
limit: {
42+
propDefinition: [
43+
app,
44+
"limit",
45+
],
46+
},
47+
},
48+
async run({ $ }) {
49+
const response = await this.app.getBusinessListings({
50+
$,
51+
data: [
52+
{
53+
location_coordinate: this.locationCoordinate,
54+
categories: this.categories,
55+
description: this.description,
56+
title: this.title,
57+
is_claimed: this.isClaimed,
58+
limit: this.limit,
59+
},
60+
],
61+
});
62+
$.export("$summary", `Successfully sent the request. Status: ${response.tasks[0].status_message}`);
63+
return response;
64+
},
65+
};
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import app from "../../dataforseo.app.mjs";
2+
3+
export default {
4+
key: "dataforseo-get-keyword-difficulty",
5+
name: "Get Keyword Difficulty",
6+
description: "Get Keyword Difficulty. [See the documentation](https://docs.dataforseo.com/v3/dataforseo_labs/google/bulk_keyword_difficulty/live/?bash)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
languageCode: {
12+
propDefinition: [
13+
app,
14+
"languageCode",
15+
],
16+
},
17+
locationCode: {
18+
propDefinition: [
19+
app,
20+
"locationCode",
21+
],
22+
},
23+
keywords: {
24+
propDefinition: [
25+
app,
26+
"keywords",
27+
],
28+
},
29+
},
30+
async run({ $ }) {
31+
const response = await this.app.getKeywordDifficulty({
32+
$,
33+
data: [
34+
{
35+
language_code: this.languageCode,
36+
location_code: this.locationCode,
37+
keywords: this.keywords,
38+
},
39+
],
40+
});
41+
$.export("$summary", `Successfully sent the request. Status: ${response.tasks[0].status_message}`);
42+
return response;
43+
},
44+
};
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import app from "../../dataforseo.app.mjs";
2+
3+
export default {
4+
key: "dataforseo-get-ranked-keywords",
5+
name: "Get Ranked Keywords",
6+
description: "Description for get-ranked-keywords. [See the documentation](https://docs.dataforseo.com/v3/keywords_data/google_ads/keywords_for_site/task_post/?bash)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
locationCode: {
12+
propDefinition: [
13+
app,
14+
"locationCode",
15+
],
16+
},
17+
targetType: {
18+
propDefinition: [
19+
app,
20+
"targetType",
21+
],
22+
},
23+
target: {
24+
propDefinition: [
25+
app,
26+
"target",
27+
],
28+
},
29+
},
30+
async run({ $ }) {
31+
const response = await this.app.getRankedKeywords({
32+
$,
33+
data: [
34+
{
35+
location_code: this.locationCode,
36+
target_type: this.targetType,
37+
target: this.target,
38+
},
39+
],
40+
});
41+
$.export("$summary", `Successfully sent the request. Status: ${response.tasks[0].status_message}`);
42+
return response;
43+
},
44+
};
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export default {
2+
TARGET_TYPES: [
3+
"site",
4+
"page",
5+
],
6+
};
Lines changed: 137 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,143 @@
1+
import { axios } from "@pipedream/platform";
2+
import constants from "./common/constants.mjs";
3+
14
export default {
25
type: "app",
36
app: "dataforseo",
4-
propDefinitions: {},
7+
propDefinitions: {
8+
locationCode: {
9+
type: "string",
10+
label: "Location Code",
11+
description: "The code of the target location",
12+
async options() {
13+
const response = await this.getLocations();
14+
const languageCodes = response.tasks[0].result;
15+
return languageCodes.map(({
16+
location_name, location_code,
17+
}) => ({
18+
value: location_code,
19+
label: location_name,
20+
}));
21+
},
22+
},
23+
locationCoordinate: {
24+
type: "string",
25+
label: "Location Coordinate",
26+
description: "The coordinate of the target location. It should be specified in the “latitude,longitude,radius” format, i.e.: `53.476225,-2.243572,200`",
27+
},
28+
targetType: {
29+
type: "string",
30+
label: "Target Type",
31+
description: "The type of the target",
32+
options: constants.TARGET_TYPES,
33+
},
34+
target: {
35+
type: "string",
36+
label: "Target",
37+
description: "The domain name or the url of the target website or page",
38+
},
39+
categories: {
40+
type: "string[]",
41+
label: "Categories",
42+
description: "The categories you specify are used to search for business listings",
43+
optional: true,
44+
},
45+
description: {
46+
type: "string",
47+
label: "Description",
48+
description: "The description of the business entity for which the results are collected",
49+
optional: true,
50+
},
51+
title: {
52+
type: "string",
53+
label: "Title",
54+
description: "The name of the business entity for which the results are collected",
55+
optional: true,
56+
},
57+
isClaimed: {
58+
type: "boolean",
59+
label: "Is Claimed",
60+
description: "Indicates whether the business is verified by its owner on Google Maps",
61+
optional: true,
62+
},
63+
limit: {
64+
type: "string",
65+
label: "Limit",
66+
description: "The maximum number of returned businesses",
67+
optional: true,
68+
},
69+
languageCode: {
70+
type: "string",
71+
label: "Language Code",
72+
description: "The language code for the request",
73+
async options() {
74+
const response = await this.getLanguageCode();
75+
const languageCodes = response.tasks[0].result;
76+
return languageCodes.map(({
77+
language_name, language_code,
78+
}) => ({
79+
value: language_code,
80+
label: language_name,
81+
}));
82+
},
83+
},
84+
keywords: {
85+
type: "string[]",
86+
label: "Keywords",
87+
description: "Target Keywords. The maximum number of keywords is 1000",
88+
},
89+
},
590
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
91+
_baseUrl() {
92+
return "https://api.dataforseo.com/v3";
93+
},
94+
async _makeRequest(opts = {}) {
95+
const {
96+
$ = this,
97+
path,
98+
...otherOpts
99+
} = opts;
100+
return axios($, {
101+
...otherOpts,
102+
url: this._baseUrl() + path,
103+
auth: {
104+
username: `${this.$auth.api_login}`,
105+
password: `${this.$auth.api_password}`,
106+
},
107+
});
108+
},
109+
async getKeywordDifficulty(args = {}) {
110+
return this._makeRequest({
111+
path: "/dataforseo_labs/google/bulk_keyword_difficulty/live",
112+
method: "post",
113+
...args,
114+
});
115+
},
116+
async getBusinessListings(args = {}) {
117+
return this._makeRequest({
118+
path: "/business_data/business_listings/search/live",
119+
method: "post",
120+
...args,
121+
});
122+
},
123+
async getRankedKeywords(args = {}) {
124+
return this._makeRequest({
125+
path: "/keywords_data/google_ads/keywords_for_site/live",
126+
method: "post",
127+
...args,
128+
});
129+
},
130+
async getLanguageCode(args = {}) {
131+
return this._makeRequest({
132+
path: "/keywords_data/google_ads/languages",
133+
...args,
134+
});
135+
},
136+
async getLocations(args = {}) {
137+
return this._makeRequest({
138+
path: "/serp/google/ads_search/locations",
139+
...args,
140+
});
9141
},
10142
},
11-
};
143+
};

components/dataforseo/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/dataforseo",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream DataForSEO Components",
55
"main": "dataforseo.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.0.3"
1417
}
15-
}
18+
}

pnpm-lock.yaml

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)