Via the dop-api/opendoc API, smart sheet data is obtained directly without relying on browser JS memory.
Cookie Acquisition
Priority: automatic extraction > environment variables > command-line arguments
Method 1: Automatic extraction from the browser (recommended)
Prerequisite: the browser is already logged in to WeCom Docs (any WeCom Docs page open is sufficient).
// 在 browser evaluate 中执行
() => document.cookie
Method 2: Environment variables
export WECOM_COOKIE="utype=ww; TOK=xxx; wedoc_sid=xxx; wedoc_skey=xxx; wedoc_ticket=xxx; ..."
Method 3: Command-line arguments
node scripts/fetch-smartsheet.mjs <url> "<cookie-string>"
Method 4: User provides manually
Guide the user to obtain the Cookie in the browser:
- Open any WeCom Docs page in the browser (such as a smart sheet)
- Press F12 to open Developer Tools
- Switch to the "Console" tab
- Enter
document.cookieand press Enter - Copy the entire output text
Or via the "Network" panel:
- Open Developer Tools → Network tab
- Refresh the page
- Click any
doc.weixin.qq.comrequest - Find the
Cookiefield in Headers and copy the complete value
Key Cookie fields
| Field | Purpose | Required |
|---|---|---|
wedoc_sid |
Session ID | ✅ |
wedoc_skey |
Session key | ✅ |
wedoc_ticket |
Authentication ticket | ✅ |
TOK |
XSRF token | ✅ |
tdoc_uid |
User ID | ✅ |
utype |
User type (ww = WeCom) | Recommended |
wedoc_sids |
Multi-session identifier | Recommended |
The simplest approach is to copy the complete document.cookie output; there is no need to manually select fields.
The Cookie validity period depends on the WeCom login state, usually from several hours to several days. Expiration manifests as the API returning a login page or 403.
Usage
# 读取表格(自动分页)
node scripts/fetch-smartsheet.mjs <smartsheet-url>
# 只读前 10 行
WECOM_ENDROW=10 node scripts/fetch-smartsheet.mjs <url>
# 调试模式(输出原始 JSON)
DEBUG=1 node scripts/fetch-smartsheet.mjs <url>
Environment variables
| Variable | Default value | Description |
|---|---|---|
WECOM_COOKIE |
- | Cookie string |
WECOM_STARTROW |
0 | Start row |
WECOM_ENDROW |
- | End row (when set, only a single page is requested) |
WECOM_PAGE_SIZE |
500 | Automatic pagination size |
API details
Core API:GET https://doc.weixin.qq.com/dop-api/opendoc
For data format details, see references/snapshot-format.md。