# twitter_search

> For the complete documentation index, see [llms.txt](https://docs.redpanda.com/llms.txt). Component-specific: [connect-full.txt](https://docs.redpanda.com/connect-full.txt)

---
title: twitter_search
latest-connect-version: 4.93.0
latest-operator-version: v26.1.4
latest-console-tag: v3.7.3
latest-redpanda-tag: v26.1.9
docname: inputs/twitter_search
page-component-name: connect
page-version: master
page-component-version: master
page-component-title: Connect
page-relative-src-path: inputs/twitter_search.adoc
page-edit-url: https://github.com/redpanda-data/rp-connect-docs/edit/main/modules/components/pages/inputs/twitter_search.adoc
page-git-created-date: "2024-05-24"
page-git-modified-date: "2026-05-26"
---

<!-- Source: https://docs.redpanda.com/connect/components/inputs/twitter_search.md -->

**Available in:** Self-Managed

Consumes tweets matching a given search using the Twitter recent search V2 API.

#### Common

```yml
inputs:
  label: ""
  twitter_search:
    query: "" # No default (required)
    tweet_fields: []
    poll_period: 1m
    backfill_period: 5m
    cache: "" # No default (required)
    api_key: "" # No default (required)
    api_secret: "" # No default (required)
```

#### Advanced

```yml
inputs:
  label: ""
  twitter_search:
    query: "" # No default (required)
    tweet_fields: []
    poll_period: 1m
    backfill_period: 5m
    cache: "" # No default (required)
    cache_key: last_tweet_id
    rate_limit: ""
    api_key: "" # No default (required)
    api_secret: "" # No default (required)
```

Continuously polls the [Twitter recent search V2 API](https://developer.twitter.com/en/docs/twitter-api/tweets/search/api-reference/get-tweets-search-recent) for tweets that match a given search query.

Each tweet received is emitted as a JSON object message, with a field `id` and `text` by default. Extra fields [can be obtained from the search API](https://developer.twitter.com/en/docs/twitter-api/fields) when listed with the `tweet_fields` field.

In order to paginate requests that are made the ID of the latest received tweet is stored in a [cache resource](https://docs.redpanda.com/connect/components/caches/about/), which is then used by subsequent requests to ensure only tweets after it are consumed. It is recommended that the cache you use is persistent so that Redpanda Connect can resume searches at the correct place on a restart.

Authentication is done using OAuth 2.0 credentials which can be generated within the [Twitter developer portal](https://developer.twitter.com).

## [](#fields)Fields

### [](#api_key)`api_key`

An API key for OAuth 2.0 authentication. It is recommended that you populate this field using [environment variables](https://docs.redpanda.com/connect/configuration/interpolation/).

**Type**: `string`

### [](#api_secret)`api_secret`

An API secret for OAuth 2.0 authentication. It is recommended that you populate this field using [environment variables](https://docs.redpanda.com/connect/configuration/interpolation/).

**Type**: `string`

### [](#backfill_period)`backfill_period`

A duration string indicating the maximum age of tweets to acquire when starting a search.

**Type**: `string`

**Default**: `5m`

### [](#cache)`cache`

A cache resource to use for request pagination.

**Type**: `string`

### [](#cache_key)`cache_key`

The key identifier used when storing the ID of the last tweet received.

**Type**: `string`

**Default**: `last_tweet_id`

### [](#poll_period)`poll_period`

The length of time (as a duration string) to wait between each search request. This field can be set empty, in which case requests are made at the limit set by the rate limit. This field also supports cron expressions.

**Type**: `string`

**Default**: `1m`

### [](#query)`query`

A search expression to use.

**Type**: `string`

### [](#rate_limit)`rate_limit`

An optional rate limit resource to restrict API requests with.

**Type**: `string`

**Default**: `""`

### [](#tweet_fields)`tweet_fields[]`

An optional list of additional fields to obtain for each tweet, by default only the fields `id` and `text` are returned. For more info refer to the [twitter API docs](https://developer.twitter.com/en/docs/twitter-api/fields).

**Type**: `array`

**Default**: `[]`