# X (Twitter) Search & Discovery Scraper (`nexascout/nexascout-x-search-discovery`) Actor

Search public X posts by keyword or query with the official X API. Export normalized posts, authors, timestamps, engagement metrics, media, deduplication, and query provenance. Bring your own X API Bearer Token.

- **URL**: https://apify.com/nexascout/nexascout-x-search-discovery.md
- **Developed by:** [NexaScout](https://apify.com/nexascout) (community)
- **Categories:** Social media, Developer tools, Automation
- **Stats:** 2 total users, 1 monthly users, 0.0% runs succeeded, 1 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 x post results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
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.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## 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.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## X (Twitter) Search & Discovery Scraper

Search public X posts with the official X API v2 and export clean, normalized records for research, monitoring, analytics, and downstream automation.

### What this Actor does

- Searches public X posts using one or more short queries.
- Supports recent search and full-archive search when your X developer access allows it.
- Normalizes post text, author data, timestamps, engagement metrics, media, conversation IDs, and quote/reply relationships.
- Deduplicates overlapping results across queries while preserving query provenance.
- Applies optional language and engagement filters.
- Keeps strict caps on items, pages, retries, and runtime so costs are easier to control.
- Uses your own X Developer Bearer Token.

### Bring your own X API token

Live X access uses a **BYOT (bring your own token)** model.

Enter your X Developer **Bearer Token** in the `bearerToken` field. The field is marked as a secret input, so Apify encrypts it before storing the run input.

Important:

- X API usage is billed by X to the developer account that issued the token.
- Store users never use a NexaScout X credential.
- The Actor does not fall back to an owner-level X token.
- Live requests are locked to the official X API host.
- The token is not written to the dataset or run summary.

### Quick start

Use a small recent-search run first:

```json
{
  "queries": [
    "\"manual process\" automation",
    "\"copy paste\" workflow"
  ],
  "bearerToken": "YOUR_X_BEARER_TOKEN",
  "searchMode": "recent",
  "maxItems": 25,
  "maxItemsPerQuery": 15,
  "maxPagesPerQuery": 1
}
```

### Main inputs

#### `queries`

One or more X search queries. Short, focused queries usually produce cleaner research data than one very broad query.

Examples:

- `"manual process" automation`
- `Shopify "spreadsheet" inventory`
- `CRM "manual data entry"`
- `"real estate" "takes hours"`

#### `bearerToken`

Your X Developer Bearer Token. Required for live X collection.

#### `searchMode`

- `recent` — uses X recent search.
- `all` — requests full-archive search. Your X developer project must have access to that endpoint.

#### Cost-control inputs

Use `maxItems`, `maxItemsPerQuery`, `maxPagesPerQuery`, `maxRetries`, and `maxRuntimeSec` to keep runs bounded.

### Output

Each dataset row represents one normalized public X post. Common fields include:

- `postId`
- `url`
- `authorId`, `authorHandle`, `authorName`
- `text`
- `lang`
- `createdAt`
- engagement metrics
- `conversationId`
- `inReplyToId`
- quote/retweet indicators
- `matchedQueries`
- `searchQuery`

The run also stores a `RUN_SUMMARY` record with query-level counts, retries, rate-limit hits, warnings, and totals.

### Good use cases

- Brand and product mention monitoring
- Competitive research
- Market and category research
- Customer pain-point discovery
- Lead-signal discovery
- Trend and conversation discovery
- Building a normalized X data layer for agents or automations

### Pricing

Apify Store charges for the Actor are separate from X API charges.

Your X Developer account is responsible for X API usage generated by your token. Check current X API pricing and limits in your X Developer Console before large runs.

### Limitations

- Only data returned by the official X API is available.
- Protected, unavailable, deleted, or otherwise inaccessible posts are not returned.
- Full-archive search depends on the capabilities of your X developer project.
- X rate limits and product limits still apply.
- This Actor does not automate login, posting, liking, following, or other engagement actions.

This Actor is not affiliated with X Corp.

# Changelog

This Actor's version history is a separate document: https://apify.com/nexascout/nexascout-x-search-discovery/changelog.md

# Actor input Schema

## `queries` (type: `array`):

Short independent X search queries.

## `bearerToken` (type: `string`):

Bring your own X Developer API Bearer Token for live X access. Apify encrypts this secret before storing run input. X API usage and charges apply to your own X Developer account. NexaScout does not use its X token for public/Store runs.

## `adapter` (type: `string`):

Use x-api for real X data. mock returns synthetic deterministic data and is intended only for testing.

## `searchMode` (type: `string`):

recent covers the recent search window; all requests full archive.

## `adapterConfig` (type: `object`):

Advanced/testing settings only. For live x-api runs the endpoint is locked to the official X API. Never place credentials in this object; use the encrypted bearerToken field.

## `maxItems` (type: `integer`):

Hard cap.

## `maxItemsPerQuery` (type: `integer`):

Per-query cap.

## `maxPagesPerQuery` (type: `integer`):

Pagination cap.

## `interQueryDelaySec` (type: `integer`):

Seconds between queries.

## `startTime` (type: `string`):

ISO-8601 lower bound.

## `endTime` (type: `string`):

ISO-8601 upper bound.

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

Optional language filter.

## `minLikes` (type: `integer`):

Minimum likes.

## `minReplies` (type: `integer`):

Minimum replies.

## `minReposts` (type: `integer`):

Minimum reposts.

## `includeRaw` (type: `boolean`):

Attach raw X API payload.

## `maxRuntimeSec` (type: `integer`):

Runtime cap.

## `maxRetries` (type: `integer`):

Retries for 429/5xx.

## Actor input object example

```json
{
  "queries": [
    "ecommerce spreadsheet"
  ],
  "adapter": "x-api",
  "searchMode": "recent",
  "maxItems": 50,
  "maxItemsPerQuery": 20,
  "maxPagesPerQuery": 2,
  "interQueryDelaySec": 1,
  "includeRaw": false,
  "maxRuntimeSec": 600,
  "maxRetries": 2
}
```

# Actor output Schema

## `posts` (type: `string`):

Normalized public X posts in the default dataset.

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

Query counts, retries, rate-limit hits, warnings, and totals.

# 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 = {
    "queries": [
        "ecommerce spreadsheet"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("nexascout/nexascout-x-search-discovery").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 = { "queries": ["ecommerce spreadsheet"] }

# Run the Actor and wait for it to finish
run = client.actor("nexascout/nexascout-x-search-discovery").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 '{
  "queries": [
    "ecommerce spreadsheet"
  ]
}' |
apify call nexascout/nexascout-x-search-discovery --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,nexascout/nexascout-x-search-discovery"
        }
    }
}
```

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/1a5ihqjquFmyoMNQ9/builds/f7j1HE23S8W0FOUcD/openapi.json
