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 Twitter account lookup app does
- Accepts
name,@nameor anx.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. It does not run a live demo.
| 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
git clone https://github.com/Desearch-ai/desearch-py-examples && cd desearch-py-examples/x-user-lookup-app
export DESEARCH_API_KEY=... # from console.desearch.ai
python3 app.py --port 8000 # open http://127.0.0.1:8000--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.
Ideas to extend it
- 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.
