Skip to content

Commit d801f4d

Browse files
committed
fix: Limitless search functionality and semantic parameters
1 parent 76b5b87 commit d801f4d

File tree

4 files changed

+26
-11
lines changed

4 files changed

+26
-11
lines changed

core/src/BaseExchange.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ export interface MarketFilterParams {
66
offset?: number;
77
sort?: 'volume' | 'liquidity' | 'newest';
88
searchIn?: 'title' | 'description' | 'both'; // Where to search (default: 'title')
9-
}
10-
11-
export interface MarketFetchParams extends MarketFilterParams {
129
query?: string; // For keyword search
1310
slug?: string; // For slug/ticker lookup
11+
page?: number; // For pagination (used by Limitless)
12+
similarityThreshold?: number; // For semantic search (used by Limitless)
1413
}
1514

15+
export interface MarketFetchParams extends MarketFilterParams { }
16+
1617
export interface EventFetchParams {
1718
query?: string; // For keyword search (will be required in practice)
1819
limit?: number;

core/src/exchanges/limitless/fetchMarkets.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { HttpClient, MarketFetcher } from '@limitless-exchange/sdk';
22
import { MarketFetchParams } from '../../BaseExchange';
33
import { UnifiedMarket } from '../../types';
4+
import axios from 'axios';
45
import { LIMITLESS_API_URL, mapMarketToUnified } from './utils';
56
import { limitlessErrorMapper } from './errors';
67

@@ -51,14 +52,18 @@ async function searchMarkets(
5152
query: string,
5253
params?: MarketFetchParams
5354
): Promise<UnifiedMarket[]> {
54-
// SDK doesn't have a search method yet, create a temporary HTTP client
55-
const httpClient = new HttpClient({
56-
baseURL: LIMITLESS_API_URL,
55+
// SDK doesn't have a search method yet, use axios directly
56+
57+
const response = await axios.get(`${LIMITLESS_API_URL}/markets/search`, {
58+
params: {
59+
query: query,
60+
limit: params?.limit || 20,
61+
page: params?.page || 1,
62+
similarityThreshold: params?.similarityThreshold || 0.5
63+
}
5764
});
5865

59-
const response = await httpClient.get('/markets/search?query=' + encodeURIComponent(query) + '&limit=' + (params?.limit || 20));
60-
61-
const rawResults = response?.markets || [];
66+
const rawResults = response?.data?.markets || [];
6267
const allMarkets: UnifiedMarket[] = [];
6368

6469
for (const res of rawResults) {

core/src/exchanges/limitless/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
PredictionMarketExchange,
33
MarketFilterParams,
4+
MarketFetchParams,
45
HistoryFilterParams,
56
ExchangeCredentials,
67
EventFetchParams,
@@ -90,7 +91,7 @@ export class LimitlessExchange extends PredictionMarketExchange {
9091
// Implementation methods for CCXT-style API
9192
// ----------------------------------------------------------------------------
9293

93-
protected async fetchMarketsImpl(params?: MarketFilterParams): Promise<UnifiedMarket[]> {
94+
protected async fetchMarketsImpl(params?: MarketFetchParams): Promise<UnifiedMarket[]> {
9495
// Pass API key if available for authenticated requests
9596
const apiKey = this.auth?.getApiKey();
9697
return fetchMarkets(params, apiKey);

core/src/server/openapi.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ info:
55
A unified local sidecar API for prediction markets (Polymarket, Kalshi).
66
This API acts as a JSON-RPC-style gateway. Each endpoint corresponds to a specific method
77
on the generic exchange implementation.
8-
version: 2.0.0
8+
version: 0.4.4
99

1010
servers:
1111
- url: http://localhost:3847
@@ -956,6 +956,14 @@ components:
956956
searchIn:
957957
type: string
958958
enum: [title, description, both]
959+
query:
960+
type: string
961+
slug:
962+
type: string
963+
page:
964+
type: integer
965+
similarityThreshold:
966+
type: number
959967

960968
EventFetchParams:
961969
type: object

0 commit comments

Comments
 (0)