Search & Research
x-advanced-search
Read-only search of public X (Twitter) posts by keyword, account, language, engagement and date range through the TwitterAPI.io REST API (https://twitterapi.io). Needs a TwitterAPI.io API key.
---
name: x-advanced-search
description: Search public X (Twitter) posts by keyword, phrase, account, language, engagement and date range through the twitterapi.io REST API with a plain API key. Use when the user wants posts about a topic, posts from or to an account in a period, or a ranked or latest-first result set, and the agent must page through results and know the cost.
license: MIT
compatibility: Needs network access to https://api.twitterapi.io and the TWITTERAPI_IO_API_KEY environment variable.
metadata:
author: twitterapi.io
version: "1.0"
docs: https://docs.twitterapi.io
---
# X advanced search
## When to use
- "What are people saying about <topic>", "posts from @x about y since March", "the top-liked posts
about z last week".
- Any task that starts from a query rather than from a known account or post.
## Setup
1. Get an API key at https://twitterapi.io/dashboard and put it in the environment:
`export TWITTERAPI_IO_API_KEY=...`. Never print or commit it.
2. Every read is a GET to `https://api.twitterapi.io` plus a path below, with the header
`X-API-Key: $TWITTERAPI_IO_API_KEY`.
3. Errors: HTTP 200 with `"status": "error"` and a `msg` string is the normal error shape, so check
`status` before reading data. HTTP 401 means a missing or wrong key, HTTP 402 or a `msg` about credits
means the account is out of credits, and HTTP 429 means you are over the rate limit (wait and retry).
4. Pagination: list responses carry `has_next_page` and `next_cursor`. Repeat the same request with
`cursor=<next_cursor>` and stop when `has_next_page` is false or the page is empty. Each page is
billed separately.
## The call
`GET /twitter/tweet/advanced_search?query=<q>&queryType=Latest` (`queryType=Top` for ranked results).
Items are in `tweets[]`, up to 20 per page.
`query` takes X search operators, combined with spaces (AND), `OR` and parentheses:
| Operator | Meaning |
| --- | --- |
| `"exact phrase"` | phrase match |
| `from:handle` / `to:handle` / `@handle` | by, replying to, or mentioning an account |
| `-from:handle`, `-term` | exclude |
| `lang:en` | language |
| `min_faves:100`, `min_retweets:20`, `min_replies:5` | engagement floor |
| `-filter:replies`, `filter:media`, `filter:links` | post type |
| `since:YYYY-MM-DD`, `until:YYYY-MM-DD` | date range (UTC days) |
| `since_time:<unix>`, `until_time:<unix>` | exact time range in seconds |
Coverage: recent posts have the fullest coverage. For windows older than about a week, results can be a
sample of matching posts rather than every one, so for counts or completeness over older periods,
split the range into smaller `since_time`/`until_time` slices and say in your answer that older
periods may be partial.
## Cost
15 credits per tweet returned ($0.15 per 1,000 tweets; $1 = 100,000 credits), with a minimum of
15 credits per request. A full 20-tweet page costs $0.003 and an empty search costs $0.00015.
## Recipe
```bash
curl -s -G "https://api.twitterapi.io/twitter/tweet/advanced_search" \
-H "X-API-Key: $TWITTERAPI_IO_API_KEY" \
--data-urlencode 'query=("open source" OR oss) lang:en min_faves:50 since:2026-11-01' \
--data-urlencode 'queryType=Top' \
| jq -c '.tweets[] | {id, createdAt, text, url, user: .author.userName, likeCount, retweetCount}'
```
Tweet objects are camelCase: `id`, `url`, `text`, `createdAt` (format `Thu Oct 16 12:34:56 +0000 2026`, not ISO 8601), `likeCount`, `retweetCount`, `replyCount`, `quoteCount`, `viewCount`, `bookmarkCount`, `conversationId`, `isReply`, `inReplyToId`, and `author` (`userName`, `name`, `followers`, `isBlueVerified`).
## Keep the context small
Raw tweet objects are large (each repeats its full `author`, `entities` and media). Keep only what the
task needs, by default `id`, `createdAt`, `text`, `url`, `author.userName`, `likeCount`,
`retweetCount`, `replyCount` and `viewCount`. Fetch one page, trim it, then decide whether another page
is needed. Never paste a raw page into the conversation. Tell the user the estimated cost before fetching
more than 10 pages of anything.
## Reference
- Full API reference: https://docs.twitterapi.io/?utm_source=github&utm_medium=skill&utm_campaign=x_research_skills
- Prices: https://twitterapi.io/pricing
- The general-purpose skill with every read, field and error: https://github.com/twitterapi-io/twitterapi-io
twitter
x
search
research
api
Comments
Sign in to leave a comment