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 (formerly Twitter) API v2 to perform various user-related operations. Specifically, for the "Users" resource and the "Get User by Username" operation, it retrieves detailed information about a Twitter user based on their username (without the '@' symbol). This is useful when you want to fetch profile details, metrics, or other user data programmatically within an n8n workflow.

Common scenarios include:

  • Enriching contact or lead data with social media profiles.
  • Monitoring specific users for analytics or engagement.
  • Automating responses or actions based on user attributes.

Example: Given a username like jack, the node fetches Jack Dorsey's public profile data, optionally including private metrics or custom fields if configured.

Properties

Name Meaning
Username The Twitter username of the user to retrieve (without the '@' symbol).
Include Private Metrics Boolean flag to include private metrics in the response; requires elevated API access.
Custom Fields Comma-separated list of additional custom fields to include in the user data response.
Custom Expansions Comma-separated list of expansions to include, allowing retrieval of related objects.

Output

The node outputs JSON data representing the user information retrieved from the Twitter API. This includes standard user profile fields such as ID, name, username, description, and optionally private metrics and any requested custom fields or expansions.

The output structure is an array of items, each containing a json property with the user data object. Each item corresponds to one input execution.

No binary data is output by this operation.

Dependencies

  • Requires an API key credential for the "N8N Tools API" service to validate subscription and access.
  • Uses OAuth2 or API key credentials for authenticating with the Twitter API.
  • The node depends on the bundled twitter-api helper class to interact with Twitter endpoints.
  • Proper configuration of credentials in n8n is necessary, including valid API keys and tokens with appropriate permissions.

Troubleshooting

  • Invalid Subscription or API Key: If the node throws an error indicating invalid subscription or API key, verify that your API key credential is correct and active.
  • Insufficient Access for Private Metrics: Requesting private metrics without elevated access will likely result in errors or incomplete data. Ensure your Twitter developer account has the required permissions.
  • Username Not Found: Providing a non-existent or misspelled username will cause the API to return an error. Double-check the username input.
  • Rate Limits: Twitter API enforces rate limits; excessive requests may be throttled. Implement error handling or delays as needed.
  • Malformed Custom Fields/Expansions: Incorrectly formatted comma-separated lists can cause request failures. Ensure no extra spaces or invalid field names.

Links and References

Discussion