feishu-cli api Directly calls any Feishu OpenAPI endpoint, covering endpoints not yet wrapped as dedicated commands. Under a single-tool stack, it is the fallback capability replacing lark-cli api .
feishu-cli: if not yet installed, go to riba2534/feishu-cli for installation instructions.
Usage
feishu-cli api <METHOD> <path> [flags]
METHOD:GET|POST|PUT|DELETE|PATCH(case-insensitive)path: full API path, e.g./open-apis/im/v1/messages(leading slash may be omitted; if a full URL is passed by mistake, the host is automatically stripped)
Flags
| Flag | Description |
|---|---|
--params '<json>' |
query parameters (JSON object), e.g. '{"page_size":10}' |
--data '<json>' / --data-file <file> |
Request body:--data pass a JSON string, or --data-file read from a file (- means stdin); the two are mutually exclusive |
--as auto|user|bot |
Identity: auto (User preferred with Tenant fallback, default) / user (force User Token, requires auth loginfirst) / bot (force Tenant/app Token) |
--user-access-token |
Explicitly pass a User Access Token (--as user/auto used when --as user/auto) |
--dry-run |
Only print the request that would be sent (method/path/query/body/identity), without actually calling |
-o <file> |
Write the raw response body to a file (binary-safe, suitable for download-type endpoints) |
--format json|pretty|table|ndjson|csv |
Response rendering format (once specified, uses built-in rendering, overriding the default pretty; only applies to JSON responses) |
--jq '<expr>' |
Filter the response with the built-in gojq (no external jq needed; only applies to JSON responses) |
-o-o binary download and--format/--jqare mutually exclusive: default /--raw/ pure-ouses the raw file-writing path (binary-safe); once--formator--jqis included, the response is first parsed as JSON and then rendered, and a binary response will fail to decode and report the error "Response is not valid JSON, cannot render with --format/--jq (remove these two flags to output raw with --raw)". When downloading media/files, use only-o, do not add--format/--jq。
Large integer precision: the response is parsed with
UseNumber, so Feishu 19-digitmessage_id/chat_idetc. will not be downgraded and lose precision.
Three-step investigation method (when the path is unknown)
feishu-cli schema <service> # 1. 列出该 service 的 resource.method
feishu-cli schema <service>.<resource>.<method> # 2. 查 path / 参数 / scope
feishu-cli api <METHOD> <path> ... # 3. 裸调
Examples
# GET + query + jq 过滤
feishu-cli api GET /open-apis/wiki/v2/spaces --params '{"page_size":10}' --jq '.data.items[].name'
# POST 发消息(先 dry-run 预览)
feishu-cli api POST /open-apis/im/v1/messages \
--params '{"receive_id_type":"chat_id"}' \
--data '{"receive_id":"oc_xxx","msg_type":"text","content":"{\"text\":\"hi\"}"}' --dry-run
# 请求体从文件读
feishu-cli api POST /open-apis/bitable/v1/apps/xxx/tables --data-file body.json
# 下载二进制到文件
feishu-cli api GET /open-apis/drive/v1/medias/<token>/download -o /tmp/file.bin
# 强制用户身份(访问用户私有资源)
feishu-cli api GET /open-apis/calendar/v4/calendars --as user
# 表格输出
feishu-cli api GET /open-apis/wiki/v2/spaces --jq '.data.items' --format table
When to use dedicated commands instead of api
api is the fallback. For high-frequency scenarios, prefer the wrapped dedicated commands (error handling/parameter validation/convenience flags are more complete): messages→msg, docs→doc, bitable→bitable, sheets→sheet, calendar→calendar , etc. Only when an endpoint has no corresponding dedicated command, use api raw call.