This Twitter account lookup app is a small tool for X: type a public username and get a profile card, that account's recent posts, a posts-per-day count, the median likes and a CSV. It is for developers, marketers and researchers who want account data without an X account or X API setup. It uses one Desearch endpoint and the Python standard library.
The problem
Sizing up an X account by hand means opening the profile, scrolling the timeline and counting posts and likes yourself. Getting the same data into a spreadsheet takes even longer. When you check several accounts, for partners, creators or competitors in your market, that adds up fast. A lookup that returns the profile and recent posts as data makes it a one-step job.
What the app does
- Accepts a username or an
x.com/nameprofile link. - Shows a profile card: name, bio, followers, following, total posts and join date.
- Lists recent posts with time (UTC), kind (post, reply, repost), text, likes, replies, reposts, views and a link.
- Follows the cursor for up to 3 pages in total, about 50 posts, and drops repeated posts.
- Computes posts per day, median likes and the first and last post time.
- Exports the same lookup as CSV. A username with no public account shows a "not found" page.
How it works
- Check the username. 1 to 15 letters, digits or underscores, and pages 1 to 3. A bad form gets HTTP 400 before any call.
- Get the profile and posts.
GET /twitter/user/posts?username=<name>returnsuser,tweetsandnext_cursor. - Page back. Send
cursor=<next_cursor>for older posts, up to 3 pages, and dedupe by post id. - Compute and show. Build the card, the post rows and the stats, then serve the HTML page or the CSV.
The code
The core call, copied from app.py. The key is read from the DESEARCH_API_KEY env var:
def api_key():
k = os.environ.get("DESEARCH_API_KEY")
if not k and os.environ.get("DESEARCH_API_KEY_FILE"):
k = pathlib.Path(os.environ["DESEARCH_API_KEY_FILE"]).read_text().strip()
if not k:
sys.exit("Set DESEARCH_API_KEY or DESEARCH_API_KEY_FILE")
return kuser_posts sends that key on GET /twitter/user/posts:
url = BASE + "/twitter/user/posts?" + urllib.parse.urlencode(params)
req = urllib.request.Request(url, headers={"Authorization": self.key, "User-Agent": UA})params in core.py builds the query, and adds cursor when paging:
def params(username, cursor=None):
p = {"username": username}
if cursor:
p["cursor"] = cursor
return pThe response is one JSON object with user (name, bio, followers, following, total posts, join date), tweets (recent posts with text, time, likes, replies, reposts and views) and next_cursor.
The folder layout:
core.py: username check, paging rules, profile card, post rows, stats, CSV and HTML. No network.app.py: the HTTP server, the CLI and the Desearch client.test_core.py: offline tests.samples/: one lookup page, its CSV and a short lookup summary.
Endpoints
GET /twitter/user/posts
Example output
A lookup on 2026-10-16 at 15:06 (Asia/Tbilisi) of the Desearch org account, desearch_ai, with 3 pages. This page shows that stored lookup.
| What came back | Value |
|---|---|
| Followers / following | 1,725 / 76 |
| Total posts on the account | 681 |
| Joined | 2025-01-14 |
| Posts returned over 3 pages | 48 |
| Time span | 2026-09-24 to 2026-10-15 (UTC) |
| Posts per day | 2.29 |
| Median likes | 4 |
The full lookup is in samples/page.html, samples/posts.csv and samples/lookup-summary.json.
Run it yourself
Clone desearch-py-examples and open x-user-lookup-app. Then run:
python3 -m pip install -r requirements.txt # only pytest, for the tests
export DESEARCH_API_KEY=your_key # or DESEARCH_API_KEY_FILE=/path/to/key
python3 app.py --port 8000 # open http://127.0.0.1:8000
python3 app.py --cli desearch_ai --pages 3 --csv desearch_ai-posts.csv # or as a CLI--cli desearch_ai: run one lookup from the command line.--pages 3: how many pages of posts to fetch, 1 to 3.--csv desearch_ai-posts.csv: save the posts as a spreadsheet.
What it costs
Measured on 2026-10-16 from the X-Desearch-Cost-Usd header: $0.00015 per post returned, so a page of 16 to 18 posts cost $0.0024 to $0.0027 and the 3-page sample lookup cost $0.00765. A username with no account cost $0 in the same test. See pricing.
Try it
Open the live lookup. Type a public X username to get the profile card and recent posts with likes, replies, reposts and views. Repeat lookups are served from a cache at no extra cost.
Ideas to extend it
The CSV gives marketers and researchers a way to review recent posts outside the profile card. The card keeps the public profile fields beside the account activity summary. Posts per day and median likes describe the returned posts, while the post links let readers open the originals.
- Look up a list of accounts from a CSV and compare posts per day and median likes.
- Save a lookup each week to see how an account's posting changes.
- Add a chart of likes per post over the returned period.
