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

# Search tweets in a community, X (Twitter) API docs

> Search tweets in one X (Twitter) Community or every Community by keyword on the communities/tweets path, with the same inputs and pages as Community search.

> For the complete documentation index, see [llms.txt](https://docs.xquik.com/llms.txt).

`GET https://xquik.com/api/v1/x/communities/tweets`

**1 credit per result returned** · [All plans](https://xquik.com) from \$0.00012/credit · Supports [guest paid reads](https://docs.xquik.com/guides/guest-wallets.md)

```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/bash.json","/languages/csharp.json","/languages/go.json","/languages/java.json","/languages/javascript.json","/languages/kotlin.json","/languages/php.json","/languages/python.json","/languages/ruby.json","/languages/typescript.json"]}}
curl -G https://xquik.com/api/v1/x/communities/tweets \
  --data-urlencode "communityId=1493446837214187523" \
  --data-urlencode "q=launch" \
  -H "x-api-key: xq_your_api_key_here" | jq
```

```javascript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/bash.json","/languages/csharp.json","/languages/go.json","/languages/java.json","/languages/javascript.json","/languages/kotlin.json","/languages/php.json","/languages/python.json","/languages/ruby.json","/languages/typescript.json"]}}
const params = new URLSearchParams({ communityId: "1493446837214187523", q: "launch" });
const response = await fetch(`https://xquik.com/api/v1/x/communities/tweets?${params}`, {
  headers: { "x-api-key": "xq_your_api_key_here" },
});
const page = await response.json();
if (!response.ok) throw new Error(JSON.stringify(page));

for (const tweet of page.tweets) console.log(tweet.id, tweet.text);
```

```python Python theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/bash.json","/languages/csharp.json","/languages/go.json","/languages/java.json","/languages/javascript.json","/languages/kotlin.json","/languages/php.json","/languages/python.json","/languages/ruby.json","/languages/typescript.json"]}}
import requests

response = requests.get(
    "https://xquik.com/api/v1/x/communities/tweets",
    params={"communityId": "1493446837214187523", "q": "launch"},
    headers={"x-api-key": "xq_your_api_key_here"},
)
page = response.json()
if not response.ok:
    raise RuntimeError(page)

for tweet in page["tweets"]:
    print(tweet["id"], tweet["text"])
```

## The same search on another path

`GET /x/communities/tweets` searches the tweets in one Community, or across every
Community without `communityId`. It works exactly as [Community search](https://docs.xquik.com/api-reference/x/community-search.md)
does on `GET /x/communities/search`. Both take the same
`communityId`, `q`, `queryType`, `cursor`, and `pageSize`. Both answer the same page of tweets.




Keep this path when your integration already uses it. New integrations can use either.




To get a Community's posts for a hashtag, search with `q=#tag`
and its `communityId`. An example is `q=#bitcoin`.

## Query parameters

| Query parameter | Type | Required | Description |
| - | - | - | - |
| `communityId` | `string` | No | ID or link of the Community to search, such as `x.com/i/communities/1493446837214187523`. Leave it out to search every Community. |
| `q` | `string` | Yes | Search query for the Community's tweets. |
| `queryType` | `string` | No | Sort order. `Top` returns the most relevant tweets, `Latest` the most recent. Defaults to `Latest`. |
| `cursor` | `string` | No | Pagination cursor from a previous response. Omit for the first page. |
| `pageSize` | `number` | No | Upper bound for tweets per page. Accepts 1-100. Defaults to `20`. |

### Tweet filters

These filters narrow the search and the rows it returns, as on Community search.

See [tweet filters](https://docs.xquik.com/api-reference/x/tweet-filters.md) for every filter. Common ones are `fromUser`, `language`, `sinceDate`, `mediaType`, `minLikes`, and `hashtags`.

| Query parameter | Type | Required | Description |
| - | - | - | - |
| `sinceId` | `string` | No | Return Tweets whose IDs exceed this ID. |
| `maxId` | `string` | No | Return Tweets at or below this ID. |
| `nativeRetweets` | `boolean` | No | When `true`, only return native reposts. |

| Query parameter | Type | Required | Description |
| - | - | - | - |
| `withinTime` | `string` | No | Match Tweets from this recent window, such as `90m` or `7d`. Use a whole number & `s`, `m`, `h` or `d`. |

### Choose fields

| Query parameter | Type | Required | Description |
| - | - | - | - |
| `fields` | `string` | No | Fields to keep in each row, comma-separated, such as `id,text,author.username`. Use dots for nested fields. Case & underscores do not matter. A row that lacks a field leaves it out. Cursors, counts & diagnostics always stay. An unknown name returns `400 unknown_field` with the valid names, before any read. The price stays the same. |
| `omit` | `string` | No | Fields to drop from each row, comma-separated, such as `entities,media`. It takes the same names as `fields`. With `fields`, it drops from the kept fields. |

## Headers

| Header | Type | Required | Description |
| - | - | - | - |
| `x-api-key` | `string` | No | Full account key. Sessions and OAuth also work. |
| `Authorization` | `string` | No | `Bearer xq_your_guest_key_here` for `paid_reads`. |

## Response

### 200 OK

Returns the same page as [Community search](https://docs.xquik.com/api-reference/x/community-search.md#response), with `tweets`, `has_next_page`, and
`next_cursor`.

> [!NOTE]
>
> **Related.** [Community search](https://docs.xquik.com/api-reference/x/community-search.md) · [Community tweets](https://docs.xquik.com/api-reference/x/community-tweets.md) · [Community details](https://docs.xquik.com/api-reference/x/community-info.md)

> [accordion] Related follower, list & community APIs
>
> * Profiles
>   * [Search users](https://docs.xquik.com/api-reference/x/search-users.md)
>   * [Search autocomplete](https://docs.xquik.com/api-reference/x/search-autocomplete.md)
>   * [Get user](https://docs.xquik.com/api-reference/x/twitter-profile-lookup.md)
>   * [Batch users](https://docs.xquik.com/api-reference/x/batch-users.md)
> * Followers
>   * [Followers](https://docs.xquik.com/api-reference/x/followers.md)
>   * [Following](https://docs.xquik.com/api-reference/x/following.md)
>   * [Follower IDs](https://docs.xquik.com/api-reference/x/follower-ids.md)
>   * [Following IDs](https://docs.xquik.com/api-reference/x/following-ids.md)
>   * [Creator subscriptions](https://docs.xquik.com/api-reference/x/user-subscriptions.md)
>   * [Affiliates](https://docs.xquik.com/api-reference/x/user-affiliates.md)
>   * [Similar accounts](https://docs.xquik.com/api-reference/x/user-similar.md)
>   * [Translate bio](https://docs.xquik.com/api-reference/x/user-bio-translation.md)
>   * [User insights](https://docs.xquik.com/api-reference/x/user-engagement-insights.md)
>   * [Verified followers](https://docs.xquik.com/api-reference/x/verified-followers.md)
>   * [Followers you know](https://docs.xquik.com/api-reference/x/followers-you-know.md)
>   * [Check follower](https://docs.xquik.com/api-reference/x/check-follower.md)
> * Lists
>   * [Search lists](https://docs.xquik.com/api-reference/x/search-lists.md)
>   * [User lists](https://docs.xquik.com/api-reference/x/user-lists.md)
>   * [List memberships](https://docs.xquik.com/api-reference/x/user-list-memberships.md)
>   * [List details](https://docs.xquik.com/api-reference/x/list-details.md)
>   * [List members](https://docs.xquik.com/api-reference/x/list-members.md)
>   * [List followers](https://docs.xquik.com/api-reference/x/list-followers.md)
> * Communities
>   * [Find](https://docs.xquik.com/api-reference/x/community-find.md)
>   * [Popular](https://docs.xquik.com/api-reference/x/community-popular.md)
>   * [Topics](https://docs.xquik.com/api-reference/x/community-topics.md)
>   * [Suggested](https://docs.xquik.com/api-reference/x/community-suggested.md)
>   * [Details](https://docs.xquik.com/api-reference/x/community-info.md)
>   * [Members](https://docs.xquik.com/api-reference/x/community-members.md)
>   * [Member search](https://docs.xquik.com/api-reference/x/community-member-search.md)
>   * [Moderators](https://docs.xquik.com/api-reference/x/community-moderators.md)
>   * [Timeline](https://docs.xquik.com/api-reference/x/community-tweets.md)
>   * [Media](https://docs.xquik.com/api-reference/x/community-media.md)
>   * [Keyword search](https://docs.xquik.com/api-reference/x/community-search.md)
>   * [Tweets search](https://docs.xquik.com/api-reference/x/community-tweets-search.md)

## Response examples

### 200 example

```json theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/bash.json","/languages/csharp.json","/languages/go.json","/languages/java.json","/languages/javascript.json","/languages/kotlin.json","/languages/php.json","/languages/python.json","/languages/ruby.json","/languages/typescript.json"]}}
{
  "tweets": [
    {
      "id": "2102761519985332442",
      "text": "This galaxy is a little extra.\n\nMeet Messier 106, a spiral galaxy with an extra set of arms. These two additional arms are made of gas heated up by jets from the galaxy’s central black hole. The jets’ superheated shockwaves are depicted in royal blue by @chandraxray. https://t.co/421Lzs0r0c",
      "retweetCount": 1364,
      "replyCount": 271,
      "likeCount": 9775
    }
  ],
  "has_next_page": true,
  "next_cursor": "DAAHCgABHTK6Vr___-sLAAIAAAATMjEwMTc3MDE4NjE1NjA1Mjk1OQgAAwAAAAIAAA",
  "filtered_count": 0
}
```

* **400** `{ "error": "invalid_input", "message": "Invalid input. Check the request body." }`
* **401** `{ "error": "unauthenticated", "message": "Authentication required." }`
* **402** `{ "error": "insufficient_credits", "message": "Insufficient credits. Top up or subscribe to continue." }`
* **403** `{ "error": "api_key_paused", "message": "This API key is paused. Resume it at dashboard.xquik.com/api-keys to use it again." }`
* **424** `{ "error": "x_api_unavailable", "message": "X data source temporarily unavailable. Try again later." }`
* **429** `{ "error": "rate_limit_exceeded", "message": "Too many requests. Try again later.", "retryAfter": 60 }`
* **502** `{ "error": "x_api_unavailable", "message": "X data source temporarily unavailable. Try again later." }`
* **503** `{ "error": "x_api_unavailable", "message": "Xquik is busy right now. Retry shortly." }`


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