Skip to content

feat: add Xquik as X/Twitter search engine for online research#1308

Open
kriptoburak wants to merge 1 commit intokhoj-ai:masterfrom
kriptoburak:feat/xquik-search-engine
Open

feat: add Xquik as X/Twitter search engine for online research#1308
kriptoburak wants to merge 1 commit intokhoj-ai:masterfrom
kriptoburak:feat/xquik-search-engine

Conversation

@kriptoburak
Copy link
Copy Markdown

@kriptoburak kriptoburak commented Apr 10, 2026

Summary

Adds Xquik as a sixth search engine for Khoj's online research, alongside Serper, Exa, Firecrawl, Google, and SearXNG. Set XQUIK_API_KEY to activate. Returns results in the same {organic: [...]} format - zero changes needed elsewhere.

This adds a social media dimension to research. Currently all five search engines return web pages (articles, docs, blogs). Xquik searches X/Twitter - real-time perspectives, expert opinions, community sentiment, and breaking news that hasn't been written about yet.

Why this is useful

Research questions like "What do developers think about X?" or "What's the reaction to Y?" currently only return web articles. With Xquik, Khoj can now surface the actual discussion happening on X/Twitter - primary sources, not just secondary reporting.

Each result includes:

  • Full tweet text as content (available for extraction/summarization)
  • Engagement metrics (likes, RTs, views) for signal quality
  • A note marking it as social media (so the LLM treats it as opinion, not authoritative fact)

Configuration

# Add to your .env
XQUIK_API_KEY=xk_your_key_here

Get a key at xquik.com. $0.00015 per tweet read.

Xquik is registered as a fallback search engine (appended after existing engines). If Serper/Exa/etc. return results first, Xquik won't be called. To use Xquik as the primary engine, set only XQUIK_API_KEY without other search engine keys.

Changes

1 file changed - src/khoj/processor/tools/online_search.py:

  1. Added XQUIK_API_KEY = os.getenv("XQUIK_API_KEY") constant (line 50)
  2. Added search_with_xquik to the search_engines list when env var is set (line 119)
  3. Added search_with_xquik() async function following the exact same pattern as search_with_exa, search_with_firecrawl, etc.

Pattern compliance

The function follows the exact interface of every other search engine in the file:

async def search_with_xquik(
    query: str, location: LocationData
) -> Tuple[str, Dict[str, List[Dict]]]:
    # Returns: (query, {"organic": [{"title", "link", "snippet", "content"}]})
  • Same signature as search_with_exa, search_with_serper, etc.
  • Same return format: (query, {"organic": [...]})
  • Same error handling: logs error, returns (query, {})
  • Uses aiohttp.ClientSession like all other engines
  • Uses WEBPAGE_REQUEST_TIMEOUT constant
  • No new dependencies

Test plan

  • python -m py_compile src/khoj/processor/tools/online_search.py - syntax valid
  • Function signature matches all other search engines
  • Return format matches expected {"organic": [...]} structure
  • Without XQUIK_API_KEY - behavior 100% unchanged (not added to engine list)
  • API errors caught and logged, returns empty dict (never breaks the research loop)

Built with Claude Code

Adds search_with_xquik as a sixth search engine alongside Serper,
Exa, Firecrawl, Google, and SearXNG. Activates when XQUIK_API_KEY
env var is set. Returns results in the same {organic} format.

Adds real-time social media perspectives (tweets, expert opinions,
community sentiment) to research results — a dimension currently
missing from web-only search engines.
@kriptoburak kriptoburak force-pushed the feat/xquik-search-engine branch from aa09eb2 to a97a412 Compare April 23, 2026 01:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant