N8N Tools - X (Twitter) Enhanced icon

N8N Tools - X (Twitter) Enhanced

Comprehensive X (Twitter) API v2 integration for N8N workflows

Overview

The "Get User Timeline" operation of the Timelines resource in this node fetches tweets posted by a specified user. It allows retrieving a user's recent tweets with various filtering and pagination options. This is useful for monitoring a user's activity, analyzing tweet content, or aggregating tweets for further processing.

Common scenarios include:

  • Displaying a user's latest tweets on a dashboard.
  • Archiving tweets from specific users for sentiment analysis.
  • Triggering workflows based on new tweets from a user.

For example, you can use this operation to get the last 10 tweets from a user, excluding retweets and replies, within a certain date range.

Properties

Name Meaning
User ID The user identifier or @username whose timeline you want to retrieve.
Max Results Maximum number of tweets to return (1 to 100).
Start Time ISO 8601 formatted start time to filter tweets from (optional).
End Time ISO 8601 formatted end time to filter tweets until (optional).
Since ID Return tweets with IDs greater than this value (optional).
Until ID Return tweets with IDs less than this value (optional).
Pagination Token Token to paginate through results (optional).
Exclude Optionally exclude retweets and/or replies from the results. Possible values: Retweets, Replies.
Include Private Metrics Boolean flag to include private metrics data (requires elevated API access).
Custom Fields Comma-separated list of additional custom fields to include in the response (e.g., tweet fields).
Custom Expansions Comma-separated list of expansions to include additional related objects (e.g., user details).

Output

The output is an array of JSON objects representing tweets from the specified user's timeline. Each item contains detailed tweet data including text, metadata, and optionally expanded related objects depending on the requested custom fields and expansions.

If private metrics are included, additional engagement statistics may be present.

No binary data is output by this operation.

Example output snippet (simplified):

[
  {
    "id": "1234567890",
    "text": "This is a tweet from the user.",
    "created_at": "2024-01-01T12:00:00Z",
    "author_id": "user123",
    "public_metrics": {
      "retweet_count": 5,
      "reply_count": 2,
      "like_count": 10,
      "quote_count": 1
    }
    // Additional fields and expansions as requested
  }
]

Dependencies

  • Requires an active subscription and valid API key for the external service called "N8N Tools API" for validation.
  • Requires Twitter API v2 credentials configured in n8n (OAuth2 or API key).
  • The node uses a bundled Twitter API client library internally to interact with Twitter endpoints.

Troubleshooting

  • Invalid subscription or API key error: If you receive an error about invalid subscription or API key, verify that your N8N Tools API credentials are correct and have an active subscription.
  • Permission errors when including private metrics: Including private metrics requires elevated Twitter API access; ensure your Twitter credentials have the necessary permissions.
  • Pagination issues: When using pagination tokens, ensure tokens are correctly passed between executions to avoid missing or duplicating data.
  • Date format errors: Start Time and End Time must be in valid ISO 8601 format; otherwise, the request will fail.
  • User not found: If the User ID or username is incorrect or does not exist, the API will return an error.

Links and References

Discussion