From da2f17c7579e823b7ce8b3a261af3637675e9e22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adem=C3=ADlson=20F=2E=20Tonato?= Date: Wed, 9 Apr 2025 17:24:29 +0100 Subject: [PATCH] feat(api/search): add search endpoint and update request limits - Introduced a new POST endpoint for searching with a query and limit - Updated the maximum limit for search results from 20 to 50 in the request schema - Adjusted the default number of results in the Google search function from 7 to 5 --- apps/api/requests.http | 11 +++++++++++ apps/api/src/controllers/v1/types.ts | 2 +- apps/api/src/search/googlesearch.ts | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/apps/api/requests.http b/apps/api/requests.http index 4c69d011..2ef8bb37 100644 --- a/apps/api/requests.http +++ b/apps/api/requests.http @@ -120,3 +120,14 @@ content-type: application/json GET {{baseUrl}}/v1/llmstxt/{{generateLlmsTxtId}} HTTP/1.1 Authorization: Bearer {{$dotenv TEST_API_KEY}} + +### Search +# @name search +POST {{baseUrl}}/v1/search HTTP/1.1 +Authorization: Bearer {{$dotenv TEST_API_KEY}} +content-type: application/json + +{ + "query": "firecrawl", + "limit": 50 +} diff --git a/apps/api/src/controllers/v1/types.ts b/apps/api/src/controllers/v1/types.ts index ea46768f..a85ef2cd 100644 --- a/apps/api/src/controllers/v1/types.ts +++ b/apps/api/src/controllers/v1/types.ts @@ -969,7 +969,7 @@ export const searchRequestSchema = z .positive() .finite() .safe() - .max(20) + .max(50) .optional() .default(5), tbs: z.string().optional(), diff --git a/apps/api/src/search/googlesearch.ts b/apps/api/src/search/googlesearch.ts index 8e6eade0..f4f924ea 100644 --- a/apps/api/src/search/googlesearch.ts +++ b/apps/api/src/search/googlesearch.ts @@ -70,7 +70,7 @@ async function _req( export async function googleSearch( term: string, advanced = false, - num_results = 7, + num_results = 5, tbs = undefined as string | undefined, filter = undefined as string | undefined, lang = "en",