> For the complete documentation index, see [llms.txt](https://university.mindstudio.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://university.mindstudio.ai/building-ai-agents/blocks-reference/search-x-posts.md).

# Search X Posts

Search for posts on X by keyword in a MindStudio workflow

{% embed url="<https://www.youtube.com/embed/bOZ2-hWYucs>" %}

## Configuration

### Search Query

Enter the text or keyword phrase you want to search for. You can include variables (e.g., `{{user_input}}`) to make the query dynamic.

**Example:**\
`"fact checking"`

`{{topic}} AND ("AI" OR "machine learning")`

> **Note:** You may include [X advanced search operators](https://developer.twitter.com/en/docs/twitter-api/tweets/search/integrate/build-a-query).

***

### Max Results

Set the maximum number of posts to retrieve. This can range from 10 to 100. Use the slider or type in a number.

***

### After Date *(Optional)*

Return only posts made after a specific date/time. Accepts relative expressions using `{{dateSubtract}}`, `{{currentDate}}`, or static ISO timestamps.

**Example:**

`{{dateSubtract currentDate 3 "days"}}`

This would fetch posts from the last 3 days.

***

### Before Date *(Optional)*

Return only posts made before a specific date/time. Use ISO format (`YYYY-MM-DD HH:mm:ss`).

**Example:**

`2025-07-01 00:00:00`

***

### Output Variable

Specify the variable name where the results will be saved. This variable can be used in later blocks.

**Example:**

`genAIReporting` or `Xpost_results`

## Sample Output

```json
{
  "data": [
    {
      "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "text": "RT @example: Sample tweet text about a topic.",
      "author_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "edit_history_tweet_ids": [
        "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
      ]
    },
    {
      "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "text": "RT @example: Sample tweet text about indie games.",
      "author_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "edit_history_tweet_ids": [
        "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
      ]
    }
  ],
  "meta": {
    "newest_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "oldest_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "result_count": 2,
    "next_token": "example-token-string"
  }
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://university.mindstudio.ai/building-ai-agents/blocks-reference/search-x-posts.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
