> ## 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.

# Top tweets by likes & views, X (Twitter) API docs

> Get the top Twitter and X tweets by likes, replies, quotes, bookmarks, shares, or views for a day, week, or month, worldwide or by country. 1 credit per tweet.

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

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

**1 credit per tweet** · Up to 100 tweets per list

[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 --get "https://xquik.com/api/v1/x/tweets/top" \
  --data-urlencode "metric=views" \
  --data-urlencode "window=week" \
  --data-urlencode "country=US" \
  -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({ metric: "views", window: "week", country: "US" });
const response = await fetch(`https://xquik.com/api/v1/x/tweets/top?${params}`, {
  headers: { "x-api-key": "xq_your_api_key_here" },
});
const body = await response.json();
if (!response.ok) throw new Error(JSON.stringify(body));

for (const tweet of body.tweets) {
  console.log(`@${tweet.author.username}: ${tweet.viewCount} views`);
}
```

```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/tweets/top",
    params={"metric": "views", "window": "week", "country": "US"},
    headers={"x-api-key": "xq_your_api_key_here"},
)
body = response.json()
if not response.ok:
    raise RuntimeError(body)

for tweet in body["tweets"]:
    print(f'@{tweet["author"]["username"]}: {tweet.get("viewCount")} views')
```

## The tweets X ranks highest

Use `GET /x/tweets/top` to list the tweets X ranks highest by one metric. Pick
the metric and how far back to look. Narrow it to one country or one language. Leave both out to cover all of X.




Pages hold up to 20 tweets. Pass `next_cursor` as `cursor` for the next page. The list ends at 100 tweets.

## Query parameters

| Query parameter | Type | Required | Description |
| - | - | - | - |
| `metric` | `string` | No | What to rank tweets by. Use `likes`, `replies`, `quotes`, `bookmarks`, `shares`, or `views`. Singular names work too, such as `like`. |
| `window` | `string` | No | How far back to look. Use `day`, `week`, or `month`. Also takes `24h`, `7d`, `30d`, `daily`, `weekly`, and `monthly`. |
| `country` | `string` | No | Only tweets from one country. Send a 2- or 3-letter ISO 3166 code, such as `US` or `USA`. Send `country` or `language`, not both. |
| `language` | `string` | No | Only tweets in one language, as a 2-letter code, such as `en`. Send `country` or `language`, not both. |
| `cursor` | `string` | No | `next_cursor` from the previous page. |
| `pageSize` | `number` | No | Tweets per page, from 1 to 100. Your credits can return fewer. Default `20`. |

### 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

| Field | Type | Description |
| - | - | - |
| `tweets` | `object[]` | The tweets in X's order. Each has its author, text, media, and metrics, as [Search tweets](https://docs.xquik.com/api-reference/x/search-tweets.md) returns them. |
| `has_next_page` | `boolean` | `true` while more tweets follow, up to 100. |
| `next_cursor` | `string` | Pass it as `cursor` for the next page. Empty on the last page. |

### 400 Invalid input

`{ "error": "invalid_input", "message": "Send country or language, not both." }`




The message says which parameter to fix.

### 401 Unauthenticated

Anonymous requests get `WWW-Authenticate: Bearer` and a guest wallet checkout action. This is not a Payment challenge.

### 402 Payment required

Account keys get account options. Guest keys get guest top-up only.
No checkout starts automatically. Confirm any payment action.

### 502 X API unavailable

The read service returned an error. Retry after a short delay.

> [!NOTE]
>
> **Related.** [Search tweets](https://docs.xquik.com/api-reference/x/search-tweets.md) · [Trends](https://docs.xquik.com/api-reference/x/trends.md) · [Get tweet](https://docs.xquik.com/api-reference/x/get-tweet.md)

> [accordion] Related tweet, reply & media APIs
>
> * Tweets
>   * [Get tweet](https://docs.xquik.com/api-reference/x/get-tweet.md)
>   * [Tweet insights](https://docs.xquik.com/api-reference/x/tweet-engagement-insights.md)
>   * [Batch tweets](https://docs.xquik.com/api-reference/x/batch-tweets.md)
>   * [Tweet thread](https://docs.xquik.com/api-reference/x/tweet-thread.md)
>   * [Hidden replies](https://docs.xquik.com/api-reference/x/tweet-hidden-replies.md)
>   * [Translate tweet](https://docs.xquik.com/api-reference/x/tweet-translation.md)
>   * [Embed tweet](https://docs.xquik.com/api-reference/x/tweet-embed.md)
>   * [Resolve links](https://docs.xquik.com/api-reference/x/resolve-links.md)
>   * [Tweet subtitles](https://docs.xquik.com/api-reference/x/tweet-subtitles.md)
>   * [X Article](https://docs.xquik.com/api-reference/x/get-article.md)
> * Analysis
>   * [Sentiment analysis](https://docs.xquik.com/api-reference/x/sentiment-analysis.md)
>   * [Brand mentions](https://docs.xquik.com/api-reference/x/brand-monitoring.md)
>   * [News classification](https://docs.xquik.com/api-reference/x/news-classification.md)
>   * [Market signals](https://docs.xquik.com/api-reference/x/market-signals.md)
>   * [Viral score](https://docs.xquik.com/api-reference/x/viral-score.md)
>   * [Classify posts](https://docs.xquik.com/api-reference/x/classify-tweets.md)
> * Engagement
>   * [Tweet replies](https://docs.xquik.com/api-reference/x/tweet-replies.md)
>   * [Quote tweets](https://docs.xquik.com/api-reference/x/tweet-quotes.md)
>   * [Likers](https://docs.xquik.com/api-reference/x/favoriters.md)
>   * [Reposters](https://docs.xquik.com/api-reference/x/retweeters.md)
>   * [Reposter IDs](https://docs.xquik.com/api-reference/x/retweeter-ids.md)
>   * [Check repost](https://docs.xquik.com/api-reference/x/tweet-repost-check.md)
> * Profiles
>   * [User tweets](https://docs.xquik.com/api-reference/x/user-tweets.md)
>   * [Batch user tweets](https://docs.xquik.com/api-reference/x/batch-user-tweets.md)
>   * [User replies](https://docs.xquik.com/api-reference/x/user-replies.md)
>   * [User likes](https://docs.xquik.com/api-reference/x/user-likes.md)
>   * [User media](https://docs.xquik.com/api-reference/x/user-media.md)
>   * [User highlights](https://docs.xquik.com/api-reference/x/user-highlights.md)
>   * [User articles](https://docs.xquik.com/api-reference/x/user-articles.md)
> * Feeds
>   * [List tweets](https://docs.xquik.com/api-reference/x/list-tweets.md)
>   * [Trends](https://docs.xquik.com/api-reference/x/trends.md)
>   * [Trends history](https://docs.xquik.com/api-reference/x/trends-history.md)
>   * [Top tweets](https://docs.xquik.com/api-reference/x/top-tweets.md)
>   * [Trend locations](https://docs.xquik.com/api-reference/x/trend-locations.md)
>   * [Search Spaces](https://docs.xquik.com/api-reference/x/search-spaces.md)
>   * [Get Space](https://docs.xquik.com/api-reference/x/get-space.md)
>   * [Space replay](https://docs.xquik.com/api-reference/x/space-replay.md)
>   * [Get broadcast](https://docs.xquik.com/api-reference/x/get-broadcast.md)
>   * [User live status](https://docs.xquik.com/api-reference/x/user-live-status.md)
>   * [User shadowban](https://docs.xquik.com/api-reference/x/user-shadowban.md)
>   * [Notes contributor](https://docs.xquik.com/api-reference/x/community-notes-contributor.md)
>   * [Contributor notes](https://docs.xquik.com/api-reference/x/community-notes-contributor-notes.md)
>   * [Deleted notes](https://docs.xquik.com/api-reference/x/community-notes-contributor-deleted-notes.md)
>   * [Hashflags](https://docs.xquik.com/api-reference/x/hashflags.md)
>   * [Search places](https://docs.xquik.com/api-reference/x/search-places.md)
>   * [Download media](https://docs.xquik.com/api-reference/x/download-media.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.