UNPKG

n8n-nodes-dataforseo

Version:

DataForSEO is an SEO and marketing data provider, empowering businesses with invaluable insights via APIs and databases.

228 lines 13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DataForSeoSerpApi = void 0; const n8n_workflow_1 = require("n8n-workflow"); const google_1 = require("./resources/google"); const google_2 = require("./execute/google"); const bing_1 = require("./execute/bing"); const bing_2 = require("./resources/bing"); const youtube_1 = require("./resources/youtube"); const youtube_2 = require("./execute/youtube"); const yahoo_1 = require("./execute/yahoo"); const yahoo_2 = require("./resources/yahoo"); const baidu_1 = require("./resources/baidu"); const baidu_2 = require("./execute/baidu"); const naver_1 = require("./execute/naver"); const naver_2 = require("./resources/naver"); const seznam_1 = require("./resources/seznam"); const seznam_2 = require("./execute/seznam"); class DataForSeoSerpApi { constructor() { this.description = { displayName: 'DataForSEO SERP API', name: 'dataForSeoSerpApi', icon: 'file:dataforseo.svg', group: ['transform'], version: 1, subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}', description: 'DataForSEO SERP API', defaults: { name: 'DataForSeo SERP 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', value: 'google', }, { name: 'Bing', value: 'bing', }, { name: 'YouTube', value: 'youtube', }, { name: 'Yahoo', value: 'yahoo', }, { name: 'Baidu', value: 'baidu', }, { name: 'Naver', value: 'naver', }, { name: 'Seznam', value: 'seznam', } ], default: 'google', }, ...google_1.GoogleOperations, ...bing_2.BingOperations, ...youtube_1.YouTubeOperations, ...yahoo_2.YahooOperations, ...baidu_1.BaiduOperations, ...naver_2.NaverOperations, ...seznam_1.SeznamOperations ], }; } async execute() { let responseData = []; const resource = this.getNodeParameter('resource', 0); const operation = this.getNodeParameter('operation', 0); const mapping = { 'google': { 'get-live-google-organic-serp-regular': google_2.getLiveGoogleOrganicSERPRegular, 'get-live-google-organic-serp-advanced': google_2.getLiveGoogleOrganicSERPAdvanced, 'get-live-google-organic-serp-html': google_2.getLiveGoogleOrganicSERPHTML, 'get-google-organic-serp-regular': google_2.getGoogleOrganicSERPRegular, 'get-google-organic-serp-advanced': google_2.getGoogleOrganicSERPAdvanced, 'get-google-organic-serp-html': google_2.getGoogleOrganicSERPHTML, 'get-live-google-ai-mode-serp-advanced': google_2.getLiveGoogleAiModeSERPAdvanced, 'get-live-google-ai-mode-serp-html': google_2.getLiveGoogleAiModeSERPHtml, 'get-google-ai-mode-serp-advanced': google_2.getGoogleAiModeSERPAdvanced, 'get-google-ai-mode-serp-html': google_2.getGoogleAiModeSERPHTML, 'get-live-google-maps-serp-advanced': google_2.getLiveGoogleMapsSERPAdvanced, 'get-google-maps-serp-advanced': google_2.getGoogleMapsSERPAdvanced, 'get-live-google-local-finder-serp-advanced': google_2.getLiveGoogleLocalFinderSERPAdvanced, 'get-live-google-local-finder-serp-html': google_2.getLiveGoogleLocalFinderSERPHTML, 'get-google-local-finder-serp-advanced': google_2.getGoogleLocalFinderSERPAdvanced, 'get-google-local-finder-serp-html': google_2.getGoogleLocalFinderSERPHTML, 'get-live-google-news-serp-advanced': google_2.getLiveGoogleNewsSERPAdvanced, 'get-live-google-news-serp-html': google_2.getLiveGoogleNewsSERPHTML, 'get-google-news-serp-advanced': google_2.getGoogleNewsSERPAdvanced, 'get-google-news-serp-html': google_2.getGoogleNewsSERPHTML, 'get-live-google-events-serp-advanced': google_2.getLiveGoogleEventsSERPAdvanced, 'get-google-events-serp-advanced': google_2.getGoogleEventsSERPAdvanced, 'get-live-google-images-serp-advanced': google_2.getLiveGoogleImagesSERPAdvanced, 'get-live-google-images-serp-html': google_2.getLiveGoogleImagesSERPHTML, 'get-google-images-serp-advanced': google_2.getGoogleImagesSERPAdvanced, 'get-google-images-serp-html': google_2.getGoogleImagesSERPHTML, 'get-google-search-by-image-serp-advanced': google_2.getGoogleSearchByImageSERPAdvanced, 'get-google-search-by-image-serp-html': google_2.getGoogleSearchByImageSERPHTML, 'get-google-jobs-serp-advanced': google_2.getGoogleJobsSERPAdvanced, 'get-google-jobs-serp-html': google_2.getGoogleJobsSERPHTML, 'get-live-google-autocomplete-serp-advanced': google_2.getLiveGoogleAutocompleteSERPAdvanced, 'get-google-autocomplete-serp-advanced': google_2.getGoogleAutocompleteSERPAdvanced, 'get-live-google-dataset-serp-advanced': google_2.getLiveGoogleDatasetSERPAdvanced, 'get-google-dataset-serp-advanced': google_2.getGoogleDatasetSERPAdvanced, 'get-live-google-dataset-info-advanced': google_2.getLiveGoogleDatasetInfoAdvanced, 'get-google-dataset-info-advanced': google_2.getGoogleDatasetInfoAdvanced, 'get-live-google-ads-advertisers-serp-advanced': google_2.getLiveGoogleAdsAdvertisersSERPInfoAdvanced, 'get-google-ads-advertisers-serp-advanced': google_2.getGoogleAdsAdvertisersSERPAdvanced, 'get-live-google-ads-search-advanced': google_2.getLiveGoogleAdsSearchAdvanced, 'get-google-ads-search-advanced': google_2.getGoogleAdsSearchAdvanced, 'get-live-google-finance-explore-serp-advanced': google_2.getLiveGoogleFinanceExploreSERPAdvanced, 'get-live-google-finance-explore-serp-html': google_2.getLiveGoogleFinanceExploreSERPHTML, 'get-google-finance-explore-serp-advanced': google_2.getGoogleFinanceExploreSERPAdvanced, 'get-google-finance-explore-serp-html': google_2.getGoogleFinanceExploreSERPHTML, 'get-live-google-finance-markets-serp-advanced': google_2.getLiveGoogleFinanceMarketsSERPAdvanced, 'get-live-google-finance-markets-serp-html': google_2.getLiveGoogleFinanceMarketsSERPHTML, 'get-google-finance-markets-serp-advanced': google_2.getGoogleFinanceMarketsSERPAdvanced, 'get-google-finance-markets-serp-html': google_2.getGoogleFinanceMarketsSERPHTML, 'get-live-google-finance-quote-serp-advanced': google_2.getLiveGoogleFinanceQuoteSERPAdvanced, 'get-live-google-finance-quote-serp-html': google_2.getLiveGoogleFinanceQuoteSERPHTML, 'get-google-finance-quote-serp-advanced': google_2.getGoogleFinanceQuoteSERPAdvanced, 'get-google-finance-quote-serp-html': google_2.getGoogleFinanceQuoteSERPHTML, 'get-live-google-finance-ticker-search-advanced': google_2.getLiveGoogleFinanceTickerSearchAdvanced, 'get-google-finance-ticker-search-advanced': google_2.getGoogleFinanceTickerSearchAdvanced }, 'bing': { 'get-live-bing-organic-serp-regular': bing_1.getLiveBingOrganicSERPRegular, 'get-live-bing-organic-serp-advanced': bing_1.getLiveBingOrganicSERPAdvanced, 'get-live-bing-organic-serp-html': bing_1.getLiveBingOrganicSERPHTML, 'get-bing-organic-serp-regular': bing_1.getBingOrganicSERPRegular, 'get-bing-organic-serp-advanced': bing_1.getBingOrganicSERPAdvanced, 'get-bing-organic-serp-html': bing_1.getBingOrganicSERPHTML, 'get-live-bing-local-finder-serp-regular': bing_1.getLiveBingLocalPackSERPRegular, 'get-live-bing-local-finder-serp-html': bing_1.getLiveBingLocalPackSERPHTML, 'get-bing-local-finder-serp-regular': bing_1.getBingLocalPackSERPRegular, 'get-bing-local-finder-serp-html': bing_1.getBingLocalPackSERPHTML }, 'youtube': { 'get-live-youtube-organic-serp-advanced': youtube_2.getLiveYoutubeOrganicSERPAdvanced, 'get-youtube-organic-serp-advanced': youtube_2.getYoutubeOrganicSERPAdvanced, 'get-live-youtube-video-info-advanced': youtube_2.getLiveYoutubeVideoInfoAdvanced, 'get-youtube-video-info-advanced': youtube_2.getYoutubeVideoInfoAdvanced, 'get-live-youtube-subtitles-advanced': youtube_2.getLiveYoutubeSubtitlesAdvanced, 'get-youtube-subtitles-advanced': youtube_2.getYoutubeSubtitlesAdvanced, 'get-live-youtube-comments-advanced': youtube_2.getLiveYoutubeCommentsAdvanced, 'get-youtube-comments-advanced': youtube_2.getYoutubeCommentsAdvanced }, 'yahoo': { 'get-live-yahoo-organic-serp-regular': yahoo_1.getLiveYahooOrganicSERPRegular, 'get-live-yahoo-organic-serp-advanced': yahoo_1.getLiveYahooOrganicSERPAdvanced, 'get-live-yahoo-organic-serp-html': yahoo_1.getLiveYahooOrganicSERPHTML, 'get-yahoo-organic-serp-regular': yahoo_1.getYahooOrganicSERPRegular, 'get-yahoo-organic-serp-advanced': yahoo_1.getYahooOrganicSERPAdvanced, 'get-yahoo-organic-serp-html': yahoo_1.getYahooOrganicSERPHTML }, 'baidu': { 'get-baidu-organic-serp-regular': baidu_2.getBaiduOrganicSERPRegular, 'get-baidu-organic-serp-advanced': baidu_2.getBaiduOrganicSERPAdvanced, 'get-baidu-organic-serp-html': baidu_2.getBaiduOrganicSERPHTML }, 'naver': { 'get-naver-organic-serp-regular': naver_1.getNaverOrganicSERPRegular, 'get-naver-organic-serp-advanced': naver_1.getNaverOrganicSERPAdvanced, 'get-naver-organic-serp-html': naver_1.getNaverOrganicSERPHTML }, 'seznam': { 'get-seznam-organic-serp-regular': seznam_2.getSeznamOrganicSERPRegular, 'get-seznam-organic-serp-advanced': seznam_2.getSeznamOrganicSERPAdvanced, 'get-seznam-organic-serp-html': seznam_2.getSeznamOrganicSERPHTML } }; 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.DataForSeoSerpApi = DataForSeoSerpApi; //# sourceMappingURL=DataForSeoSerpApi.node.js.map