ナビゲーションにスキップ

What changed on a peer’s X account, and which newly observed posts deserve follow-up?

To follow a public X account, save page one of the account’s timeline from twitter.web.fetch_user_post_tweet as the baseline. In each later check, fetch page one again and run watch_account.py to match post IDs against the saved state. Record publication time and discovery time separately, then select the product updates, events or discussions worth following up.

For example, if an older pinned post first appears today, label the post “Older post discovered today.” For a newly published release notice, share the original post and the effective date with the team.

Establish a baseline before treating a whole page as news

Verify that the handle belongs to the intended public account, and save the account’s homepage response and the actual observation time. The first new-posts.csv contains only headers because the first run establishes the starting point; empty rows do not mean the account has no content. Each later run continues from the latest accepted state, and every earlier export stays in place.

If a handle changes, is reused or becomes uncertain, verify the account identity and start a new baseline; watch_account.py does not prove ownership continuity on its own. To reorganize data, compare saved responses locally instead of buying another homepage request.

Which newly observed items deserve a teammate’s attention?

Use the table as a review guide for common changes:

Observed changeWhat to checkHow to describe the change
Product or event announcementExact text, date and availability conditionsWhat was publicly announced, why it matters and the next verification.
A first-seen item with an old publication dateWhether the post only entered the observed homepage in this roundNewly observed old material, not a new publication today.
A retweet of someone else’s contentThe target’s action versus the original author’s statementDo not attribute the entire announcement or view to the target account.
Pinned changes or an old ID missing from the homepageSeparate pinned evidence, coverage and raw filesAbsence is not deletion, and pinning does not establish new publication.
No new candidates this roundSuccessful collection and the page actually coveredNo newly observed IDs in this round, not proof of no posts during the interval.

A person decides relevance. High engagement is not automatically a business opportunity, and one account’s activity does not show industry growth.

Hand over a change brief that supports further research

Keep the account, the observation times, the newly observed IDs, the source posts, the specific change, the business relevance, and the next check. new-posts.csv is a candidate list. Add editorial reasons, owner, and processing status in a separate working copy; watch_account.py does not populate editorial reasons, owner, or status columns.

Read the round’s coverage.json, inspect the original evidence, and only then accept the round’s new state.json. Checking only the homepage can miss posts published between observations. A historical backfill needs a separately approved scope and must not become the next routine checkpoint. State the homepage-only limit in the brief, so that “not observed” is not mistaken for “did not happen”.

For a watch list of 20 accounts, keep a separate baseline and last successful time for each account. If one account’s lookup fails, report the other accounts’ changes and mark the failed account for follow-up. When the failed account’s lookup works again, compare the account with the account’s own last valid state.

Choose an observation cadence and estimate scope

Request another account observation only when you need one. Budget the cost as account count × rounds × current action price; extra pages, retries, model analysis and message delivery are separate costs. Do not raise the frequency automatically because a page is short; choose an approved cadence from the research question and the omissions you can accept.

Steps 1–6 below implement collection and comparison. watch_account.py never buys queries on its own; collecting new pages and sending a digest are separate actions you decide on.

1. Choose the account and cap the cost

Checking page one for 20 accounts daily for 30 days takes 600 list requests. Count additional pages and model usage separately. See BeatAPI pricing.

Pass the account name as screen_name, without @ and without a full profile URL. twitter.web.fetch_user_post_tweet also accepts integer rest_id, and rest_id takes precedence when both are sent, so the workflow sends only screen_name. twitter.web.fetch_user_post_tweet has no tab parameter. Replies, media-only feeds and keyword mentions are not interchangeable with an account’s post timeline.

2. Save one homepage observation

Save request.json with the intended handle:

{"action":"twitter.web.fetch_user_post_tweet","params":{"screen_name":"<account_handle>"}}

After approving the query, save the original response and the headers in a new directory:

mkdir x-observation-1 && \
curl --fail-with-body -sS https://api.beatapi.io/v1/social-data/call \
-H "Authorization: Bearer $BEATAPI_API_KEY" \
-H 'Content-Type: application/json' \
--data-binary @request.json \
-D x-observation-1/response.headers \
-o x-observation-1/response.json

Record the real HTTP status and a collection time with a timezone. An error leaves the previous monitoring state unchanged; keep the failed raw file and do not retry automatically. Use the complete direct response, not the first few items of an AI preview.

Save observation.json next to the response directory. Replace all illustrative values with your actual request and observation:

{"action":"twitter.web.fetch_user_post_tweet","params":{"screen_name":"<account_handle>"},"http_status":200,"collected_at":"2026-11-17T09:00:00+08:00","response_file":"x-observation-1/response.json"}

3. Establish a baseline, then compare the next saved page

Save the script below as watch_account.py, then run the script in two stages:

  1. For the first saved page, run python3 watch_account.py observation.json - x-baseline. The hyphen means no previous state: every returned timeline item becomes the baseline, and new-posts.csv contains headers only.
  2. For each later observation, run python3 watch_account.py observation-next.json x-baseline/state.json x-next. Pass the latest accepted state.json path on the next run, and never overwrite the previous output folder.
import csv
import hashlib
import json
import re
import sys
from datetime import datetime
from pathlib import Path
manifest, previous, output = sys.argv[1:]
manifest = Path(manifest)
entry = json.loads(manifest.read_text(encoding='utf-8'))
params = entry.get('params')
action = 'twitter.web.fetch_user_post_tweet'
if entry.get('action') != action or not isinstance(params, dict) or set(params) != {'screen_name'}:
raise ValueError('Use one account homepage request: screen_name only, no cursor/rest_id')
handle = params['screen_name']
if not isinstance(handle, str) or not re.fullmatch(r'[A-Za-z0-9_]{1,15}', handle):
raise ValueError('Use the handle without @ or a URL')
scope = handle.lower()
stamp = datetime.fromisoformat(entry['collected_at'].replace('Z', '+00:00'))
if stamp.utcoffset() is None: raise ValueError('Record timezone-aware collection time')
if type(entry.get('http_status')) is not int or entry['http_status'] != 200:
raise ValueError('HTTP failure: preserve the response and keep the previous state')
source = (manifest.parent / entry['response_file']).resolve()
raw = source.read_bytes()
response = json.loads(raw)
if not isinstance(response, dict) or response.get('status') != 'succeeded' or response.get('action') != action or response.get('error') is not None:
raise ValueError('Unsuccessful account response; state must not advance')
request_id = response.get('request_id')
if not isinstance(request_id, str) or not request_id.strip(): raise ValueError('Missing request_id')
data = response.get('data')
if not isinstance(data, dict) or not isinstance(data.get('timeline'), list):
raise ValueError('Expected the complete direct data.timeline array')
old = None
seen = set()
old_requests = []
if previous != '-':
old = json.loads(Path(previous).read_text(encoding='utf-8'))
if not isinstance(old, dict) or old.get('version') != 1 or old.get('screen_name') != scope or not isinstance(old.get('seen_ids'), list) or not isinstance(old.get('request_ids'), list):
raise ValueError('State belongs to another workflow or account')
def identifier(value): return isinstance(value, str) and value.isascii() and value.isdigit() and any(c != '0' for c in value)
if any(not identifier(v) for v in old['seen_ids']) or len(old['seen_ids']) != len(set(old['seen_ids'])):
raise ValueError('Invalid seen-ID state')
old_requests = old['request_ids']
if any(not isinstance(v, str) or not v.strip() for v in old_requests) or len(old_requests) != len(set(old_requests)):
raise ValueError('Invalid request history')
last = datetime.fromisoformat(old['last_collected_at'].replace('Z', '+00:00'))
if last.utcoffset() is None or stamp <= last or request_id in old_requests:
raise ValueError('Use a later new observation, not a replay or reordered response')
seen = set(old['seen_ids'])
rows, page_ids, duplicates = [], set(), 0
metrics = ['favorites', 'retweets', 'replies', 'quotes', 'bookmarks', 'views']
def count(value):
if value is None: return ''
if type(value) is int and 0 <= value <= 9007199254740991: return value
if isinstance(value, str) and value.isascii() and value.isdigit(): return value
raise ValueError('Expected a nonnegative safe integer or original digit string counter')
for post in data['timeline']:
if not isinstance(post, dict): raise ValueError('Unexpected timeline item')
key = post.get('tweet_id')
if not isinstance(key, str) or not key.isascii() or not key.isdigit() or not any(c != '0' for c in key):
raise ValueError('Original string tweet_id required; numeric IDs cannot be repaired')
author = post.get('author')
if author is not None and not isinstance(author, dict): raise ValueError('Invalid author object')
author_id = (author or {}).get('rest_id')
if author_id is not None and (not isinstance(author_id, str) or not author_id.isascii() or not author_id.isdigit()):
raise ValueError('Preserve original string author rest_id')
for field in ['text', 'created_at', 'lang', 'reply_to']:
if post.get(field) is not None and not isinstance(post[field], str): raise ValueError('Unexpected text field')
state = 'baseline' if old is None else ('seen_before' if key in seen else 'newly_observed')
row = {'tweet_id': key, 'status': state, 'requested_screen_name': handle, 'author_rest_id': author_id,
'text': post.get('text'), 'created_at': post.get('created_at'), 'lang': post.get('lang'),
'reply_to': post.get('reply_to'), 'has_retweeted_object': post.get('retweeted_tweet') is not None,
'collected_at': entry['collected_at'], 'request_id': request_id}
row.update({k: count(post.get(k)) for k in metrics})
if key in page_ids:
duplicates += 1
continue
page_ids.add(key)
rows.append(row)
cursor = data.get('next_cursor')
if cursor is not None and not isinstance(cursor, str): raise ValueError('Unexpected next_cursor type')
next_cursor = cursor if cursor and cursor.strip() else None
new_rows = [row for row in rows if row['status'] == 'newly_observed']
state = {'version': 1, 'screen_name': scope, 'seen_ids': sorted(seen | page_ids),
'request_ids': old_requests + [request_id], 'last_collected_at': entry['collected_at']}
report = {'mode': 'baseline' if old is None else 'compare', 'screen_name': handle,
'returned_items': len(data['timeline']), 'unique_ids_this_page': len(page_ids), 'duplicates_this_page': duplicates,
'newly_observed': len(new_rows), 'previous_ids_not_on_this_page': len(seen - page_ids),
'source_file': str(source), 'source_sha256': hashlib.sha256(raw).hexdigest(),
'request_id': request_id, 'collected_at': entry['collected_at'], 'next_cursor': next_cursor,
'coverage': 'first page only; no claim of all posts since the previous run',
'pinned_saved_separately': 'pinned' in data, 'network_calls': 0}
output = Path(output)
output.mkdir(parents=False, exist_ok=False)
def cell(value):
if value is None: return ''
value = str(value)
return "'" + value if value.lstrip().startswith(('=', '+', '-', '@')) else value
columns = ['tweet_id', 'status', 'requested_screen_name', 'author_rest_id', 'text', 'created_at', 'lang', 'reply_to', 'has_retweeted_object'] + metrics + ['collected_at', 'request_id']
for filename, selected in [('observed-posts.csv', rows), ('new-posts.csv', new_rows)]:
with (output / filename).open('x', encoding='utf-8-sig', newline='') as f:
writer = csv.writer(f); writer.writerow(columns)
writer.writerows([[cell(row.get(k)) for k in columns] for row in selected])
(output / 'raw-response.json').write_bytes(raw)
for filename, value in [('state.json', state), ('coverage.json', report), ('profile.json', data.get('user')), ('pinned.json', data.get('pinned'))]:
(output / filename).write_text(json.dumps(value, ensure_ascii=False, indent=2) + '\n', encoding='utf-8')
if next_cursor and page_ids:
(output / 'backfill-request.json').write_text(json.dumps({'action': action, 'params': {'screen_name': handle, 'cursor': next_cursor}}, indent=2) + '\n', encoding='utf-8')
print(json.dumps({'mode': report['mode'], 'newly_observed': len(new_rows), 'output': str(output)}))

watch_account.py runs offline. Before creating outputs, the script validates the account scope, time ordering, request replay, string IDs, reported counters and response structure. A changed counter on the same ID is not a new post. Every unique item on the current page goes into observed-posts.csv; for an ID repeated within the page, the script keeps the first row, and raw-response.json keeps every occurrence.

4. Read the result correctly

  • new-posts.csv: newly observed IDs relative to your stored state, not proof of publication since yesterday. An old post newly surfaced by the platform can appear here.
  • observed-posts.csv: the current page with baseline/seen_before/newly_observed labels, text, reported publication time, metrics and query provenance. Missing counters stay blank and reported zero stays zero.
  • profile.json and pinned.json: separate copies of the original data.user and data.pinned objects. The timeline author’s name and screen_name were null in the observed contract, so the script does not fill the author columns with the requested account’s name. A repost can refer to someone else’s content; has_retweeted_object marks that the repost’s original object is present, and the original object stays in the raw JSON.
  • coverage.json: the current page’s counts, the raw-source hash and the continuation cursor. Previously seen IDs that are absent now are not labeled deleted. The hash detects changes to the saved source; the hash does not authenticate the account identity and is not a tamper-proof history.
  • state.json: the cumulative seen IDs and accepted request IDs for the handle. A renamed or reassigned handle needs a new reviewed baseline; watch_account.py does not validate account ownership continuity on its own.

A pinned post is not added to the new-post list only because the post is pinned. If the same ID also appears in the timeline, normal deduplication applies. Do not replace missing author fields, views or text with guesses.

5. Make gaps and continuation explicit

Each new monitoring run starts at the account homepage without a cursor. Do not reuse yesterday’s cursor as today’s starting point, and do not stop processing the page at the first known ID: pinning or mixed ordering can put older IDs before new ones.

One first page per day can miss posts from a busy account. watch_account.py records next_cursor and, for a nonempty page, writes backfill-request.json. backfill-request.json proposes a request for an older page with its own budget; the script never sends the request. Keep backfilled historical responses as a separate collection. watch_account.py rejects requests with a cursor, so a backfilled page cannot silently become the next daily checkpoint. When missed posts would matter, use a higher approved frequency or a separately specified backfill workflow. Neither a missing cursor nor an empty page proves that all history was covered.

6. Hand off an actionable digest

  1. Review new-posts.csv for relevant changes, and add why each item matters.
  2. Link each item as https://x.com/i/status/<tweet_id> with the preserved ID.
  3. Summarize the selected public business activity; leave out personal whereabouts and inferred private attributes.
  4. Record the sampled account, the query time, the unique IDs and the coverage limit in the digest.

watch_account.py does not send the digest to a team or schedule recurring paid requests; configure either action separately.

Before adopting the next state, compare two rows with raw-response.json and inspect coverage.json. Rerunning exports on saved data adds no API charges. Contract basis: the documented output shape of twitter.web.fetch_user_post_tweet; replace the illustrative account handle in the examples with your target public screen_name.

Keyword search · Brand discussion triage · X questions