Skip to navigation

How do I retrieve WeChat article reads, likes and recommendations separately from its text?

Request a WeChat article URL with standard statistics (wechat_mp.v2.fetch_article_stats) to get the article’s currently reported reads, likes, recommendations and other engagement counts. Make one request per article. Standard statistics do not return the article text, and you do not need the text to get the counts; request the text separately with wechat_mp.v2.fetch_article_detail_h5 only when you need it.

Pass a short article link or the full long link that contains __biz as url. Keep raw:true (the default) to retain the visibility flags and the retrieval status. Set raw:false for simplified counts only.

Fetch one article’s statistics

curl -sS https://api.beatapi.io/v1/social-data/call \
-H "Authorization: Bearer $BEATAPI_API_KEY" \
-H 'Content-Type: application/json' \
-d '{"action":"wechat_mp.v2.fetch_article_stats","params":{"url":"<article_url>","raw":true}}' \
-o wechat-article-stats.json

Use each count with its status

Check for status:succeeded, then read data and keep the request_id and the observation time. In a standard statistics response, read each count field together with its flag:

What you wantCount fieldFlag to check
Readsread_numshow_read
Likes and recommendations (在看)like_count, old_like_countshow_like, show_old_like
Shares and savesshare_count, collect_countshow_share, show_collect
Commentscomment_countcomment_enabled
Starsstar_numshow_star. Keep the returned field name.

Retain retrieval flags such as get_data_succ when the response includes them. Keep display text such as “100k+” as a threshold, and keep the raw number when the response returns 100001. Record missing, hidden, null and failed values as four separate states. Record zero only when the response reports an available numeric zero.

For H5 comment counts, request wechat_mp.v2.fetch_article_stats_h5 to get comment_count and elected_comment_count. Pass comment_id if you have the article’s comment_id, and use raw:true to retain comment_raw. wechat_mp.v2.fetch_article_stats_h5 does not supply reads: the H5 response lists metrics it cannot return in unavailable, so request reads from standard statistics.

Compare articles from the same campaign

Choose the articles and the observation time first:

  1. For a day-seven comparison, save each article’s counts on the day the article is seven days old.
  2. To compare three articles published on different dates with one lookup made today, label the results “Totals observed today” and list each article’s publication date and promotion conditions.
  3. For unique readers or conversion, use an account report you have access to.

For each observation, keep the article URL, the statistics action, the raw value, the status, the collection time and the request ID. To add titles or text, join the saved article sources by verified article identity.

For example, you check one article on Monday and on Wednesday. Confirm that both rows refer to the same article URL and the same statistics action, and keep each row’s observation time and retrieval status. If the Wednesday row has no read count, keep Monday’s value and leave the change blank.

Export a small article review sheet without inventing values

For example, review five known campaign article URLs at a stated time and keep the exact source of each value. One standard statistics request per article is five calls at current pricing. Article text and comments are separate requests, added only where needed.

  1. Run the curl above with --max-time 30 for each article and record the actual HTTP status. A transport timeout does not prove the call was free, so do not retry a timed-out call automatically.
  2. Record each actual request in stats-pages.json in the following format. The timestamp and URL below are placeholders, not a recorded response.
[{"action":"wechat_mp.v2.fetch_article_stats","params":{"url":"https://mp.weixin.qq.com/s/example","raw":true},"http_status":200,"collected_at":"2026-11-16T18:00:00Z","response_file":"wechat-article-stats.json"}]
  1. Save the Python script below as wechat_metrics.py and run python3 wechat_metrics.py stats-pages.json metric-review. wechat_metrics.py runs offline and makes no paid calls. The new metric-review directory contains metric rows, the original responses and their hashes.
import csv, hashlib, json, pathlib, sys
from datetime import datetime
from urllib.parse import urlsplit, parse_qs
manifest, target = map(pathlib.Path, sys.argv[1:3])
entries = json.loads(manifest.read_text(encoding="utf-8"))
if not isinstance(entries, list) or not 1 <= len(entries) <= 100:
raise ValueError("Supply 1–100 saved requests; no network calls are made")
STANDARD = "wechat_mp.v2.fetch_article_stats"
H5 = "wechat_mp.v2.fetch_article_stats_h5"
metrics = {"read_num": "show_read", "like_count": "show_like", "old_like_count": "show_old_like",
"share_count": "show_share", "collect_count": "show_collect", "comment_count": "comment_enabled", "star_num": "show_star"}
rows, sources, request_ids = [], [], set()
def cell(v):
if v is None:
return ""
value = str(v)
return "'" + value if value.startswith(("=", "+", "-", "@", "\t", "\r", "\n")) else value
def classify(value, present):
if not present:
return "missing", None
if value is None:
return "null", None
if isinstance(value, bool):
return "invalid_boolean", None
if type(value) is int:
if value > 9007199254740991:
return "unsafe_numeric", None
return ("reported_integer", str(value)) if value >= 0 else ("invalid_negative", None)
if isinstance(value, str):
return ("reported_integer", value) if value.isascii() and value.isdigit() else ("reported_text", None)
raise ValueError("Unexpected structured or floating metric")
for index, entry in enumerate(entries):
action, params = entry["action"], entry["params"]
if action not in (STANDARD, H5) or type(params.get("raw")) is not bool:
raise ValueError("Use a stats action with explicit raw mode")
allowed = {"url", "raw"} | ({"comment_id"} if action == H5 else set())
if set(params) - allowed:
raise ValueError("Unexpected action parameters")
article_url = params["url"]
if not isinstance(article_url, str) or any(c.isspace() or ord(c) < 32 for c in article_url):
raise ValueError("Invalid public article URL")
u = urlsplit(article_url)
if any(k.lower() in ("key", "uin", "pass_ticket", "ticket", "access_token") for k in parse_qs(u.query, keep_blank_values=True)):
raise ValueError("Use a public share URL without session credentials")
if u.scheme not in ("http", "https") or u.hostname != "mp.weixin.qq.com" or u.username is not None or u.password is not None or u.port not in (None, 80, 443):
raise ValueError("Expected original WeChat article URL")
if u.path == "/s":
query = parse_qs(u.query, keep_blank_values=True)
if any(len(query.get(k, [])) != 1 or not query[k][0] for k in ("__biz", "mid", "idx")):
raise ValueError("Long article URL needs unambiguous __biz/mid/idx")
if not query["mid"][0].isdigit() or not query["idx"][0].isdigit() or int(query["idx"][0]) < 1:
raise ValueError("Invalid article position")
elif not u.path.startswith("/s/") or not u.path[3:] or "/" in u.path[3:]:
raise ValueError("Short article URL needs a nonempty article token")
collected = datetime.fromisoformat(entry["collected_at"].replace("Z", "+00:00"))
if collected.tzinfo is None:
raise ValueError("Collection time requires timezone")
http = entry["http_status"]
if type(http) is not int or not 100 <= http <= 599:
raise ValueError("Record actual integer HTTP status")
source = manifest.parent / entry["response_file"]
raw = source.read_bytes(); result = json.loads(raw)
evidence = {"source": str(source), "sha256": hashlib.sha256(raw).hexdigest(), "params": params,
"action": action, "http_status": http, "collected_at": entry["collected_at"]}
data, failure = {}, None
if http != 200:
error = result.get("error", {})
if not isinstance(error, dict) or not isinstance(error.get("code"), str) or not error["code"].strip():
raise ValueError("Expected gateway error envelope")
request, failure = error.get("request_id"), error["code"]
else:
if result.get("action") != action or result.get("status") != "succeeded" or result.get("error") is not None or not isinstance(result.get("data"), dict):
raise ValueError("Wrong action, failure or missing data object")
request, data = result.get("request_id"), result["data"]
if not isinstance(request, str) or not request.strip() or request in request_ids:
raise ValueError("Missing/repeated successful request ID")
request_ids.add(request)
evidence.update(request_id=request, error_code=failure)
sources.append((evidence, raw))
unavailable = data.get("unavailable", [])
if not isinstance(unavailable, list) or any(not isinstance(x, str) for x in unavailable):
raise ValueError("Invalid unavailable list")
fields = dict(metrics)
if action == H5:
fields["elected_comment_count"] = None
for metric, flag in fields.items():
raw_value = data.get(metric)
state, value = classify(raw_value, metric in data)
if failure:
state, value = "gateway_failed", None
elif metric in unavailable:
state, value = ("unavailable" if raw_value is None else "inconsistent_unavailable"), None
elif action == H5 and metric not in ("comment_count", "elected_comment_count"):
state, value = "unsupported_by_action", None
rows.append({"article_url": article_url, "action": action, "request_id": request,
"collected_at": entry["collected_at"], "metric": metric, "state": state, "value": value,
"raw_value": json.dumps(raw_value, ensure_ascii=False), "visibility_flag": flag,
"visibility_raw": json.dumps(data.get(flag), ensure_ascii=False) if flag else None,
"get_data_succ_raw": json.dumps(data.get("get_data_succ")),
"source_index": index + 1, "error_code": failure})
target.mkdir(exist_ok=False)
with (target / "metrics.csv").open("x", encoding="utf-8-sig", newline="") as f:
writer = csv.DictWriter(f, fieldnames=list(rows[0])); writer.writeheader()
writer.writerows({k: cell(v) for k, v in row.items()} for row in rows)
for index, (_, raw) in enumerate(sources):
(target / ("raw-%03d.json" % (index + 1))).write_bytes(raw)
(target / "evidence.json").write_text(json.dumps({"requests": [x[0] for x in sources],
"exact_audience_claim": False, "automatic_ranking": False,
"note": "reported_integer describes syntax only; inspect source flags and platform thresholds before comparison"}, ensure_ascii=False, indent=2), encoding="utf-8")
print(json.dumps({"requests": len(sources), "metric_rows": len(rows)}))

Read the exported rows as follows:

Column or stateMeaning
value, raw_value, stateThree separate columns. A zero stays a reported integer; absent, null and unavailable stay distinct.
reported_integerThe response returned a bare integer. reported_integer describes the representation, not an exact audience size or the metric’s visibility.
reported_textA textual threshold such as “100k+”. The script does not turn the threshold into a number, and does not read 100001 as 100k-plus.
Empty value for a very large integerA bare integer above the safe numeric range is withheld from value instead of being repaired client-side.
gateway_failedA non-200 response with a valid gateway error envelope; the row keeps the error evidence.

H5 rows never fill a read count. The sheet keeps the raw visibility and retrieval flags and does not rank articles; review the flags and each article’s age at collection before comparing.

wechat_metrics.py stops without writing when a response is an HTTP 200 business failure, when a response is malformed or when the output directory already exists. Keep the original manifest and responses to investigate the stop. Keep the raw files private and share a reviewed or redacted copy. A before/after comparison needs the same article, the same action, the same metric scope and comparable collection times. Do not subtract H5 nulls from standard values, and do not infer sales from reads.

wechat_metrics.py accepts a short link with a nonempty token, or a long link with exactly one nonempty __biz, mid and idx each. The script rejects URLs that contain credentials and keeps the original URL unchanged.

What should a ten-article review contain?

A ten-article review contains the comparable observations, the articles still under review and the unresolved attempts:

  1. Plan ten standard statistics requests at the current price.
  2. After export, select the metric=read_num rows in metrics.csv and check each row against the saved response through article_url and source_index.
  3. Record each interrupted request with no response body as an unresolved attempt.
  4. To add titles and article text, use the saved-source join. The saved-source join handles up to five pairs at a time, so split the ten articles into two batches and put each article in exactly one batch.