> ## Documentation Index
> Fetch the complete documentation index at: https://docs.scrapebadger.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Search Tweets Across Communities

> Search tweets posted in communities, across every community.

The Top and Latest tabs of X's community search page. `tweet_type` is `Top`
(default) or `Latest`. Each tweet carries `community_id` and `community_name`,
the community it was posted in. `/communities/search` finds communities by
name; `/communities/{community_id}/search_tweets` searches inside one community.

## SDKs, CLI and MCP

Python and Node SDK 0.85.0 and later have a typed method. Each tweet is a regular tweet with two more fields, `community_id` and `community_name`.

```python Python theme={null}
from scrapebadger import ScrapeBadger
from scrapebadger.twitter import CommunitySearchTweetType

async with ScrapeBadger(api_key="YOUR_API_KEY") as client:
    page = await client.twitter.communities.search_tweets_across_communities(
        "web scraping", tweet_type=CommunitySearchTweetType.LATEST
    )
    for tweet in page.data:
        print(tweet.community_id, tweet.community_name, tweet.text)

    # Next page
    if page.next_cursor:
        page2 = await client.twitter.communities.search_tweets_across_communities(
            "web scraping",
            tweet_type=CommunitySearchTweetType.LATEST,
            cursor=page.next_cursor,
        )
```

```typescript Node theme={null}
import { ScrapeBadger } from "scrapebadger";

const client = new ScrapeBadger({ apiKey: "YOUR_API_KEY" });

const page = await client.twitter.communities.searchTweetsAcrossCommunities("web scraping", {
  tweetType: "Latest",
});
for (const tweet of page.data) {
  console.log(tweet.community_id, tweet.community_name, tweet.text);
}

// Next page
if (page.nextCursor) {
  const page2 = await client.twitter.communities.searchTweetsAcrossCommunities("web scraping", {
    tweetType: "Latest",
    cursor: page.nextCursor,
  });
}
```

```bash CLI theme={null}
# scrapebadger-cli 0.36.0 and later
scrapebadger twitter search-community-tweets "web scraping" --type Latest
```

`search_tweets_across_communities_all` (Python) and `searchTweetsAcrossCommunitiesAll` (Node) fetch the following pages for you.

| Where | Name |
| - | - |
| Hosted MCP server | `twitter_search_tweets_across_communities` |
| Local MCP server (`scrapebadger-mcp` 0.11.0 and later) | `search_twitter_community_tweets` |


## OpenAPI

````yaml get /v1/twitter/communities/search_tweets
openapi: 3.1.0
info:
  title: ScrapeBadger Twitter API
  description: >-
    The ScrapeBadger Twitter API provides programmatic access to Twitter/X data
    through a simple REST interface. Retrieve tweets, user profiles, followers,
    lists, communities, trends, and geographic data — all with a single API key.


    All endpoints require authentication via the `x-api-key` header. Each
    request consumes credits from your account balance. Paginated endpoints
    return a `next_cursor` field that you can pass to subsequent requests to
    retrieve additional pages of results.


    **Base URL:** `https://scrapebadger.com/v1/twitter`


    **Concurrency:** every account has a max concurrency: how many requests it
    can run at the same time, across all of its API keys. A request over the
    limit gets a `429` response (`concurrency_limit_exceeded`) with
    `Retry-After: 1`; retry as soon as one of your running requests finishes.
    Your account's value is on the pricing page and in `GET /v1/account/me`
    (`max_concurrency`, `concurrent_requests`), and every response carries
    `X-Concurrency-Limit` and `X-Concurrency-Remaining`.


    **Credits:** Each successful API call deducts credits from your balance. If
    your balance reaches zero, subsequent requests will return `402 Payment
    Required`.
  version: 1.0.0
  contact:
    name: ScrapeBadger Support
    url: https://scrapebadger.com
    email: support@scrapebadger.com
servers:
  - url: https://scrapebadger.com
    description: Production
security:
  - apiKey: []
tags:
  - name: Tweets
    description: >-
      Retrieve tweets, search tweets, and access tweet metadata including
      replies, quotes, retweeters, favoriters, edit history, and community
      notes.
  - name: Users
    description: >-
      Retrieve user profiles, followers, following lists, mentions,
      subscriptions, and search for users.
  - name: Lists
    description: Access Twitter list details, list tweets, and search within lists.
  - name: Communities
    description: Retrieve community details, community tweets, and search for communities.
  - name: Trends
    description: Get trending topics globally or by location.
  - name: Geo
    description: Search for geographic places and retrieve place details.
  - name: Spaces
    description: Access Twitter Spaces and live broadcast details.
  - name: Stream Monitors
    description: >-
      Create and manage real-time stream monitors that track Twitter accounts
      and deliver new tweets via WebSocket or webhook.
  - name: Stream Webhooks
    description: >-
      Manage webhook endpoints for stream monitor delivery. Webhooks receive
      HMAC-SHA256 signed payloads when new tweets are detected.
  - name: Stream Logs
    description: >-
      Access delivery logs and billing logs for stream monitors. Track tweet
      detection latency, webhook delivery status, and credit consumption.
  - name: Filter Rules
    description: >-
      Create and manage filter rules that monitor Twitter using Advanced Search
      queries at configurable intervals. Delivered via WebSocket or webhook.
paths:
  /v1/twitter/communities/search_tweets:
    get:
      tags:
        - Communities
      summary: Search tweets across communities
      description: >-
        Search tweets posted in communities, across every community. These are
        the Top and Latest tabs of X's community search page
        (`x.com/i/communities/suggested?q=...`); [Search
        communities](/api-reference/endpoint/communities/search-communities) is
        its first tab.


        Each tweet is the usual tweet object plus `community_id` and
        `community_name`, the community it was posted in. Use them with [Get
        community
        details](/api-reference/endpoint/communities/get-community-details) and
        [Get community
        tweets](/api-reference/endpoint/communities/get-community-tweets).


        X decides the page size (usually 10 to 25 tweets). Pass `next_cursor`
        back unchanged as `cursor` for the next page.
      operationId: searchTweetsAcrossCommunities
      parameters:
        - name: query
          in: query
          required: true
          description: >-
            Search query. Search operators such as `lang:en` or `from:username`
            are supported.
          schema:
            type: string
            example: web scraping
        - name: tweet_type
          in: query
          required: false
          description: 'The tab to read: `Top` (ranked by X) or `Latest` (newest first).'
          schema:
            type: string
            enum:
              - Top
              - Latest
            default: Top
        - name: count
          in: query
          required: false
          description: >-
            Number of tweets to ask X for (1-100). X decides the actual page
            size.
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 20
        - name: cursor
          in: query
          required: false
          description: >-
            Pagination cursor: the `next_cursor` of the previous response of the
            same query, unchanged.
          schema:
            type: string
      responses:
        '200':
          description: Successfully retrieved tweets.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CommunityPostsResponse'
        '400':
          description: >-
            Invalid cursor. Pass the `next_cursor` of the previous response
            unchanged, or leave `cursor` out for the first page.
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          $ref: '#/components/responses/PaymentRequired'
        '429':
          $ref: '#/components/responses/ConcurrencyLimitExceeded'
components:
  schemas:
    CommunityPostsResponse:
      type: object
      description: Paginated list of tweets found across communities.
      properties:
        data:
          type:
            - array
            - 'null'
          description: Array of tweet objects, each naming its community.
          items:
            $ref: '#/components/schemas/CommunityPostData'
        next_cursor:
          type:
            - string
            - 'null'
          description: Cursor for fetching the next page. Null if no more results.
    CommunityPostData:
      allOf:
        - $ref: '#/components/schemas/TweetData'
        - type: object
          properties:
            community_id:
              type:
                - string
                - 'null'
              description: >-
                ID of the community the tweet was posted in. Null for the rare
                result X returns without a community.
            community_name:
              type:
                - string
                - 'null'
              description: Name of the community the tweet was posted in.
      description: A tweet with the community it was posted in.
    ErrorResponse:
      type: object
      description: Error response returned for failed requests.
      required:
        - error
      properties:
        error:
          type: string
          description: Human-readable error message describing what went wrong.
    TweetData:
      type: object
      description: >-
        Comprehensive tweet data including text, author info, engagement
        metrics, media, and metadata.
      required:
        - id
        - text
        - created_at
      properties:
        id:
          type: string
          description: Unique tweet identifier.
          example: '1234567890123456789'
        text:
          type: string
          description: The tweet text content.
          example: Hello, world! This is a tweet.
        full_text:
          type:
            - string
            - 'null'
          description: >-
            Full text of the tweet, including extended content beyond 280
            characters.
        created_at:
          type: string
          description: Timestamp when the tweet was created.
          example: Wed Oct 10 20:19:24 +0000 2018
        lang:
          type:
            - string
            - 'null'
          description: BCP 47 language tag of the tweet content.
          example: en
        user_id:
          type:
            - string
            - 'null'
          description: Numeric ID of the tweet author.
          example: '44196397'
        username:
          type:
            - string
            - 'null'
          description: Username (screen name) of the tweet author.
          example: elonmusk
        user_name:
          type:
            - string
            - 'null'
          description: Display name of the tweet author.
          example: Elon Musk
        favorite_count:
          type: integer
          description: Number of times this tweet has been liked.
          default: 0
        retweet_count:
          type: integer
          description: Number of times this tweet has been retweeted.
          default: 0
        reply_count:
          type: integer
          description: Number of replies to this tweet.
          default: 0
        quote_count:
          type: integer
          description: Number of times this tweet has been quoted.
          default: 0
        view_count:
          type:
            - integer
            - 'null'
          description: Number of times this tweet has been viewed.
        bookmark_count:
          type:
            - integer
            - 'null'
          description: Number of times this tweet has been bookmarked.
        favorited:
          type: boolean
          description: Whether the authenticated user has liked this tweet.
          default: false
        retweeted:
          type: boolean
          description: Whether the authenticated user has retweeted this tweet.
          default: false
        bookmarked:
          type: boolean
          description: Whether the authenticated user has bookmarked this tweet.
          default: false
        possibly_sensitive:
          type: boolean
          description: >-
            Whether the tweet is flagged as possibly containing sensitive
            content.
          default: false
        is_quote_status:
          type: boolean
          description: Whether the tweet is a quote tweet.
          default: false
        is_retweet:
          type: boolean
          description: Whether the tweet is a retweet.
          default: false
        conversation_id:
          type:
            - string
            - 'null'
          description: ID of the conversation thread this tweet belongs to.
        in_reply_to_status_id:
          type:
            - string
            - 'null'
          description: ID of the tweet this is a reply to, if applicable.
        in_reply_to_user_id:
          type:
            - string
            - 'null'
          description: ID of the user this tweet is replying to.
        media:
          type: array
          description: Media attachments (photos, videos, GIFs).
          items:
            $ref: '#/components/schemas/Media'
        urls:
          type: array
          description: URLs mentioned in the tweet.
          items:
            $ref: '#/components/schemas/URL'
        hashtags:
          type: array
          description: Hashtags in the tweet.
          items:
            $ref: '#/components/schemas/Hashtag'
        user_mentions:
          type: array
          description: Users mentioned in the tweet.
          items:
            $ref: '#/components/schemas/UserMention'
        poll:
          oneOf:
            - $ref: '#/components/schemas/Poll'
            - type: 'null'
          description: Poll data if the tweet contains a poll.
        place:
          oneOf:
            - $ref: '#/components/schemas/Place'
            - type: 'null'
          description: Geographic place associated with the tweet.
        quoted_status_id:
          type:
            - string
            - 'null'
          description: ID of the quoted tweet, if this is a quote tweet.
        retweeted_status_id:
          type:
            - string
            - 'null'
          description: ID of the original tweet, if this is a retweet.
        edit_tweet_ids:
          type:
            - array
            - 'null'
          description: List of tweet IDs in the edit chain.
          items:
            type: string
        editable_until_msecs:
          type:
            - integer
            - 'null'
          description: Timestamp (milliseconds) until the tweet can be edited.
        edits_remaining:
          type:
            - integer
            - 'null'
          description: Number of remaining edits allowed.
        is_edit_eligible:
          type:
            - boolean
            - 'null'
          description: Whether the tweet is eligible for editing.
        has_card:
          type:
            - boolean
            - 'null'
          description: Whether the tweet has a link preview card.
        thumbnail_url:
          type:
            - string
            - 'null'
          description: URL of the link preview thumbnail.
        thumbnail_title:
          type:
            - string
            - 'null'
          description: Title of the link preview card.
        has_community_notes:
          type:
            - boolean
            - 'null'
          description: Whether the tweet has community notes attached.
        source:
          type:
            - string
            - 'null'
          description: Client application used to post the tweet.
          example: Twitter Web App
    Media:
      type: object
      description: Media attachment in a tweet (photo, video, or animated GIF).
      properties:
        media_key:
          type:
            - string
            - 'null'
          description: Unique identifier for the media.
        type:
          type:
            - string
            - 'null'
          description: Type of media.
          enum:
            - photo
            - video
            - animated_gif
        url:
          type:
            - string
            - 'null'
          description: URL of the media resource.
        preview_image_url:
          type:
            - string
            - 'null'
          description: URL of the preview/thumbnail image.
        width:
          type:
            - integer
            - 'null'
          description: Width of the media in pixels.
        height:
          type:
            - integer
            - 'null'
          description: Height of the media in pixels.
        duration_ms:
          type:
            - integer
            - 'null'
          description: Duration in milliseconds (for video/GIF).
        view_count:
          type:
            - integer
            - 'null'
          description: Number of views (for video).
        alt_text:
          type:
            - string
            - 'null'
          description: Alt text description of the media.
    URL:
      type: object
      description: URL entity in a tweet or user profile.
      required:
        - url
      properties:
        url:
          type: string
          description: The shortened t.co URL.
        expanded_url:
          type:
            - string
            - 'null'
          description: The fully expanded URL.
        display_url:
          type:
            - string
            - 'null'
          description: Display-friendly version of the URL.
        unwound_url:
          type:
            - string
            - 'null'
          description: Fully resolved URL after following redirects.
    Hashtag:
      type: object
      description: Hashtag entity in a tweet.
      required:
        - text
      properties:
        text:
          type: string
          description: 'The hashtag text (without the # symbol).'
          example: AI
        indices:
          type:
            - array
            - 'null'
          description: Start and end positions of the hashtag in the tweet text.
          items:
            type: integer
    UserMention:
      type: object
      description: User mention entity in a tweet.
      properties:
        id:
          type:
            - string
            - 'null'
          description: Numeric ID of the mentioned user.
        username:
          type:
            - string
            - 'null'
          description: Username of the mentioned user.
        name:
          type:
            - string
            - 'null'
          description: Display name of the mentioned user.
        indices:
          type:
            - array
            - 'null'
          description: Start and end positions of the mention in the tweet text.
          items:
            type: integer
    Poll:
      type: object
      description: Poll data in a tweet.
      properties:
        id:
          type:
            - string
            - 'null'
          description: Unique poll identifier.
        voting_status:
          type:
            - string
            - 'null'
          description: Current voting status.
          enum:
            - open
            - closed
        end_datetime:
          type:
            - string
            - 'null'
          description: When the poll ends or ended.
        duration_minutes:
          type:
            - integer
            - 'null'
          description: Total duration of the poll in minutes.
        options:
          type: array
          description: Poll options with vote counts.
          items:
            $ref: '#/components/schemas/PollOption'
    Place:
      type: object
      description: Geographic place information attached to a tweet.
      properties:
        id:
          type:
            - string
            - 'null'
          description: Unique place identifier.
        full_name:
          type:
            - string
            - 'null'
          description: Full human-readable place name.
          example: San Francisco, CA
        name:
          type:
            - string
            - 'null'
          description: Short place name.
          example: San Francisco
        country:
          type:
            - string
            - 'null'
          description: Country name.
          example: United States
        country_code:
          type:
            - string
            - 'null'
          description: ISO country code.
          example: US
        place_type:
          type:
            - string
            - 'null'
          description: Type of place.
          enum:
            - city
            - country
            - admin
            - poi
            - neighborhood
    PollOption:
      type: object
      description: A single poll option with its vote count.
      required:
        - position
        - label
        - votes
      properties:
        position:
          type: integer
          description: Position of the option (1-indexed).
        label:
          type: string
          description: Text label of the poll option.
        votes:
          type: integer
          description: Number of votes for this option.
  responses:
    Unauthorized:
      description: Authentication failed. The API key is missing, invalid, or expired.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error: Invalid or missing API key
    PaymentRequired:
      description: >-
        Insufficient credits. Your account balance has been exhausted. Purchase
        more credits at
        https://scrapebadger.com/dashboard/billing?utm_source=docs&utm_medium=referral.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error: Insufficient credits
    ConcurrencyLimitExceeded:
      description: >-
        Too many concurrent requests. Every request of this account (all of its
        API keys) that is still running holds one of its max concurrency slots,
        and all of them are in use. Retry as soon as one finishes (`Retry-After:
        1`), or upgrade your plan for more: https://scrapebadger.com/pricing
      headers:
        Retry-After:
          description: Seconds to wait before retrying. Always 1.
          schema:
            type: integer
            example: 1
        X-Concurrency-Limit:
          description: The account's max concurrency.
          schema:
            type: integer
            example: 5
        X-Concurrency-Remaining:
          description: Free slots left. 0 on this response.
          schema:
            type: integer
            example: 0
      content:
        application/json:
          schema:
            type: object
            required:
              - error
              - detail
              - max_concurrency
              - concurrent_requests
            properties:
              error:
                type: string
                enum:
                  - concurrency_limit_exceeded
                description: Machine-readable error code.
              detail:
                type: string
                description: Human-readable explanation.
              max_concurrency:
                type: integer
                description: How many requests this account may run at the same time.
              concurrent_requests:
                type: integer
                description: How many of its requests were running when this one arrived.
          example:
            error: concurrency_limit_exceeded
            detail: >-
              Too many concurrent requests: this account allows 5 at a time and
              5 are already running. Retry as soon as one finishes, or upgrade
              your plan for more: https://scrapebadger.com/pricing
            max_concurrency: 5
            concurrent_requests: 5
  securitySchemes:
    apiKey:
      type: apiKey
      name: x-api-key
      in: header
      description: >-
        Your ScrapeBadger API key. You can find this in your dashboard at
        https://scrapebadger.com/dashboard/api-keys?utm_source=docs&utm_medium=referral.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.