# Search X (Twitter) from Python with one HTTP request and one key

In Python, POST to the RouterGrowth run endpoint with social.search, platform x and your keyword, and read the posts from the JSON. There is no tweepy install, no X developer app or bearer token from X, and the same request works for Reddit and LinkedIn by changing one field.

HTML page: https://www.routergrowth.com/tools/x-twitter/api-python
Part of: [X (Twitter) tools](https://www.routergrowth.com/tools/x-twitter.md)

## The call

[`social.search`](https://www.routergrowth.com/catalog/social.search): Public posts matching a keyword on X, LinkedIn, Reddit, YouTube, TikTok, Instagram or Facebook: brand mentions, category conversations, competitor chatter.

Price on this network: $0.0007 per post, $0.002 minimum a call. The exact quote is shown before every run.

## What a real run returned

Run on 2026-10-19: 10 records in 5.3 s for $0.007. Personal fields are masked. Ten of the newest posts for python automation: course offers, job posts and learning threads, all from the same morning.

| text | likes | views | posted |
|---|---|---|---|
| Stop building AI that just answers questions. Build AI that does the work with these automation projects. https://t.co/XINeHtUgDg | 8 | 428 | 2026-10-19 |
| Mastering Python Network Automation by GitforGits / Asian Publishing House is on sale on Leanpub! Its suggested price is $29.99; get it for… | 0 | 52 | 2026-10-19 |

## How to do it

1. **Store your key.** Put the RouterGrowth key in an environment variable and send it as a Bearer header.
2. **POST the search.** Body: capability social.search, input with platform x, query and limit. requests, httpx or aiohttp all work.
3. **Read result.posts.** Each item has text, engagement, created_at, url and author_url.
4. **Schedule it.** Run the script from cron or a notebook and append new posts by URL to your dataset.

## Ask it like this

- Write a Python script that searches X for python automation every hour and appends new posts to a CSV. (`social.search`)
- In Python, search X for a keyword, then pull the last ten posts from the three accounts that posted most. (`social.search`, `social.posts`)

## Connect

MCP server: `https://api.routergrowth.com/mcp`

```bash
claude mcp add --transport http routergrowth https://api.routergrowth.com/mcp
```

```bash
npm install -g routergrowth && routergrowth setup
routergrowth run -c social.search -i '{"platform": "x", "query": "python automation", "limit": 10}'
```

```bash
curl -X POST https://api.routergrowth.com/v1/run \
  -H "Authorization: Bearer $ROUTERGROWTH_API_KEY" \
  -d '{"capability": "social.search", "input": {"platform": "x", "query": "python automation", "limit": 10}}'
```

## Worth knowing

- **No tweepy needed.** tweepy wraps X's own API and its credentials. This is a plain JSON API, independent of X.
- **Mixed languages.** Keyword search returns posts in any language. Add language words or filter on text if you need English only.
- **Read only.** Nothing in the call posts or likes on X.

## Questions

### Is there an official Python client?

None is needed. The REST API takes JSON, and the routergrowth CLI covers shell use.

### Can I use async?

Yes. Any async HTTP client can send the same request.

### How fresh are the posts?

The search returns the newest public posts it finds at call time.

### Does it work for Reddit too?

Yes. Set platform to reddit in the same request.

## Related

- [An API that searches X posts by keyword and returns them with their numbers](https://www.routergrowth.com/tools/x-twitter/search-tweets-api.md)
- [Scrape a public X (Twitter) profile: followers, bio, website and category](https://www.routergrowth.com/tools/x-twitter/profile-scraper.md)
- [How X (Twitter) data is priced on RouterGrowth: per post, no plan](https://www.routergrowth.com/tools/x-twitter/api-prices.md)
- [Scrape X (Twitter) posts that match a keyword, in one call](https://www.routergrowth.com/tools/x-twitter/scraper.md)
- [Read any public X account's recent posts through one independent API](https://www.routergrowth.com/tools/x-twitter/api.md)
