dingtalk-docs-reader
Installation
SKILL.md
IRON LAW: Every API call requires a valid browser Cookie with X-XSRF-TOKEN. Auth failures return 301/302 redirects, not 401 — always check for redirects before parsing response JSON.
DingTalk Document API Guide
Portal: https://alidocs.dingtalk.com
Programmatic read access to DingTalk native documents via cookie-based session auth and internal endpoints reverse-engineered from the web frontend. No stable public OpenAPI covers these paths.
Workflow
- ⛔ BLOCKING Authenticate → obtain cookie via manual extraction from browser → verify:
XSRF-TOKENpresent in cookie string - ⚠️ REQUIRED Create client →
async with DingTalkClient(cookie) as client→ verify: noDingTalkAuthErroron first call - ⚠️ REQUIRED Navigate → extract space/node ID from URL → list children or get node info → verify: API returns
isSuccess: true - ⚠️ REQUIRED Read/Download → branch by extension:
adoc→get_document_data()+extract_text_from_alidocs()for text; (conditional)export_to_pdf()if PDF output is needed- (conditional)
dlink/hlink→resolve_external_link()first, then treat target as regular node - other →
download_file()(validates extension againstDOWNLOADABLE_EXTENSIONS)
- (conditional) Cleanup → client auto-closes via
async with; manualaclose()if not using context manager