Search & Discovery API

Full-text and semantic search across your debates and verdicts, with advanced filters and query suggestions.

5 min read
Share

The Search API lets you query your debate history using a combination of keyword matching, full-text search, and semantic vector search. Results are always scoped to the authenticated user's own debates.

Base URL

All endpoints below are relative to https://api.askverdict.ai. All search endpoints require authentication via Authorization: Bearer <your_api_key>.


Endpoints

MethodPathDescription
GET/api/searchSearch debates and verdicts with filters
GET/api/search/suggestionsAutocomplete suggestions from search history
DELETE/api/search/historyClear your personal search history

GET /api/search

GET/api/search

Search your debates using keyword matching, full-text search, and semantic vector similarity. Supports advanced filters for status, mode, date range, confidence score, and verdict presence.

How Search Works

Results are produced in three stages and merged:

  1. Keyword (ILIKE) — Matches question and context fields with a case-insensitive substring scan. Always active.
  2. Full-text (tsvector) — When the search_vector column is populated by Postgres triggers, plainto_tsquery is used to boost and rank results.
  3. Semantic (vector) — Embeddings are generated for your query and compared against stored debate embeddings. Vector-only hits (semantically similar but not keyword-matched) are appended after keyword results.

Pagination and total counts are based on keyword results only — semantic-only additions are appended beyond the normal page boundary.

Query Parameters

NameTypeRequiredDescription
qstringRequiredSearch query. 1–200 characters. Matched against debate question and context.
type"debates" | "verdicts"OptionalFilter by result type. "verdicts" returns only completed debates that have a verdict. Default: "debates".
sort"relevance" | "date" | "popularity"OptionalSort order. "relevance" uses full-text rank + recency. "popularity" sorts by view count. Default: "date".
pageintegerOptionalPage number, 1-indexed. Default: 1.
limitintegerOptionalResults per page. Between 1 and 50. Default: 10.
statusstringOptionalComma-separated status filter. Valid values: pending, running, paused, completed, failed. Example: "completed,failed".
modestringOptionalComma-separated mode filter. Valid values: fast, balanced, thorough. Example: "balanced,thorough".
dateFromstring (ISO 8601)OptionalInclude only debates created on or after this date. Example: "2026-01-01".
dateTostring (ISO 8601)OptionalInclude only debates created on or before this date (end of day inclusive). Example: "2026-02-28".
minConfidencenumber (0–100)OptionalInclude only debates with a verdict confidence at or above this percentage. Example: 70 means confidence >= 0.70.
hasVerdictbooleanOptionalWhen true, return only debates that have a verdict object.

Example Requests

bash
# Basic search
curl "https://api.askverdict.ai/api/search?q=microservices" \
  -H "Authorization: Bearer vrd_your_api_key"
 
# Filter to completed debates with high confidence, sorted by relevance
curl "https://api.askverdict.ai/api/search?q=infrastructure+migration&type=verdicts&sort=relevance&status=completed&minConfidence=75&page=1&limit=20" \
  -H "Authorization: Bearer vrd_your_api_key"
 
# Date-range filter for Q1 2026
curl "https://api.askverdict.ai/api/search?q=build+vs+buy&dateFrom=2026-01-01&dateTo=2026-03-31" \
  -H "Authorization: Bearer vrd_your_api_key"

Response

relevanceScore

relevanceScore is a float between 0 and 1 computed by Postgres ts_rank when full-text indexes are available. For ILIKE-only matches it is null. Semantic-only additions (appended after keyword results) also have relevanceScore: null.

Search Result Object

FieldTypeDescription
idstringDebate UUID
questionstringThe debate question
statusstringDebate lifecycle status
modestring | nullDebate mode (fast / balanced / thorough)
createdAtstring (ISO 8601)When the debate was created
completedAtstring | nullWhen the debate completed, or null
recommendationstring | nullVerdict recommendation — null if no verdict yet
oneLinerstring | nullOne-line verdict summary — null if no verdict yet
confidencenumber | nullVerdict confidence between 0 and 1
relevanceScorenumber | nullFull-text relevance score (0–1). Null for ILIKE or semantic-only matches

Error Responses

StatusCodeDescription
400VALIDATION_ERRORQuery string validation failed — details in error.details
401UNAUTHORIZEDMissing or invalid API key

GET /api/search/suggestions

GET/api/search/suggestions

Return autocomplete suggestions based on the authenticated user's previous search history and debate questions. Useful for implementing a live search-as-you-type dropdown.

Query Parameters

NameTypeRequiredDescription
qstringOptionalPartial query string to match against. If omitted, returns recent searches.

Example Requests

bash
curl "https://api.askverdict.ai/api/search/suggestions?q=micro" \
  -H "Authorization: Bearer vrd_your_api_key"

Response


DELETE /api/search/history

DELETE/api/search/history

Clear the authenticated user's entire search history. Suggestions will no longer be influenced by past queries.

Example Request

bash
curl -X DELETE "https://api.askverdict.ai/api/search/history" \
  -H "Authorization: Bearer vrd_your_api_key"

Response


Advanced Filtering Tips

Combining filters

All advanced filters are combined with AND logic. For example, status=completed&minConfidence=80&mode=thorough returns only completed thorough debates with confidence ≥ 80%.

Filter Examples

GoalQuery string
Find all failed debates?q=...&status=failed
Completed fast debates only?q=...&status=completed&mode=fast
High-confidence verdicts this month?q=...&type=verdicts&minConfidence=80&dateFrom=2026-02-01
Debates with any verdict?q=...&hasVerdict=true
Multiple modes?q=...&mode=balanced,thorough

Pagination

The API returns total (total keyword matches) and totalPages. Iterate with page=1, page=2, etc. using the same query string:

bash
# Page 2 of results
curl "https://api.askverdict.ai/api/search?q=strategy&page=2&limit=10" \
  -H "Authorization: Bearer vrd_your_api_key"

Was this page helpful?