> ## Documentation Index
> Fetch the complete documentation index at: https://docs.anysite.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Twitter Node

> Extract Twitter/X data with the Anysite Twitter node for n8n workflows

## Overview

The Anysite Twitter node enables you to extract Twitter (X) data within your n8n workflows. Search tweets, analyze user profiles, monitor hashtags, and track social media conversations.

## Node Configuration

### Authentication

<ParamField path="credential" type="Anysite API Credentials" required>
  Select your Anysite API credentials from the dropdown or create new ones.
</ParamField>

### Available Operations

<Tabs>
  <Tab title="Search Users">
    Search for Twitter users by username, bio, or other criteria.

    **Parameters:**

    * **Query** (required): Search terms for finding users
    * **Result Type**: "recent", "popular", or "mixed"
    * **Limit**: Maximum results to return (1-100)

    **Example Output:**

    ```json theme={null}
    {
      "users": [
        {
          "id": "twitter123",
          "username": "johnsmith_dev",
          "displayName": "John Smith",
          "bio": "Senior Software Engineer | Python enthusiast",
          "followers": 15000,
          "following": 800,
          "verified": false,
          "location": "San Francisco, CA",
          "profileImageUrl": "https://pbs.twimg.com/profile_images/..."
        }
      ]
    }
    ```
  </Tab>

  <Tab title="Get User Posts">
    Extract tweets and posts from a specific Twitter user.

    **Parameters:**

    * **Username** (required): Twitter username (without @)
    * **Tweet Count**: Number of tweets to retrieve (1-100)
    * **Include Replies**: Whether to include reply tweets
    * **Include Retweets**: Whether to include retweets

    **Example Output:**

    ```json theme={null}
    {
      "tweets": [
        {
          "id": "tweet456",
          "text": "Just shipped a new feature! Excited to see how users respond 🚀",
          "createdAt": "2024-08-26T14:30:00Z",
          "engagement": {
            "likes": 125,
            "retweets": 32,
            "replies": 18,
            "views": 2500
          },
          "mediaUrls": [],
          "hashtags": ["#ProductLaunch", "#TechStartup"]
        }
      ]
    }
    ```
  </Tab>

  <Tab title="Search Tweets">
    Search for tweets by keywords, hashtags, or phrases.

    **Parameters:**

    * **Query** (required): Search query (supports operators)
    * **Result Type**: "recent", "popular", or "mixed"
    * **Language**: Language filter (optional)
    * **Date Range**: Time period to search within

    **Example Output:**

    ```json theme={null}
    {
      "tweets": [
        {
          "id": "search789",
          "text": "The future of AI development is looking incredible! #AI #MachineLearning",
          "author": {
            "username": "ai_researcher",
            "displayName": "Dr. Sarah Wilson"
          },
          "createdAt": "2024-08-26T12:00:00Z",
          "engagement": {
            "likes": 89,
            "retweets": 24,
            "replies": 12
          }
        }
      ]
    }
    ```
  </Tab>

  <Tab title="Get Tweet Details">
    Get detailed information about a specific tweet.

    **Parameters:**

    * **Tweet ID** (required): Twitter tweet identifier
    * **Include Thread**: Whether to include tweet thread context

    **Example Output:**

    ```json theme={null}
    {
      "tweet": {
        "id": "tweet123",
        "text": "Thread about building scalable APIs: 1/8",
        "author": {
          "username": "backend_expert",
          "followers": 25000
        },
        "engagement": {
          "likes": 245,
          "retweets": 89,
          "replies": 34
        },
        "threadTweets": [
          {
            "id": "tweet124",
            "text": "First, consider your data architecture..."
          }
        ]
      }
    }
    ```
  </Tab>
</Tabs>

## Workflow Examples

### Social Media Monitoring

<Steps>
  <Step title="Monitor Brand Mentions">
    Search for tweets mentioning your brand, product, or competitors.
  </Step>

  <Step title="Analyze Sentiment">
    Use AI nodes to analyze sentiment and categorize mentions as positive, negative, or neutral.
  </Step>

  <Step title="Identify Influencers">
    Find high-engagement users mentioning your brand and assess their influence.
  </Step>

  <Step title="Alert Team">
    Send notifications to your social media team for important mentions or negative sentiment.
  </Step>
</Steps>

**Example Workflow:**

```json theme={null}
{
  "nodes": [
    {
      "name": "Monitor Brand",
      "type": "@horizondatawave/n8n-nodes-anysite.Twitter",
      "operation": "searchTweets",
      "parameters": {
        "query": "YourBrand OR @YourHandle OR #YourHashtag",
        "resultType": "recent",
        "limit": 100
      }
    },
    {
      "name": "Sentiment Analysis",
      "type": "n8n-nodes-base.openAi",
      "parameters": {
        "operation": "analyze",
        "prompt": "Analyze sentiment: {{ $json.text }}"
      }
    },
    {
      "name": "Filter Negative",
      "type": "n8n-nodes-base.filter",
      "parameters": {
        "conditions": [
          {
            "field": "sentiment",
            "operation": "equal",
            "value": "negative"
          }
        ]
      }
    },
    {
      "name": "Alert Team",
      "type": "n8n-nodes-base.slack",
      "parameters": {
        "channel": "#social-media",
        "text": "🚨 Negative mention detected: {{ $json.text }}"
      }
    }
  ]
}
```

### Influencer Outreach

Find and analyze potential influencer partners:

1. **Search Influencers** - Find users with high engagement in your niche
2. **Analyze Profile** - Check follower count, engagement rate, and content themes
3. **Content Analysis** - Review recent posts for brand alignment
4. **Contact Information** - Extract bio links and contact details
5. **CRM Integration** - Add qualified influencers to your outreach database

### Trend Analysis

Track trending topics and hashtags:

1. **Hashtag Monitoring** - Track specific hashtags relevant to your industry
2. **Engagement Tracking** - Monitor tweet performance and viral content
3. **Competitor Analysis** - See what competitors are posting about
4. **Content Opportunities** - Identify trending topics for your content calendar
5. **Reporting** - Generate weekly trend reports

## Advanced Search Queries

### Search Operators

Use Twitter's advanced search operators:

```javascript theme={null}
// Exact phrase search
{
  "query": "\"artificial intelligence\""
}

// Exclude retweets
{
  "query": "machine learning -RT"
}

// From specific user
{
  "query": "from:elonmusk"
}

// Mentions of user
{
  "query": "@openai"
}

// Multiple hashtags
{
  "query": "#AI #MachineLearning"
}

// Location-based
{
  "query": "startup near:\"San Francisco\""
}

// Date range
{
  "query": "product launch since:2024-08-01 until:2024-08-31"
}
```

### Engagement Filters

Filter by engagement metrics:

```json theme={null}
{
  "name": "High Engagement Filter",
  "type": "n8n-nodes-base.filter",
  "parameters": {
    "conditions": [
      {
        "field": "engagement.likes",
        "operation": "greaterThan",
        "value": 100
      },
      {
        "field": "engagement.retweets", 
        "operation": "greaterThan",
        "value": 20
      }
    ]
  }
}
```

## Error Handling

### Common Errors

<AccordionGroup>
  <Accordion title="Rate Limit Exceeded">
    **Error:** `429 - Too Many Requests`

    **Solution:**

    * Add delay nodes between requests (recommended: 1-2 seconds)
    * Implement retry logic with exponential backoff
    * Consider upgrading your API plan for higher limits
  </Accordion>

  <Accordion title="Tweet Not Found">
    **Error:** `404 - Tweet not found`

    **Solution:**

    * Tweet may have been deleted or made private
    * Verify the tweet ID is correct
    * Handle missing tweets gracefully in your workflow
  </Accordion>

  <Accordion title="User Suspended">
    **Error:** `403 - User account suspended`

    **Solution:**

    * Skip suspended accounts in bulk operations
    * Update your user database to mark suspended accounts
    * Implement error handling to continue workflow
  </Accordion>
</AccordionGroup>

### Retry Configuration

```json theme={null}
{
  "name": "Twitter with Retry",
  "type": "@horizondatawave/n8n-nodes-anysite.Twitter",
  "retryOnFail": true,
  "maxTries": 3,
  "waitBetweenTries": 5000,
  "parameters": {
    "operation": "searchTweets",
    "query": "your search query"
  }
}
```

## Data Processing

### Tweet Analysis

Extract insights from tweet data:

```javascript theme={null}
// Calculate engagement rate
{
  "engagementRate": "={{ ($json.engagement.likes + $json.engagement.retweets + $json.engagement.replies) / $json.engagement.views * 100 }}"
}

// Extract hashtags
{
  "hashtags": "={{ $json.text.match(/#\w+/g) }}"
}

// Check if verified user
{
  "isInfluencer": "={{ $json.author.verified || $json.author.followers > 10000 }}"
}
```

### Content Classification

Use AI to categorize tweets:

```json theme={null}
{
  "name": "Classify Content",
  "type": "n8n-nodes-base.openAi",
  "parameters": {
    "operation": "classify",
    "prompt": "Classify this tweet into categories (Product, Marketing, Support, Other): {{ $json.text }}"
  }
}
```

## Integration Examples

### Google Sheets Export

Export tweet data to spreadsheets:

```json theme={null}
{
  "name": "Export to Sheets",
  "type": "n8n-nodes-base.googleSheets",
  "parameters": {
    "operation": "append",
    "sheetId": "your-sheet-id",
    "values": [
      "={{ $json.author.username }}",
      "={{ $json.text }}",
      "={{ $json.createdAt }}",
      "={{ $json.engagement.likes }}",
      "={{ $json.engagement.retweets }}"
    ]
  }
}
```

### Webhook Notifications

Send real-time alerts:

```json theme={null}
{
  "name": "Webhook Alert",
  "type": "n8n-nodes-base.webhook",
  "parameters": {
    "httpMethod": "POST",
    "responseMode": "onReceived",
    "options": {
      "data": {
        "tweet": "={{ $json.text }}",
        "author": "={{ $json.author.username }}",
        "engagement": "={{ $json.engagement.likes }}"
      }
    }
  }
}
```

## Performance Optimization

### Batch Processing

Process large datasets efficiently:

```json theme={null}
{
  "name": "Process in Batches",
  "type": "n8n-nodes-base.splitInBatches",
  "parameters": {
    "batchSize": 25
  }
}
```

### Caching

Cache frequently accessed data:

```javascript theme={null}
// Store user data in memory
{
  "name": "Cache User Data",
  "type": "n8n-nodes-base.set",
  "parameters": {
    "values": {
      "userCache.{{ $json.username }}": "={{ $json }}"
    }
  }
}
```

## Next Steps

* [LinkedIn Node](/n8n-nodes/linkedin-node) - LinkedIn data extraction
* [Instagram Node](/n8n-nodes/instagram-node) - Instagram content analysis
* [Reddit Node](/n8n-nodes/reddit-node) - Reddit discussion monitoring
* [Workflows](/n8n-nodes/workflows) - Pre-built workflow templates
