# 微信文章转存 API Documentation

> 传入微信公众号文章链接，同步返回标题、作者、公众号、发布时间、Markdown/纯文本正文和正文图片。成功转存扣 2 算力，失败不扣费。

## Overview

This document describes how to call the **微信文章转存** API.

- **Model / path slug**: `content/wechat-archive`
- **Task type**: `sync` (`sync` = synchronous, `async` = create task then poll / callback)
- **HTML docs**: `/doc/61`

## Authentication

All API requests require your platform API key as the query parameter `key`:

```
?key=YOUR_API_KEY
```

Get API Key:
1. Sign in to the console
2. Open [API Key Management](/user/key) and create or copy your key
3. Append `key=YOUR_API_KEY` to the request URL (or pass it in form/JSON when the endpoint accepts it)

---

## API Information

- **URL**: `POST https://xiaoapis.com/api/content/wechat-archive`
- **Content-Type**: `application/json` (request body commonly `application/json` or `application/x-www-form-urlencoded` for POST)
- **HTTP Method**: `POST`

### Request Parameters

| Parameter | Required | Description |
|-----------|----------|-------------|
| `url` | Yes | 微信公众号文章链接 |
| `format` | Yes | markdown、text 或 both，默认 both |
| `timeout` | Yes | 超时秒数，5 到 60，默认 20 |

> **Note**: `key` (API key) is required for authenticated calls even if omitted from the parameter list above.

### Request Example

```
POST https://xiaoapis.com/api/content/wechat-archive
```

## Details

## 接口说明：

同步转存**微信公众号文章**。传入文章链接后，立即返回标题、作者、公众号名称、发布时间、Markdown 正文、纯文本正文，以及正文图片地址。支持完整 URL，以及带链接的分享文字（自动提取其中的 http(s) 地址）。转存失败不扣费。

本接口只读取公开文章并整理成文本，不存储、不复制、不分发原文。内容版权归原作者及原公众号所有，仅供个人备份、内容审核、知识库入库、学术研究等合理使用。

**计费：**每次成功转存扣 `2` 算力；参数错误、正文为空或转存失败不扣费。

## 请求HEADER：

| 名称 | 值 |
| --- | --- |
| Content-Type | application/json 或 application/x-www-form-urlencoded |

## 请求参数说明：

| 名称 | 必填 | 类型 | 示例值 | 说明 |
| --- | --- | --- | --- | --- |
| key | 是 | string | 你的密钥 | 平台 API 密钥 |
| url | 是 | string | https://mp.weixin.qq.com/s/... | 微信公众号文章链接，最大 2048 字符。兼容 content、link；可粘贴带网址的分享文字 |
| format | 否 | string | both | 输出格式：markdown 只返回 Markdown，text 只返回纯文本，both 两者都返回。默认 both |
| timeout | 否 | int | 20 | 超时秒数，5 到 60。默认 20 |

只接受 POST。表单或 JSON 均可，参数放在请求体里。

## 返回参数说明：

| 名称 | 类型 | 说明 |
| --- | --- | --- |
| code | int | 状态码，200 表示成功 |
| msg | string | 状态信息 |
| data.title | string | 文章标题 |
| data.author | string | 作者 |
| data.account_name | string | 公众号名称 |
| data.publish_time | string | 发布时间 |
| data.read_num | int 或 null | 阅读量，没有则为 null |
| data.like_num | int 或 null | 点赞或在看数，没有则为 null |
| data.markdown | string | Markdown 正文。format 为 text 时为空字符串 |
| data.text | string | 纯文本正文。format 为 markdown 时为空字符串 |
| data.images | array | 正文图片。元素含 url、size_bytes |
| data.format | string | 本次实际使用的输出格式 |
| data.request_url | string | 本次转存的文章链接 |

## Response Example

```json
{
    "code": 200,
    "msg": "转存成功",
    "data": {
        "title": "示例标题",
        "author": "作者名",
        "account_name": "公众号名",
        "publish_time": "2026-05-01T10:00:00+08:00",
        "read_num": null,
        "like_num": null,
        "markdown": "# 示例标题 正文",
        "text": "示例标题 正文",
        "images": [
            {
                "url": "https://你的域名/article.jpg",
                "size_bytes": 45000
            }
        ],
        "format": "both",
        "request_url": "https://mp.weixin.qq.com/s/示例"
    }
}
```

## Error Codes

| 业务码 | 说明 |
| --- | --- |
| 200 | 转存成功 |
| 400 | 参数错误、链接不是公众号文章，或未能读取到正文。此类错误不扣费 |
| 403 | 认证失败，请检查 key |
| 500 | 文章暂时无法转存，或服务配置异常。此类错误不扣费，请稍后重试 |

## Usage Flow

1. Obtain your API Key from the console
2. Call the endpoint with `key` and required parameters
3. Parse the JSON (or binary) response according to the examples above

---

_Generated for AI / LLM consumption. Source of truth: `api_list` (same as HTML `/doc/{id}`)._
