export type GetApiMarketsSearchArgs = {query: string, limit?: number | undefined, page?: number | undefined, similarityThreshold?: number | undefined}; export type GetApiMarketsSearchOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Search for markets based on semantic similarity * * GET /markets/search */ export const getApiMarketsSearch = async (args: GetApiMarketsSearchArgs, options?: GetApiMarketsSearchOptions) => { const {baseUrl = "https://api.limitless.exchange", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.query != null) query.append("query", String(args.query)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.page != null) query.append("page", String(args.page)) if (args.similarityThreshold != null) query.append("similarityThreshold", String(args.similarityThreshold)) const url = `${baseUrl.replace(/\/+$/, '')}/markets/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 };