WeChat Official Accounts Account Historical Articles API (V2)
Retrieves historical articles for a WeChat Official Account identified by ghid or article URL, with an offset cursor from the previous page. Use it to continue through an account's article archive with cursor pagination.
Request Body
| Name | In | Type | Required | Default | Description |
|---|---|---|---|---|---|
token | form | string | Yes | - | Access token for this API service. |
ghid | form | string | No | | WeChat Official Account original identifier, using the gh_ prefix returned by WeChat. Use either ghid or url. |
url | form | string | No | | WeChat Official Account article URL used to identify the account and fetch historical articles. Use either ghid or url. |
offset | form | string | No | | PagingInfo.Offset cursor returned by the previous response. Leave it empty for the first page. For this POST endpoint, send it in an application/x-www-form-urlencoded form body. |
Code Samples
curl --max-time 120 -X POST 'https://api.justoneapi.com/api/weixin/get-account-history-articles/v2' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'token=YOUR_API_KEY&ghid=&url=&offset='I want to use the "Account Historical Articles (V2)" API from JustOneAPI.
Base URL: https://api.justoneapi.com.
API Path: /api/weixin/get-account-history-articles/v2
API Endpoint: BASE_URL + /api/weixin/get-account-history-articles/v2
HTTP Method: POST
Authentication: Send "token" as an application/x-www-form-urlencoded body field.
OpenAPI Definition: https://docs.justoneapi.com/openapi/wechat-official-accounts/account-historical-articles-v2-en.json
Request headers:
- Content-Type: application/x-www-form-urlencoded
Request Body (Form):
- token (form): Access token for this API service. (Required)
- ghid (form): WeChat Official Account original identifier, using the gh_ prefix returned by WeChat. Use either ghid or url.
- url (form): WeChat Official Account article URL used to identify the account and fetch historical articles. Use either ghid or url.
- offset (form): PagingInfo.Offset cursor returned by the previous response. Leave it empty for the first page. For this POST endpoint, send it in an application/x-www-form-urlencoded form body.
Return format: safely handle JSON or text according to the actual Content-Type.
Response Handling & Error Codes:
1. Business results should be determined by the "code" field in the response body (code 0 means success).
2. Timeout Recommendation: Set the request timeout to 120 seconds. If 120 seconds is too long for your use case, use at least 60 seconds, but a small number of requests may time out before receiving a result.
3. Business Code Reference:
- 0: Success
- 100: Invalid or Inactive Token
- 301: Collection Failed. Please Retry.
- 302: Rate Limit Exceeded
- 303: Daily Quota Exceeded
- 400: Invalid Parameters
- 500: Internal Server Error
- 600: Permission Denied
- 601: Insufficient Balance
- 602: Token Budget Exceeded
4. Code 601 means the shared account balance is insufficient. Code 602 means the current API token's own cumulative budget limit has been reached. Token budget limits do not transfer funds out of the shared account balance.
Please help me write a script in my preferred programming language to call this API and handle the response.import requests
BASE_URL = "https://api.justoneapi.com" # Provided by OpenAPI servers
url = BASE_URL + "/api/weixin/get-account-history-articles/v2"
headers = {
"Content-Type": "application/x-www-form-urlencoded"
}
data = "token=YOUR_API_KEY&ghid=&url=&offset="
response = requests.post(url, headers=headers, data=data, timeout=120)
print(response.status_code)
if response.content:
content_type = response.headers.get("content-type", "").lower()
if "json" in content_type:
try:
print(response.json())
except ValueError:
print(response.text)
elif content_type.startswith("text/") or "xml" in content_type or content_type.split(";", 1)[0].strip() in {"application/javascript", "application/x-www-form-urlencoded", "application/graphql"}:
print(response.text)
else:
with open("response.bin", "wb") as output:
output.write(response.content)
print(f"Saved {len(response.content)} bytes to response.bin")const BASE_URL = "https://api.justoneapi.com"; // Provided by OpenAPI servers
const url = BASE_URL + "/api/weixin/get-account-history-articles/v2";
const response = await fetch(url, {
method: "POST",
headers: Object.fromEntries([
["Content-Type", "application/x-www-form-urlencoded"],
]),
body: "token=YOUR_API_KEY&ghid=&url=&offset=",
signal: AbortSignal.timeout(120000)
});
console.log(response.status);
const responseBytes = await response.arrayBuffer();
if (responseBytes.byteLength) {
const contentType = (response.headers.get("content-type") || "").toLowerCase();
const mediaType = contentType.split(";", 1)[0].trim();
const textual = contentType.startsWith("text/") || contentType.includes("json") || contentType.includes("xml") || ["application/javascript", "application/x-www-form-urlencoded", "application/graphql"].includes(mediaType);
if (textual) {
const responseText = new TextDecoder().decode(responseBytes);
let data = responseText;
if (contentType.includes("json")) {
try { data = JSON.parse(responseText); } catch { /* Keep the raw body. */ }
}
console.log(data);
} else {
console.log(`Received ${responseBytes.byteLength} binary bytes`);
}
}import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
public class Main {
public static void main(String[] args) throws Exception {
final String BASE_URL = "https://api.justoneapi.com"; // Provided by OpenAPI servers
final String url = BASE_URL + "/api/weixin/get-account-history-articles/v2";
HttpClient client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(120)).build();
HttpRequest.Builder builder = HttpRequest.newBuilder()
.uri(URI.create(url))
.timeout(Duration.ofSeconds(120))
.header("Content-Type", "application/x-www-form-urlencoded")
.method("POST", HttpRequest.BodyPublishers.ofString("token=YOUR_API_KEY&ghid=&url=&offset="));
HttpRequest request = builder.build();
HttpResponse<byte[]> response = client.send(request, HttpResponse.BodyHandlers.ofByteArray());
System.out.println(response.statusCode());
String contentType = response.headers().firstValue("content-type").orElse("").toLowerCase();
String mediaType = contentType.split(";", 2)[0].trim();
if (contentType.startsWith("text/") || contentType.contains("json") || contentType.contains("xml") || mediaType.equals("application/javascript") || mediaType.equals("application/x-www-form-urlencoded") || mediaType.equals("application/graphql")) {
System.out.println(new String(response.body(), StandardCharsets.UTF_8));
} else {
Files.write(Path.of("response.bin"), response.body());
System.out.println("Saved " + response.body().length + " bytes to response.bin");
}
}
}package main
import (
"fmt"
"io"
"os"
"strings"
"net/http"
"time"
)
const BASE_URL = "https://api.justoneapi.com" // Provided by OpenAPI servers
func main() {
client := &http.Client{Timeout: 120 * time.Second}
url := BASE_URL + "/api/weixin/get-account-history-articles/v2"
var data = strings.NewReader("token=YOUR_API_KEY&ghid=&url=&offset=")
req, _ := http.NewRequest("POST", url, data)
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
resp, _ := client.Do(req)
defer resp.Body.Close()
fmt.Println(resp.StatusCode)
bodyBytes, _ := io.ReadAll(resp.Body)
contentType := strings.ToLower(resp.Header.Get("Content-Type"))
mediaType := strings.TrimSpace(strings.SplitN(contentType, ";", 2)[0])
if strings.HasPrefix(contentType, "text/") || strings.Contains(contentType, "json") || strings.Contains(contentType, "xml") || mediaType == "application/javascript" || mediaType == "application/x-www-form-urlencoded" || mediaType == "application/graphql" {
fmt.Println(string(bodyBytes))
} else {
os.WriteFile("response.bin", bodyBytes, 0600)
fmt.Printf("Saved %d bytes to response.bin\n", len(bodyBytes))
}
}<?php
$BASE_URL = 'https://api.justoneapi.com'; // Provided by OpenAPI servers
$url = $BASE_URL . '/api/weixin/get-account-history-articles/v2';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, 'token=YOUR_API_KEY&ghid=&url=&offset=');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/x-www-form-urlencoded',
]);
$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
$contentType = strtolower((string) curl_getinfo($ch, CURLINFO_CONTENT_TYPE));
curl_close($ch);
echo $status . PHP_EOL;
$mediaType = trim(explode(';', $contentType, 2)[0]);
if (str_starts_with($contentType, 'text/') || str_contains($contentType, 'json') || str_contains($contentType, 'xml') || in_array($mediaType, ['application/javascript', 'application/x-www-form-urlencoded', 'application/graphql'], true)) {
echo $response;
} else {
file_put_contents('response.bin', $response);
echo 'Saved ' . strlen($response) . ' bytes to response.bin' . PHP_EOL;
}Response Fields
Key fields in a successful response (code = 0).
Articles10 fields
data.MsgList.Msg[].AppMsg.DetailInfo[]
One article in the article message.
| Field | Type | Description |
|---|---|---|
ItemIndex | integer | Position of this article within the message, matching the article URL's idx parameter. |
Title | string | Article title. |
Digest | string | Article summary, which may be empty. |
ShortShowDesc | string | Short description displayed for the article, which may be empty. |
ContentUrl | string | WeChat article URL. |
SourceUrl | string | Source link reported for the article, which may be empty. |
PublishTime | string | Article publication time as text in YYYY-MM-DD HH:mm:ss format (UTC+8), when provided. |
send_time | integer | Article publication time as a Unix timestamp in seconds. |
IsOriginal | integer | Numeric originality indicator reported for the article. |
comment_topic_id | integer | Comment topic identifier reported for the article. |
Reads and likes4 fields
data.MsgList.Msg[].AppMsg.DetailInfo[]
| Field | Type | Description |
|---|---|---|
Read | integer | Read count value reported for the article. |
Zan | integer | Like count reported in the article entry. |
stat_info | object | Optional article statistics. |
stat_info.like_num | integer | Like count reported in the statistics object. It can differ from Zan. |
Cover images12 fields
data.MsgList.Msg[].AppMsg.DetailInfo[]
| Field | Type | Description |
|---|---|---|
CoverImgUrl | string | Main cover image URL. |
CoverImgUrl_16_9 | string | Cover image URL for the 16:9 variant. |
CoverImgUrl_16_9_640 | string | Cover image URL for the 16:9 variant identified as 640. |
CoverImgUrl_1_1 | string | Cover image URL for the square variant. |
CoverImgUrl_235_1 | string | Cover image URL for the 2.35:1 variant. |
coverimgurl_3_4 | string | Cover image URL for the 3:4 variant. |
SuggestedCoverImg | object | Suggested article cover and its size hints. |
SuggestedCoverImg.url | string | Suggested cover image URL. |
SuggestedCoverImg.width_hint | integer | Width hint for the suggested cover. |
SuggestedCoverImg.height_hint | integer | Height hint for the suggested cover. |
preload_picture_info | object | Picture information reported for preloading. |
preload_picture_info.cdn_url | string | CDN URL for the preload picture. |
Message groups12 fields
data.MsgList.Msg[]
One historical message group.
| Field | Type | Description |
|---|---|---|
BaseInfo | object | Metadata for this message group. |
BaseInfo.MsgId | integer | Identifier of the historical message group. |
BaseInfo.DateTime | integer | Timestamp reported for the message group, in Unix seconds. |
BaseInfo.MsgType | integer | Numeric message type code reported for the message group. |
BaseInfo.UniqueId | string | Text identifier reported for this message group. |
AppMsg | object | Article message containing its metadata and individual articles. |
AppMsg.BaseInfo | object | Metadata for the article message. |
AppMsg.BaseInfo.AppMsgId | integer | Article message identifier, matching the mid parameter in its article URLs. |
AppMsg.BaseInfo.Type | integer | Numeric type code reported for the article message. |
AppMsg.BaseInfo.CreateTime | integer | Creation timestamp reported for the article message, in Unix seconds. |
AppMsg.BaseInfo.UpdateTime | integer | Update timestamp reported for the article message, in Unix seconds. |
AppMsg.DetailInfo | array | Individual articles grouped under this article message. |
Pagination6 fields
data
Historical article messages and pagination for the requested WeChat Official Account.
| Field | Type | Description |
|---|---|---|
MsgList.PagingInfo | object | Pagination information inside the message list. |
MsgList.PagingInfo.Offset | string | Cursor text reported inside the message list. |
MsgList.PagingInfo.IsEnd | integer | End-of-list flag reported inside the message list. |
PagingInfo | object | Pagination information for the response. Use this object's Offset for the next request. |
PagingInfo.Offset | string | Opaque cursor for the next page. Pass it unchanged as the offset form value when continuing. |
PagingInfo.IsEnd | integer | Numeric end-of-history flag. Pages that can continue return 0. |
Message list and topics4 fields
data
Historical messages and related information returned for this page.
| Field | Type | Description |
|---|---|---|
MsgList.Msg | array | Message groups returned on this page. Each article message can contain more than one article. |
MsgList.FeaturedList | array | Featured list returned with the message page. It may be empty. |
MsgList.FeaturedUpdateTime | integer | Update timestamp reported for the featured list, in Unix seconds. |
TopicList | array | Topic list returned with the response. It may be empty. |
Account profile9 fields
data
| Field | Type | Description |
|---|---|---|
AccountInfo | object | Public profile of the WeChat Official Account. |
AccountInfo.UserName | string | Original WeChat Official Account identifier with the gh_ prefix. |
AccountInfo.NickName | string | Display name of the WeChat Official Account. |
AccountInfo.HeadImgUrl | string | Profile image URL for the WeChat Official Account. |
AccountInfo.ServiceType | integer | Numeric account type code reported for this profile. |
HasArtile | boolean | Whether the account has articles, as reported by the API. |
IPWording | string | IP location label displayed for the account. |
BanReason | array | Account restriction reasons when provided. The array may be empty. |
VideoFinderInfo | object | WeChat Channels information when provided. The object may be empty. |