Search API

Search for events and markets

Search API

The Search API provides full-text search across events by title or ticker.

Access

from dflow import DFlowClient
 
client = DFlowClient()
search_api = client.search

Methods

Search for events with nested markets.

def search(
    query: str,
    sort: SortField | None = None,
    order: SortOrder | None = None,
    limit: int | None = None,
    cursor: int | None = None,
    with_nested_markets: bool | None = None,
    with_market_accounts: bool | None = None,
    status: MarketStatus | None = None,
    entity_type: SearchEntityType | None = None,
) -> SearchResult

Parameters

ParameterTypeDescription
querystrSearch query string (required)
sortstr | NoneSort field: "volume", "volume_24h", "liquidity", "open_interest", "start_date"
orderstr | NoneSort order: "asc", "desc"
limitint | NoneMaximum number of results
cursorint | NonePagination cursor
with_nested_marketsbool | NoneInclude nested markets in response
with_market_accountsbool | NoneInclude market account information
statusstr | NoneFilter by status
entity_typestr | NoneType of entity: "events", "markets", "series"

Example

# Basic search
results = client.search.search(query="bitcoin")
print(f"Found {len(results.events)} events")
 
# Search with sorting and pagination
results = client.search.search(
    query="election",
    sort="volume",
    order="desc",
    limit=20,
)
 
# Include nested markets with account info
results = client.search.search(
    query="sports",
    with_nested_markets=True,
    with_market_accounts=True,
)
 
for event in results.events:
    print(f"{event.title}")
    if event.markets:
        for market in event.markets:
            print(f"  - {market.title}: YES={market.yes_ask}")
 
# Paginate through results
if results.cursor:
    next_page = client.search.search(query="bitcoin", cursor=results.cursor)

Types

SearchResult

class SearchResult(BaseModel):
    cursor: int
    events: list[Event]

On this page