N8N Tools - X (Twitter) Enhanced icon

N8N Tools - X (Twitter) Enhanced

Comprehensive X (Twitter) API v2 integration for N8N workflows

Overview

The "Search Tweets" operation in this node allows users to search for tweets on the X (formerly Twitter) platform using a flexible query. It supports filtering by time range, tweet IDs, pagination tokens, and can include additional custom fields and expansions. This operation is useful for monitoring specific topics, hashtags, or keywords in real-time or historical data, enabling social media analysis, sentiment tracking, or content aggregation.

Practical examples:

  • Searching for recent tweets mentioning a product launch within the last week.
  • Monitoring tweets containing a hashtag during an event.
  • Collecting tweets from a specific time window for sentiment analysis.

Properties

Name Meaning
Search Query The search query string to find matching tweets.
Max Results Maximum number of tweets to return (1 to 100).
Start Time ISO 8601 formatted start time to filter tweets created after this time.
End Time ISO 8601 formatted end time to filter tweets created before this time.
Since ID Return results with tweet IDs greater than this value (filters newer tweets).
Until ID Return results with tweet IDs less than this value (filters older tweets).
Next Token Token for fetching the next page of results (pagination).
Include Private Metrics Boolean flag to include private metrics in the response (requires elevated API access).
Custom Fields Comma-separated list of additional tweet fields to include in the response.
Custom Expansions Comma-separated list of expansions to include related objects (e.g., user info, media).

Output

The output JSON contains the search results returned by the Twitter API v2 for the given query and parameters. This typically includes:

  • An array of tweet objects matching the search criteria.
  • Metadata about the search such as result counts and pagination tokens.
  • If requested, expanded objects related to tweets (users, media, etc.).
  • Optional private metrics if enabled and permitted.

No binary data is output by this operation.

Dependencies

  • Requires an API key credential for the external "N8N Tools API" service to validate subscription and usage.
  • Uses the Twitter API v2 via an internal helper class to perform the search.
  • Proper OAuth2 or API credentials for Twitter must be configured in n8n to authenticate requests.
  • The node expects network connectivity to both the N8N Tools API and Twitter API endpoints.

Troubleshooting

  • Invalid subscription or API key error: Occurs if the N8N Tools API key is missing, invalid, or expired. Verify your API key and subscription status.
  • Rate limiting or quota exceeded: Twitter API enforces rate limits; exceeding them will cause errors. Implement retry logic or reduce request frequency.
  • Invalid date/time format: Ensure that Start Time and End Time are in valid ISO 8601 format.
  • Missing required parameters: The "Search Query" is mandatory; ensure it is provided.
  • Pagination token issues: Using an invalid or expired nextToken may result in empty or error responses.
  • Private metrics access denied: Enabling private metrics requires elevated Twitter API access; otherwise, omit this option.

Links and References

Discussion