Plugin: Twitter V2 API gatherer

Purpose

Use this plugin to index content from a paid Twitter service using the V2 API.

By default, the most recent ten Tweets are returned per request.

When to use this plugin

Use this plugin if you have paid for a Twitter accound and would like to include Tweets as part of your search results.

This plugin requires a paid Twitter account. You need at least Paid Basic API access to pull tweets Twitter API access levels and versions

The plugin will get a maximum of 100 tweets per request. This is to reduce the number of requests made to the Twitter API, thereby preventing HTTP 429 requests and improving performance.

The plugin will retry once based on the HTTP Header x-rate-limit-reset after getting an HTTP error 429 Too Many Requests from the Twitter API. If the plugin receives a 429 response again, it will stop processing gracefully and log an error message. Please consider upgrading your Twitter account to a higher level if you receive this error frequently.

You can find more information about the Twitter API rate limits here: https://docs.x.com/x-api/fundamentals/rate-limits under GET /2/users/:id/tweets

Usage

Enable the plugin

  1. Select Plugins from the side navigation pane and click on the Twitter V2 API gatherer tile.

  2. From the Location section, select the data source to which you would like to enable this plugin from the Select a data source select list.

The plugin will take effect after setup steps and an advanced > full update of the data source has completed.

Configuration settings

The configuration settings section is where you do most of the configuration for your plugin. The settings enable you to control how the plugin behaves.

The configuration key names below are only used if you are configuring this plugin manually. The configuration keys are set in the data source configuration to configure the plugin. When setting the keys manually you need to type in (or copy and paste) the key name and value.

User access token

Configuration key

plugin.twitter-v2-api-gatherer.encrypted.bearerToken

Data type

Encrypted string

Required

This setting is required

Your Twitter API access token. See: https://developer.twitter.com/en/docs/authentication/oauth-2-0/bearer-tokens for more information.

Twitter user Id

Configuration key

plugin.twitter-v2-api-gatherer.config.userId

Data type

string

Required

This setting is optional

Your Twitter userId (if known).

Twitter user name

Configuration key

plugin.twitter-v2-api-gatherer.config.userName

Data type

string

Required

This setting is required

Your Twitter user name. The can be obtained from your profile and is the value after the @ symbol. It will be used to retrieve userId.

Additional Twitter query parameters

Configuration key

plugin.twitter-v2-api-gatherer.config.queryParameters.*

Data type

string

Required

This setting is required

Specify additional parameters for the Twitter query. This can be used to modify the fields returned, or apply scoping to your Twitter query. The Parameter 1 field should be used to specify the Twitter query parameter name. More info: https://developer.twitter.com/en/docs/twitter-api/tweets/timelines/api-reference/get-users-id-tweets

You need to provide either a userName or userId (or both).

Notes

If you want to have Tweet URLs created with userName: https://twitter.com/<userName>/status/<tweetId>, you need to provide it as a config key (see above).

If you don’t provide a userName the URLs will be created with userId: https://twitter.com/<userId>/status/<tweetId>;

By default, the plugin will request only tweetId and tweetText fields form API.

    ...
    {
      "edit_history_tweet_ids": [
        "123456123456"
      ],
      "id": "123456123456",
      "text": "Congratulations to Professor John Doe on receiving...."
    },
    ...

Additional fields can be requested by setting the additional Twitter query parameters option (see above).

Filter chain configuration

This plugin uses filters which are used to apply transformations to the gathered content.

The filters run in sequence and need be set in an order that makes sense. The plugin supplied filter(s) (as indicated in the listing) should be re-ordered to an appropriate point in the sequence.

Changes to the filter order affects the way the data source processes gathered documents. See: document filters documentation.

Filter classes

This plugin supplies a filter that runs in the main document filter chain: JSONToXML

Drag the JSONToXML plugin filter to where you wish it to run in the filter chain sequence.

Examples

Example: Specify additional Twitter fields to include in the response

Get the created_at field added to the set of fields returned by the Twitter API.

Configuration key name Parameter 1 Value

Additional Twitter query parameters

tweet.fields

created_at

Get the created_at and author_id fields added to the set of fields returned by the Twitter API.

Configuration key name Parameter 1 Value

Additional Twitter query parameters

tweet.fields

created_at,author_id

Example: Only get recent Tweets

If you only need tweets after a specific date:

Configuration key name Parameter 1 Value

Additional Twitter query parameters

start_time

2023-04-01T13:03:36.000Z

Change log

[1.2.0]

Changed

  • Added support to retry calling the Twitter API if it returns an HTTP 429 Too Many Requests response. The plugin will retry up to one time with a delay based on the API HTTP header x-rate-limit-reset.

  • Added a limit of getting a maximum of 100 tweets per request. This is to reduce the number of requests made to the Twitter API, thereby preventing HTTP 429 requests and improving performance.

[1.1.0]

Changed

  • Updated to the latest version plugin framework (Funnelback shared v16.20) to enable integration with the new plugin management dashboard.