export type GetApiTinyfishSearchArgs = {query: string, purpose?: string | undefined, location?: string | undefined, language?: string | undefined, include_domains?: string | undefined, exclude_domains?: string | undefined, domain_type?: string | undefined, after_date?: string | undefined, before_date?: string | undefined, recency_minutes?: number | undefined, pub_year_min?: number | undefined, pub_year_max?: number | undefined, page?: number | undefined, include_thumbnail?: string | undefined}; export type GetApiTinyfishSearchOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Search the web and get structured results. Returns ranked results with titles, snippets, and URLs. Supports location/language targeting, domain include/exclude filters, date range filters, and search types (web, news, research_paper). * * GET /tinyfish-search/ */ export const getApiTinyfishSearch = async (args: GetApiTinyfishSearchArgs, options?: GetApiTinyfishSearchOptions) => { const {baseUrl = "https://api.orthogonal.com/mpp", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.query != null) query.append("query", String(args.query)) if (args.purpose != null) query.append("purpose", String(args.purpose)) if (args.location != null) query.append("location", String(args.location)) if (args.language != null) query.append("language", String(args.language)) if (args.include_domains != null) query.append("include_domains", String(args.include_domains)) if (args.exclude_domains != null) query.append("exclude_domains", String(args.exclude_domains)) if (args.domain_type != null) query.append("domain_type", String(args.domain_type)) if (args.after_date != null) query.append("after_date", String(args.after_date)) if (args.before_date != null) query.append("before_date", String(args.before_date)) if (args.recency_minutes != null) query.append("recency_minutes", String(args.recency_minutes)) if (args.pub_year_min != null) query.append("pub_year_min", String(args.pub_year_min)) if (args.pub_year_max != null) query.append("pub_year_max", String(args.pub_year_max)) if (args.page != null) query.append("page", String(args.page)) if (args.include_thumbnail != null) query.append("include_thumbnail", String(args.include_thumbnail)) const url = `${baseUrl.replace(/\/+$/, '')}/tinyfish-search/${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };