N8N Tools - X (Twitter) Enhanced icon

N8N Tools - X (Twitter) Enhanced

Comprehensive X (Twitter) API v2 integration for N8N workflows

Overview

The node provides an enhanced integration with the X (formerly Twitter) API v2, enabling comprehensive interaction with various Twitter resources such as Tweets, Users, Timelines, Media, Spaces, Lists, Bookmarks, Direct Messages, Analytics, and Compliance features. Specifically for the Tweets resource and the Get Tweet operation, the node fetches detailed information about a single tweet by its ID.

This operation is useful when you want to retrieve all available data about a specific tweet, including optional private metrics and custom fields or expansions. For example, marketers can use this to analyze engagement on a particular tweet, developers can fetch tweet details for display in apps, or analysts can gather data for reporting.

Practical example: Given a Tweet ID, the node fetches the tweet's content, author details, public and optionally private engagement metrics, and any additional requested metadata.

Properties

Name Meaning
Tweet ID The unique identifier of the tweet to retrieve.
Include Private Metrics Boolean flag to include private engagement metrics in the response (requires elevated access).
Custom Fields Comma-separated list of additional tweet fields to include in the response.
Custom Expansions Comma-separated list of related objects to expand in the response (e.g., author details).

Output

The output is a JSON object representing the tweet data retrieved from the Twitter API. It includes standard tweet properties such as text content, creation time, author information, and engagement metrics. If "Include Private Metrics" is enabled and the user has elevated access, private metrics like impression counts may also be included.

The structure may also contain expanded objects based on the specified custom expansions, such as user profiles or media attached to the tweet.

No binary data is output by this operation.

Example output snippet (simplified):

{
  "data": {
    "id": "1234567890",
    "text": "Example tweet text",
    "author_id": "0987654321",
    "public_metrics": {
      "retweet_count": 10,
      "reply_count": 5,
      "like_count": 20,
      "quote_count": 2
    },
    "private_metrics": {
      "impression_count": 1000
    }
  },
  "includes": {
    "users": [
      {
        "id": "0987654321",
        "name": "User Name",
        "username": "username"
      }
    ]
  }
}

Dependencies

  • Requires an API key credential for the external N8N Tools API service to validate subscription and usage.
  • Requires OAuth2 or API credentials for authenticating with the Twitter API v2.
  • The node uses an internal helper class to interact with Twitter API endpoints.
  • No additional environment variables are explicitly required beyond configured credentials.

Troubleshooting

  • Invalid subscription or API key error: This occurs if the N8N Tools API key is invalid or lacks proper subscription. Verify your API key and subscription status.
  • Permission errors fetching private metrics: Including private metrics requires elevated Twitter API access. Ensure your Twitter app has the necessary permissions.
  • Tweet not found or invalid Tweet ID: Confirm that the Tweet ID provided is correct and that the tweet exists and is accessible.
  • Network or rate limit errors: Twitter API enforces rate limits; handle these gracefully and consider retrying after some delay.
  • Malformed custom fields or expansions: Ensure that custom fields and expansions are comma-separated strings without invalid characters.

Links and References

Discussion