# X (Twitter) Boolean Search Scraper | Posts & Trends (`scraping_solutions/x-twitter-boolean-search-scraper-posts-trends`) Actor

Search public X posts with AND, OR, NOT, exact phrases, hashtags, dates, media, language, engagement, and verified-author filters. Deduplicated results stream to JSON, CSV, Excel, or API.

- **URL**: https://apify.com/scraping\_solutions/x-twitter-boolean-search-scraper-posts-trends.md
- **Developed by:** [Scraping Solutions](https://apify.com/scraping_solutions) (community)
- **Stats:** 2 total users, 1 monthly users, 94.4% runs succeeded, 0 bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

from $0.26 / 1,000 matching x posts

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## X (Twitter) Boolean Search Scraper | Posts & Trends

Find public X posts with one precise Boolean query. Combine keywords, hashtags, exact phrases, `AND`, `OR`, `NOT`, parentheses, dates, language, media type, engagement thresholds, and author filters without managing cookies or a developer account.

The Actor validates your expression, creates a safe search plan, discovers candidate posts, checks the complete Boolean logic locally with Unicode-aware whole-term matching, removes duplicates, and streams matching rows to the dataset.

### What You Can Do

- Monitor brands, products, executives, competitors, or events.
- Find purchase intent, complaints, feature requests, and campaign conversations.
- Compare alternative names, spellings, hashtags, and phrases in one run.
- Exclude job posts, giveaways, spam terms, or unrelated meanings.
- Keep only recent, popular, verified, image, video, reply, or original posts.
- Export structured results to JSON, CSV, Excel, XML, RSS, or the Apify API.

### Boolean Search

Supported syntax:

| Operator | Meaning | Example |
|---|---|---|
| `AND` | Both expressions must match | `OpenAI AND agents` |
| `OR` | Either expression may match | `OpenAI OR Anthropic` |
| `NOT` | Exclude a matching expression | `AI AND NOT hiring` |
| `"..."` | Exact phrase | `"artificial intelligence"` |
| `( ... )` | Control precedence | `(OpenAI OR Anthropic) AND agents` |
| `#hashtag` | Match an exact hashtag | `#AI OR #MachineLearning` |

Terms use complete Unicode word boundaries. A query for `IA` matches the standalone term `IA`, but not `tia`, `viaje`, or `diario`. Matching is case-insensitive and accent-insensitive.

Validate and explain an expression before a paid run with the free [FlujoDato Boolean Search Validator](https://flujodato.com/en/boolean-search-validator?platform=x).

### Input Example

```json
{
  "searchQuery": "(OpenAI OR Anthropic) AND (agents OR automation) AND NOT hiring",
  "resultsLimit": 100,
  "searchSection": "latest",
  "searchCoverage": "efficient",
  "contentType": "all",
  "language": "en",
  "oldestPostDate": "",
  "newestPostDate": "",
  "minimumViews": 0,
  "minimumLikes": 5,
  "minimumReposts": 0,
  "minimumReplies": 0,
  "minimumQuotes": 0,
  "minimumBookmarks": 0,
  "verifiedAuthorsOnly": false,
  "excludeReplies": false,
  "excludeReposts": true,
  "strictBooleanSyntax": false
}
```

### Input Fields

| Field | Description | Default |
|---|---|---|
| `searchQuery` | Keyword, hashtag, phrase, or Boolean expression | Example query |
| `resultsLimit` | Maximum unique matching posts saved | `100` |
| `searchSection` | `latest` or `top` ranking | `latest` |
| `searchCoverage` | `efficient` scans up to 3x; `comprehensive` scans up to 6x and adds exact-term and hashtag variants that preserve the Boolean condition | `efficient` |
| `contentType` | All, text, media, images, or videos | `all` |
| `language` | All languages or one supported language | `all` |
| `oldestPostDate` | Inclusive start date | Empty |
| `newestPostDate` | Inclusive end date | Empty |
| `minimumViews` | Minimum reported views | `0` |
| `minimumLikes` | Minimum likes | `0` |
| `minimumReposts` | Minimum reposts | `0` |
| `minimumReplies` | Minimum replies | `0` |
| `minimumQuotes` | Minimum quote posts | `0` |
| `minimumBookmarks` | Minimum reported bookmarks | `0` |
| `verifiedAuthorsOnly` | Keep verified authors only | `false` |
| `excludeReplies` | Remove replies | `false` |
| `excludeReposts` | Remove reposts | `false` |
| `strictBooleanSyntax` | Require explicit operators | `false` |

### Output Example

```json
{
  "query": "OpenAI AND AI",
  "normalizedQuery": "OpenAI AND AI",
  "matchedTerms": ["OpenAI", "AI"],
  "discoveryQuery": "OpenAI AI",
  "searchSection": "latest",
  "tweetId": "1234567890123456789",
  "url": "https://x.com/example/status/1234567890123456789",
  "text": "A new OpenAI release for practical AI agents.",
  "hashtags": ["#AI"],
  "publishedAt": "2026-09-07T12:00:00Z",
  "language": "en",
  "contentType": "text",
  "mediaUrls": [],
  "videoUrls": [],
  "likeCount": 42,
  "repostCount": 7,
  "replyCount": 3,
  "quoteCount": 1,
  "viewCount": 2500,
  "bookmarkCount": 4,
  "isReply": false,
  "isRepost": false,
  "isQuote": false,
  "authorUsername": "example",
  "authorName": "Example",
  "authorProfileUrl": "https://x.com/example",
  "authorVerified": true,
  "authorFollowerCount": 12500,
  "scrapedAt": "2026-09-07T12:01:00Z"
}
```

Every row represents one unique matching post. Numeric zero values remain `0`. Optional unavailable values are returned as `null` or empty arrays according to their type.

### Pricing And Search Coverage

`resultsLimit` is a maximum, not a guarantee. Search feeds are ranked, can repeat posts across pages, and can end before the requested count.

- **Efficient** can inspect up to 3 times the requested result limit.
- **Comprehensive** can inspect up to 6 times the requested result limit for restrictive queries.
- When an end date is set, Efficient can use up to 0.5 successful pages per requested result and Comprehensive up to 1 page per result, shared across the complete search plan.
- Restrictive `AND`, `NOT`, date, media, author, or engagement filters may return fewer results.
- A successful page containing new candidate posts is charged even if local filters reject every candidate.
- Failed requests, retries, empty pages, and pages containing only previously seen posts are not charged.
- Each saved dataset item is charged once. Duplicate posts are never saved or charged as results.

The start date is sent to the upstream search, while the end date is verified locally. Boolean-qualified posts rejected only by the end date or another local filter keep that source active so historical pagination is not stopped as irrelevant.

Before discovery begins, the Actor estimates the maximum result and page charges required by the plan. If the run can afford at least one successful page and one result, it can start in partial mode, stream affordable output, and stop safely when the charge limit is reached. A run is rejected before provider use only when it cannot fund that minimum useful operation.

### Reliability

- Results are streamed after every completed page, so partial output survives an interrupted run.
- Stable post IDs prevent duplicate result billing.
- Temporary network, rate-limit, and server failures retry after 4, 16, and 64 seconds.
- Repeated cursors and duplicate-only pagination cycles stop automatically.
- Live progress is available in `RUN_PROGRESS`; the final counters are stored in `RUN_SUMMARY`.
- Credentials, endpoints, provider payloads, and pagination tokens are never written to the dataset or logs.

### Tips For Better Results

1. Start with 25 to 100 results in Efficient mode.
2. Test each positive term separately if a complex query returns few matches.
3. Add engagement filters gradually; high thresholds can remove most candidates.
4. Use Latest for monitoring and Top for research on prominent conversations.
5. Switch to Comprehensive only when the first sample confirms that the query is useful.

### Responsible Use

Use only public data and follow applicable laws, privacy requirements, platform terms, and your organization's data retention policies. Do not use the Actor for harassment, surveillance, discrimination, or collection of sensitive personal data.

### Support

For reproducible support, share the Actor run ID, input with secrets removed, expected behavior, and the relevant log lines. Do not send API keys or private credentials.

# Actor input Schema

## `searchQuery` (type: `string`):

Examples: OpenAI; #AI; (OpenAI OR Anthropic) AND agents AND NOT hiring. Quoted phrases stay exact, and terms use complete word boundaries, so IA does not match tia, viaje, or diario. [Validate the query before running](https://flujodato.com/en/boolean-search-validator?platform=x).

## `resultsLimit` (type: `integer`):

Maximum number of unique posts saved after all filters. This is a limit, not a guaranteed count, because search feeds can end or repeat posts.

## `searchSection` (type: `string`):

Latest prioritizes recent posts. Top prioritizes posts ranked as relevant or popular.

## `searchCoverage` (type: `string`):

Without an end-date filter, Efficient can scan up to 3x the requested result count and Comprehensive up to 6x. When Only content posted before is set, the page allowance becomes the exploration guardrail: up to 0.5 successful paid pages per requested result in Efficient and 1 page per result in Comprehensive, shared across the full plan. More successful pages can increase cost.

## `contentType` (type: `string`):

Return all posts or keep only plain text, any media, images, or videos.

## `language` (type: `string`):

Keep posts in one reported language or search all languages.

## `oldestPostDate` (type: `string`):

Optional inclusive start date in YYYY-MM-DD format. This lower boundary is sent to the upstream X search on the initial request.

## `newestPostDate` (type: `string`):

Optional inclusive end date in YYYY-MM-DD format. This upper boundary is validated locally, so historical searches may require additional paid pages. Use the same date in both fields for one calendar day.

## `minimumViews` (type: `integer`):

Save only posts with at least this many reported views. Use 0 to disable.

## `minimumLikes` (type: `integer`):

Save only posts with at least this many likes. Use 0 to disable.

## `minimumReposts` (type: `integer`):

Save only posts with at least this many reposts. Use 0 to disable.

## `minimumReplies` (type: `integer`):

Save only posts with at least this many replies. Use 0 to disable.

## `minimumQuotes` (type: `integer`):

Save only posts with at least this many quote posts. Use 0 to disable.

## `minimumBookmarks` (type: `integer`):

Save only posts with at least this many reported bookmarks. Use 0 to disable.

## `verifiedAuthorsOnly` (type: `boolean`):

Keep only posts whose author is reported as verified.

## `excludeReplies` (type: `boolean`):

Remove posts that are replies to another post.

## `excludeReposts` (type: `boolean`):

Remove reposts and keep original or quoted posts.

## `strictBooleanSyntax` (type: `boolean`):

Reject adjacent expressions without AND. Leave disabled to insert AND automatically and report a warning.

## Actor input object example

```json
{
  "searchQuery": "(OpenAI OR Anthropic) AND agents AND NOT hiring",
  "resultsLimit": 100,
  "searchSection": "latest",
  "searchCoverage": "efficient",
  "contentType": "all",
  "language": "all",
  "oldestPostDate": "",
  "newestPostDate": "",
  "minimumViews": 0,
  "minimumLikes": 0,
  "minimumReposts": 0,
  "minimumReplies": 0,
  "minimumQuotes": 0,
  "minimumBookmarks": 0,
  "verifiedAuthorsOnly": false,
  "excludeReplies": false,
  "excludeReposts": false,
  "strictBooleanSyntax": false
}
```

# Actor output Schema

## `results` (type: `string`):

All unique matching posts in the default dataset.

## `overview` (type: `string`):

Readable table with post, author, engagement, media, and Boolean match fields.

## `searchPlan` (type: `string`):

Normalized query, diagnostics, generated searches, and budget preflight.

## `runSummary` (type: `string`):

Final scanned, matched, filtered, duplicate, provider request, and charged event counts.

## `runProgress` (type: `string`):

Latest completed-page counters retained if a long run is stopped.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {};

// Run the Actor and wait for it to finish
const run = await client.actor("scraping_solutions/x-twitter-boolean-search-scraper-posts-trends").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {}

# Run the Actor and wait for it to finish
run = client.actor("scraping_solutions/x-twitter-boolean-search-scraper-posts-trends").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{}' |
apify call scraping_solutions/x-twitter-boolean-search-scraper-posts-trends --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,scraping_solutions/x-twitter-boolean-search-scraper-posts-trends"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/G5R1xdxqbdcWDWaEl/builds/cb3YIJRDDP58qfKcX/openapi.json
