Archive a bounded batch of Telegram channel messages
Re-check a single Telegram announcement with telegram.web.fetch_post_detail to detect edits against your saved copy, or archive recent announcements for a weekly brief with telegram.web.fetch_channel_posts, archive_telegram.py, cursor-bounded pagination, and build_archive_report.py. Telegram channel admins can edit published messages, so re-checking an existing announcement is a separate task from finding newly published posts. Telegram Channels
For example, you shared an event announcement on Monday. On Wednesday, someone asks whether the meeting point moved. With the original message link and Monday’s copy, fetch the message again and compare the two versions.
How do I check whether an announcement shared in chat has changed?
Split a link such as t.me/example/123 into the channel username example and the integer message ID 123, and replace both values with the values from your real link. POST the JSON below to https://api.beatapi.io/v1/social-data/call with your BeatAPI Bearer credential.
- Confirm that the response is the announcement you shared.
- Record the message link, the time checked, the previous location, the current location and the request ID.
- If Monday’s copy says Gate A and the latest version says Gate C, share Gate C together with the original link. If you only have the current version, report the current location and the time you checked.
To put several recent announcements into a weekly brief, follow steps 1–7 below.
1. Set a bounded goal
Start with one public channel and one page of recent announcements (limit: 20) for the weekly brief. Every list page and every single-message detail request is billed as a separate request. BeatAPI pricing
2. Fetch the initial batch
Replace <channel_username> with the channel username. If the HTTP request fails, keep the error output and stop; do not run the archive step. Save each later request under a new raw filename.
3. Validate and archive the raw response
Save the script below as archive_telegram.py. archive_telegram.py checks the business status, the action and the data object, validates the cursor types, saves the entire payload and refuses to overwrite an existing archive file.
4. Run and review
The archive file keeps action, request_id and data. Also keep a request manifest with the channel, the paging direction, the parameters and the collection time. A saved payload does not mean every historical message was retrieved. archive_telegram.py only preserves the payload; build_archive_report.py in step 6 extracts the documented message array.
5. Continue only within the budget
- For older messages, pass the printed
before_cursorasbefore. For newer messages, pass the printedafter_cursorasafter. - Keep
channelandlimitunchanged, and save each page under a new filename. - Stop when a cursor is missing or repeated, or when you reach the request cap. A missing cursor is not a reason to request page one again.
Budget each next request separately. Channel search and comments use their own actions, not the before and after pagination parameters.
Identifiers · Pagination and search
BeatAPI sanitizes and passes through data directly, returning data.messages, data.channel_info, and data.pagination with integer before_cursor and after_cursor fields.
6. Share an archive that links back to each response
Hand over four artifacts: the original response pages, the request manifest, the message file message-records.jsonl and the coverage report report.json. build_archive_report.py writes one object from data.messages per JSONL line. To verify an announcement, use the record’s request ID and page position to open the original response page, then open the Telegram message.
Keep the original response for every page. When a teammate opens one message in message-records.jsonl, the request ID and page position lead back to the exact response that contained the message.
Save manifest.json with the actual request-completion time, including the timezone, for each request. Each response_file must name the raw response of that request. The example below shows the expected manifest.json format for one page:
Save the script below as build_archive_report.py, and record the actual parameters for every additional page in manifest.json. build_archive_report.py rejects mixed channels or limits, repeated requests or request IDs, timestamps that do not increase, failed responses and broken cursor chains. The script copies the original bytes, records each file’s SHA-256 and leaves the source files unchanged. message_count in report.json stays null, because a page count is not a message count.
Open report.json and check each source file, request_id, timestamp and returned cursor against the preserved response. A missing or zero cursor ends that direction; zero is the default of the initial request, not permission to start again from page one. Keep older and newer scans in separate batches. Within one batch, keep channel, limit and the paging direction unchanged, let the request times increase, and take each next cursor from the previous saved response. A missing cursor ends the batch and does not prove that the history is complete. The destination directory must not exist yet. If a disk write is interrupted, inspect the partial destination, then retry with a new directory name. build_archive_report.py makes no network calls.
7. Review message records and keep the source of each record
BeatAPI returns messages, channel_info, and pagination under data, so the message array path is data.messages. Each line of message-records.jsonl holds one complete message object plus the channel, request_id, collection time, the raw response’s SHA-256 and the page position.
Open message-records.jsonl in a JSON-lines viewer and work through the records as follows:
- Filter by
request_idorpage_indexto find the raw page a record came from.message_indexis the zero-based position within that page, not a Telegram message ID. - Read
message_recordsas the number of returned occurrences. Overlapping pages stay intact, so two different messages with the same text are never merged. - An empty
messagesarray produces an empty JSONL file; a missingmessagesarray is rejected instead of being reported as zero. - The exact ID and text fields inside each message object are not verified, so the bundle contains no normalized text CSV, and
message_recordsis not a count of unique messages.
Keep channel_info and all other fields in the raw pages. Signed media links are not durable files; do not download or re-host the media without the relevant rights. Before sharing, remove personal data from a copy and keep the original privately.

