Skip to main content
All search* and get*ByKeywords methods across every platform accept a query parameter that supports Lucene-style full-text search. This guide covers every operator with practical examples.

Basic syntax

Plain text (OR by default)

Space-separated terms without quotes match posts containing any of the words. A bare space is treated as OR:
AI crypto blockchain
This returns posts containing “AI” or “crypto” or “blockchain”.
Because bare spaces default to OR, always use explicit AND when you need all terms present.

Exact phrases

Wrap terms in double quotes to match the exact phrase:
"machine learning"
"climate change"
"artificial intelligence"
Only posts containing the exact phrase (in that word order) are returned.

Boolean operators

Use AND and OR to combine terms. Operators are case-insensitive (and, AND, And all work).

AND — both terms required

AI AND robotics
"deep learning" AND python
Tesla AND "quarterly earnings"

OR — either term matches

Tesla OR SpaceX
pytorch OR tensorflow
"machine learning" OR "deep learning"

Grouping with parentheses

Combine operators with parentheses for complex queries:
(AI OR ML) AND (healthcare OR medical)
(AI OR "artificial intelligence") AND ethics
("machine learning" OR "deep learning") AND python

Common patterns

Use caseQuery
Brand monitoring"your brand" OR @yourbrand
Competitor comparison(CompanyA OR CompanyB) AND "product launch"
Sentiment on a topic"electric vehicles" AND (love OR hate OR amazing OR terrible)
Industry trends("generative AI" OR "large language models") AND 2025
Job market signals(hiring OR "open role") AND "data scientist"
Academic research"climate change" AND (study OR research OR paper)
Product feedback"your product" AND (bug OR issue OR broken OR love OR amazing)

SDK examples

import { XpozClient, ResponseType } from '@xpoz/xpoz';

const client = new XpozClient({ apiKey: 'your-api-key' });
await client.connect();

// Exact phrase with boolean operators
const results = await client.twitter.searchPosts(
  '("machine learning" OR "deep learning") AND python ',
  {
    startDate: '2025-01-01',
    language: 'en',
    responseType: ResponseType.Fast,
    limit: 50,
    fields: ['id', 'text', 'likeCount', 'authorUsername', 'createdAtDate'],
  }
);

for (const post of results.data) {
  console.log(`@${post.authorUsername}: ${post.text}`);
}

await client.close();
The same query syntax works across all platforms. Platform behavior is consistent, but content differs:
PlatformSearch methods
Twitter/XsearchPosts, getUsersByKeywords
InstagramsearchPosts, getUsersByKeywords
RedditsearchPosts, searchComments, getUsersByKeywords, getSubredditsByKeywords
TikToksearchPosts, getUsersByKeywords

Combining with dedicated parameters

Do not embed platform-specific operators in the query string. Use the dedicated parameters instead:
Instead of…Use parameter
from:elonmuskauthorUsername: "elonmusk" (TS) / author_username="elonmusk" (Python)
lang:enlanguage: "en" (TS) / language="en" (Python)
since:2025-01-01startDate: "2025-01-01" (TS) / start_date="2025-01-01" (Python)
until:2025-06-01endDate: "2025-06-01" (TS) / end_date="2025-06-01" (Python)
const results = await client.twitter.searchPosts(
  '"artificial intelligence" AND ethics',
  {
    startDate: '2025-01-01',
    endDate: '2025-06-01',
    language: 'en',
    fields: ['id', 'text', 'likeCount', 'authorUsername'],
  }
);

Reddit-specific filters

Reddit search methods accept additional parameters for sorting and time filtering:
const results = await client.reddit.searchPosts('python tutorial', {
  subreddit: 'learnpython',
  sort: 'top',
  time: 'month',
  responseType: ResponseType.Fast,
  limit: 25,
});
Reddit sort options: relevance, hot, top, new, comments. Time filters: hour, day, week, month, year, all.

Common mistakes

Forgetting quotes for exact phrases:
  • machine learning matches “machine” OR “learning” (two separate words)
  • "machine learning" matches the exact phrase
Implicit OR behavior:
  • AI blockchain crypto returns posts with ANY of these terms
  • AI AND blockchain AND crypto returns posts with ALL three terms
Nested parentheses:
  • Keep grouping to one level of nesting for best results
  • (A OR B) AND (C OR D) works well
  • Deeply nested queries may produce unexpected results
Empty results:
  • Broaden your date range or remove restrictive filters
  • Try fewer AND conditions
  • Check spelling of exact phrases

Next steps

Response Modes

Choose fast, paging, or CSV for your queries

Field Selection

Reduce response size by selecting specific fields

CSV Exports

Export large result sets to CSV

Best Practices

Optimize queries for performance