n8n-nodes-dataforseo
Version:
DataForSEO is an SEO and marketing data provider, empowering businesses with invaluable insights via APIs and databases.
154 lines • 7.54 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.DataForSeoKeywordsApi = void 0;
const n8n_workflow_1 = require("n8n-workflow");
const google_ads_1 = require("./execute/google_ads");
const google_ads_2 = require("./resources/google_ads");
const bing_ads_1 = require("./execute/bing_ads");
const bing_ads_2 = require("./resources/bing_ads");
const google_trends_1 = require("./execute/google_trends");
const google_trends_2 = require("./resources/google_trends");
const dataforseo_trends_1 = require("./resources/dataforseo_trends");
const dataforseo_trends_2 = require("./execute/dataforseo_trends");
const clickstream_data_1 = require("./execute/clickstream_data");
const clickstream_data_2 = require("./resources/clickstream_data");
class DataForSeoKeywordsApi {
constructor() {
this.description = {
displayName: 'DataForSEO Keywords Data API',
name: 'dataForSeoKeywordsApi',
icon: 'file:dataforseo.svg',
group: ['transform'],
version: 1,
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
description: 'DataForSEO Keywords Data API',
defaults: {
name: 'DataForSeo Keywords Data API',
},
inputs: ["main"],
outputs: ["main"],
credentials: [
{
name: 'dataForSeoApi',
required: true,
},
],
requestDefaults: {
method: 'POST',
baseURL: 'https://api.dataforseo.com/v3',
headers: {
'Content-Type': 'application/json',
},
},
properties: [
{
displayName: 'Resource',
name: 'resource',
type: 'options',
noDataExpression: true,
options: [
{
name: 'Google Ads',
value: 'google_ads',
},
{
name: 'Bing Ads',
value: 'bing_ads',
},
{
name: 'Google Trends',
value: 'google_trends',
},
{
name: 'DataForSEO Trends',
value: 'dataforseo_trends',
},
{
name: 'Clickstream Data',
value: 'clickstream_data',
}
],
default: 'google_ads',
},
...google_ads_2.GoogleAdsOperations,
...bing_ads_2.BingAdsOperations,
...google_trends_2.GoogleTrendsOperations,
...dataforseo_trends_1.DataforseoTrendsOperations,
...clickstream_data_2.ClickstreamDataOperations
],
};
}
async execute() {
let responseData = [];
const resource = this.getNodeParameter('resource', 0);
const operation = this.getNodeParameter('operation', 0);
const mapping = {
'google_ads': {
'get-live-google-search-volume': google_ads_1.getLiveGoogleSearchVolume,
'get-google-search-volume': google_ads_1.getGoogleSearchVolume,
'get-live-google-keywords-for-site': google_ads_1.getLiveGoogleKeywordsForSite,
'get-google-keywords-for-site': google_ads_1.getGoogleKeywordsForSite,
'get-live-google-keywords-for-keywords': google_ads_1.getLiveGoogleKeywordsForKeywords,
'get-google-keywords-for-keywords': google_ads_1.getGoogleKeywordsForKeywords,
'get-live-google-ad-traffic-by-keywords': google_ads_1.getLiveGoogleTrafficByKeywords,
'get-google-ad-traffic-by-keywords': google_ads_1.getGoogleTrafficByKeywords
},
'bing_ads': {
'get-live-bing-search-volume': bing_ads_1.getLiveBingSearchVolume,
'get-bing-search-volume': bing_ads_1.getBingSearchVolume,
'get-live-bing-search-volume-history': bing_ads_1.getLiveBingSearchVolumeHistory,
'get-bing-search-volume-history': bing_ads_1.getBingSearchVolumeHistory,
'get-live-bing-keywords-for-site': bing_ads_1.getLiveBingKeywordsForSite,
'get-bing-keywords-for-site': bing_ads_1.getBingKeywordsForSite,
'get-live-bing-keywords-for-keywords': bing_ads_1.getLiveBingKeywordsForKeywords,
'get-bing-keywords-for-keywords': bing_ads_1.getBingKeywordsForKeywords,
'get-live-bing-keyword-performance': bing_ads_1.getLiveBingKeywordperformance,
'get-bing-keyword-performance': bing_ads_1.getBingKeywordperformance,
'get-live-bing-keyword-suggestions-for-url': bing_ads_1.getLiveBingKeywordSuggestionsForUrl,
'get-bing-keyword-suggestions-for-url': bing_ads_1.getBingKeywordSuggestionsForUrl,
'get-live-bing-ads-audience-estimation': bing_ads_1.getLiveBingAudienceEstimation,
'get-bing-ads-audience-estimation': bing_ads_1.getBingAudienceEstimation
},
'google_trends': {
'get-live-google-trends-explore': google_trends_1.getLiveGoogleTrendsExplore,
'get-google-trends-explore': google_trends_1.getGoogleTrendsExplore
},
'dataforseo_trends': {
'get-live-dataforseo-trends-explore': dataforseo_trends_2.getLiveDataForSeoTrendsExplore,
'get-live-dataforseo-trends-subregion-interests': dataforseo_trends_2.getLiveDataForSeoTrendsSubregionInterests,
'get-live-dataforseo-trends-demography': dataforseo_trends_2.getLiveDataForSeoTrendsDemography,
'get-live-dataforseo-trends-merged-data': dataforseo_trends_2.getLiveDataForSeoTrendsMergedData
},
'clickstream_data': {
'get-live-dataforseo-search-volume': clickstream_data_1.getLiveClickstreamSearchVolume,
'get-live-clickstream-global-search-volume': clickstream_data_1.getLiveGlobalSearchVolume,
'get-live-bulk-clickstream-search-volume': clickstream_data_1.getLiveBulkClickstreamSearchVolume
}
};
const fn = mapping[resource][operation];
if (!fn) {
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "Something went wrong");
}
try {
const items = this.getInputData();
for (let i = 0; i < items.length; i++) {
const result = await fn(this, i);
responseData.push({
json: result,
pairedItem: { item: i }
});
}
}
catch (e) {
if (e instanceof n8n_workflow_1.NodeOperationError) {
throw e;
}
else {
throw new n8n_workflow_1.NodeOperationError(this.getNode(), "Something went wrong");
}
}
return [this.helpers.returnJsonArray(responseData)];
}
}
exports.DataForSeoKeywordsApi = DataForSeoKeywordsApi;
//# sourceMappingURL=DataForSeoKeywordsApi.node.js.map