---
id: "zh/api-get-nd-api-file-list-dir"
title: "获取文件列表"
language: "zh"
description: "GET /nd/api/file/list_dir：获取文件列表 接口说明，包含路径、方法、参数和返回信息。"
canonical_url: "https://www.babel.cc/public/babelwiki/zh/api-get-nd-api-file-list-dir.html"
markdown_url: "https://www.babel.cc/public/babelwiki/ai/zh/api-get-nd-api-file-list-dir.md"
alternates: {"en": "https://www.babel.cc/public/babelwiki/ai/en/api-get-nd-api-file-list-dir.md", "zh": "https://www.babel.cc/public/babelwiki/ai/zh/api-get-nd-api-file-list-dir.md"}
reading_note: "文档记录不等于当前部署能力；以实际版本、授权模块与配置为准。保留原文的可选、限制及待确认说明，勿补猜接口。 / Documentation is not a guarantee for every deployment. Preserve optional-module requirements, limitations and unresolved API contracts."
---

# 获取文件列表

| 属性 | 值 |
| --- | --- |
| HTTP 方法 | `GET` |
| 接口路径 | `/nd/api/file/list_dir` |
| 所属分类 | 文件 API |

## 接口说明




#### URL 参数

| 参数 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `parent_id` | `string` | 是 | 父文件夹 ID：1 企业文件夹，2 个人文件夹，3 我的项目，4 我加入的分享，其它 fileId 为对应文件夹。 |
| `page_size` | `number` | 未说明 | 每页数量 |
| `page` | `number` | 未说明 | 请求页号，从 `0` 开始：`0` 为第一页，`1` 为第二页。 |
| `type` | `string` | 未说明 | 1 - file，2 - folder，0 - all |

#### 返回字段说明

| 字段 | 类型 | 说明 |
| --- | --- | --- |
| `files` | array | 文件信息（原资料列出 `fileId`、`name`，其余字段未展开） |
| `total` | `int` | 总数量 |
| `pages` | `int` | 当前总页数；与请求参数 `page`（请求哪一页）不同。 |
| `success` | `boolean` | 获取成功标记 |
| `code` | `int` | 错误码，0 表示成功 |

请求页号 `page` 与返回总页数 `pages` 不同。例如返回 `pages: 3` 时，对应的请求页号依次为 `0`、`1`、`2`。这里说明页号基数，不推定省略 `page` 时的默认行为。

## 调用说明

- 调用前需完成 [获取 token](https://www.babel.cc/public/babelwiki/zh/api-post-api-token-do.html) 或相应免登录认证，并在请求 Header 中携带 `Authorization: Bearer <access_token>`。
- 参数和返回字段如因部署版本存在差异，应以实际私有云 API 文档和联调结果为准。
- 所属分类：文件 API。
