Skip to content

Commit 7416faa

Browse files
author
FalkWolsky
committed
Adding SerpAPI Google Search
1 parent ca5d1e2 commit 7416faa

File tree

5 files changed

+460
-269
lines changed

5 files changed

+460
-269
lines changed

server/node-service/src/plugins/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import supabaseApiPlugin from "./supabaseApi";
4141
import firebirdsqlPlugin from "./firebirdsql";
4242
import apiTemplatePlugin from "./apiTemplate";
4343
import uiPathPlugin from "./uiPath";
44+
import serpApiPlugin from "./serpApi"
4445
// import boomiPlugin from "./boomi";
4546

4647
let plugins: (DataSourcePlugin | DataSourcePluginFactory)[] = [
@@ -109,6 +110,9 @@ let plugins: (DataSourcePlugin | DataSourcePluginFactory)[] = [
109110
stripePlugin,
110111
shopifyPlugin,
111112
wooCommercePlugin,
113+
114+
// Webscrapers
115+
serpApiPlugin
112116
];
113117

114118
try {
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import _ from "lodash";
2+
import { OpenAPIV3, OpenAPI } from "openapi-types";
3+
import { ConfigToType, DataSourcePlugin } from "lowcoder-sdk/dataSource";
4+
import { runOpenApi } from "../openApi";
5+
import { parseOpenApi, ParseOpenApiOptions } from "../openApi/parse";
6+
7+
import spec from './serpApi.search.spec.json';
8+
9+
const dataSourceConfig = {
10+
type: "dataSource",
11+
params: [
12+
{
13+
"type": "groupTitle",
14+
"key": "apikey-query-api_key",
15+
"label": "Api Key Auth"
16+
},
17+
{
18+
"type": "password",
19+
"key": "apikey-query-api_key.value",
20+
"label": "api_key"
21+
}
22+
]
23+
} as const;
24+
25+
const parseOptions: ParseOpenApiOptions = {
26+
actionLabel: (method: string, path: string, operation: OpenAPI.Operation) => {
27+
return _.upperFirst(operation.operationId || "");
28+
},
29+
};
30+
31+
type DataSourceConfigType = ConfigToType<typeof dataSourceConfig>;
32+
33+
const serpApiPlugin: DataSourcePlugin<any, DataSourceConfigType> = {
34+
id: "serpApi",
35+
name: "serpApi",
36+
icon: "serpApi.svg",
37+
category: "Webscrapers",
38+
dataSourceConfig,
39+
queryConfig: async () => {
40+
const { actions, categories } = await parseOpenApi(spec as OpenAPI.Document, parseOptions);
41+
return {
42+
type: "query",
43+
label: "Action",
44+
categories: {
45+
label: "Resources",
46+
items: categories,
47+
},
48+
actions,
49+
};
50+
},
51+
run: function (actionData, dataSourceConfig): Promise<any> {
52+
const runApiDsConfig = {
53+
url: "",
54+
serverURL: "https://serpapi.com",
55+
dynamicParamsConfig: dataSourceConfig,
56+
};
57+
return runOpenApi(actionData, runApiDsConfig, spec as OpenAPIV3.Document);
58+
},
59+
};
60+
61+
export default serpApiPlugin;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy