N8N Tools - X (Twitter) Enhanced icon

N8N Tools - X (Twitter) Enhanced

Comprehensive X (Twitter) API v2 integration for N8N workflows

Overview

This node integrates with the X (Twitter) API v2 to perform various operations related to Tweets, Users, Timelines, Media, Spaces, Lists, Bookmarks, Direct Messages, Analytics, and Compliance. Specifically for the Tweets - Get Tweets operation, it retrieves multiple tweets by their IDs in a single request.

Common scenarios where this node is beneficial include:

  • Fetching detailed information about specific tweets for analysis or display.
  • Collecting tweet data for social media monitoring or reporting.
  • Enriching workflows with tweet metadata such as metrics, expansions, or custom fields.

Practical example:

  • You have a list of Tweet IDs from a previous search or event and want to retrieve full details about these tweets including author info and engagement metrics.

Properties

Name Meaning
Tweet IDs Comma-separated list of Tweet IDs to retrieve.
Include Private Metrics Boolean flag to include private metrics in the response (requires elevated access).
Custom Fields Comma-separated custom tweet fields to include in the response (e.g., created_at, lang).
Custom Expansions Comma-separated custom expansions to include (e.g., author_id, attachments.media_keys).

Output

The node outputs an array of JSON objects, each representing a tweet retrieved from the Twitter API. Each object contains the tweet data enriched with any requested fields and expansions.

  • The json output field includes all standard tweet properties plus any custom fields or expansions specified.
  • If private metrics are included, additional engagement data will be present.
  • No binary data is output for this operation.

Example structure snippet (simplified):

{
  "data": [
    {
      "id": "1234567890",
      "text": "Example tweet text",
      "author_id": "0987654321",
      "created_at": "2024-01-01T12:00:00Z",
      "public_metrics": {
        "retweet_count": 10,
        "reply_count": 5,
        "like_count": 20,
        "quote_count": 1
      },
      "private_metrics": { ... } // if included
    }
  ],
  "includes": {
    "users": [ ... ], // if expansions requested
    "media": [ ... ]
  }
}

Dependencies

  • Requires an API key credential for the external "N8N Tools API" service to validate subscription and usage.
  • Requires OAuth2 or API credentials for Twitter API v2 access.
  • The node uses an internal helper class to interact with Twitter's API endpoints.
  • Proper configuration of credentials in n8n is necessary before use.

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.

  • Twitter API errors:
    Errors from Twitter (e.g., rate limits, invalid Tweet IDs) will be thrown. Check the error message for details and ensure Tweet IDs are valid.

  • Empty or malformed Tweet IDs:
    Ensure Tweet IDs are provided as a comma-separated string without extra spaces or invalid characters.

  • Private metrics not included despite enabling:
    Elevated Twitter API access is required to retrieve private metrics. Confirm your Twitter developer account permissions.

  • Network or connectivity issues:
    Verify network access to Twitter API endpoints and that credentials are correctly configured.

Links and References

Discussion