# @datocms/rest-api-reference 中文文档

规范地址：https://npmcn.com/package/%40datocms/rest-api-reference/

版本：6\.1\.0
npm 元数据更新时间：2026-08-31T08:06:33.009Z
中文译文更新时间：2026-11-11T15:34:08.876Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40datocms/rest-api-reference
原文对照：https://npmcn.com/package/%40datocms/rest-api-reference/?lang=original
项目主页：https://github.com/datocms/js-rest-api-clients/tree/main/packages/rest-api-reference#readme
源码仓库：https://github.com/datocms/js-rest-api-clients

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：146 kB，88 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- 运行依赖：1 个
- 首次发布：2026-04-09T13:05:16.698Z
- 最新版本发布：2026-08-31T08:06:32.763Z
- 近 30 天下载量：91489（2026-10-12 至 2026-11-10，npm 官方下载统计）
- 已发布版本数：8（近 12 个月 8 个）

## 中文简介

浏览 DatoCMS REST API 参考文件的公用事业

## 安装

```sh
npm install @datocms/rest-api-reference
```

也可以使用：`pnpm add @datocms/rest-api-reference`、`yarn add @datocms/rest-api-reference`、`bun add @datocms/rest-api-reference`

## README

[![Node.js CI](https://github.com/datocms/js-rest-api-clients/actions/workflows/node.js.yml/badge.svg)](https://github.com/datocms/js-rest-api-clients/actions/workflows/node.js.yml)

# DatoCMS REST API 参考文献

要浏览的公用事业 [达多CMS](https://www.datocms.com/) 方案参考文件。 获取并淡化官方的超文本描述, 解析资源方案, 并让 Markdown 描述资源及其行动 .

  
  
[![](https://www.datocms.com/images/full_logo.svg)](https://www.datocms.com/)  
  

## 安装

```bash
npm install @datocms/rest-api-reference
```

## 使用量

```typescript
import {
  fetchHyperschema,
  parseResourcesSchema,
  listResources,
  describeResource,
  describeResourceAction,
} from '@datocms/rest-api-reference';

// Fetch and dereference a hyperschema using a shorthand...
const hyperschema = await fetchHyperschema('cma');

// ...or the dashboard API
const dashboardSchema = await fetchHyperschema('dashboard');

// ...or a custom URL
const custom = await fetchHyperschema('https://example.com/schema.json');

// Parse a resources.json file (shipped with @datocms/cma-client)
const resourcesSchema = parseResourcesSchema(rawResourcesJson);

// List all available resources grouped by theme
const listing = listResources(hyperschema, resourcesSchema);

// Describe a specific resource and its available actions
const resource = describeResource(hyperschema, resourcesSchema, 'items');

// Describe a specific action with examples
const action = describeResourceAction(
  hyperschema,
  resourcesSchema,
  'items',
  'create',
);
```

### 扩展 `<details>` 块

`describeResource` 财务报告和审定财务报表 `describeResourceAction` 接受选项 `expandDetails` 参数 — 一组 `<summary>` 扩充文本。 提供时,仅匹配 `<details>` 块返回, 完全打开 :

```typescript
const expanded = describeResourceAction(
  hyperschema,
  resourcesSchema,
  'items',
  'create',
  ['Example: Basic creation'],
);
```

### 下级公用事业

软件包还导出 finder 函数和一个 Markdown 构建器 :

```typescript
import {
  findHyperschemaEntity,
  findHyperschemaLink,
  findResourcesEntityByJsonApiType,
  findResourcesEntityByNamespace,
  findResourcesEndpointByRel,
  render,
  h1,
  h2,
  p,
  ul,
  li,
  code,
} from '@datocms/rest-api-reference';
```

## 捐款

GitHub 上欢迎错误报告和拉取请求 [https://github.com/datocms/js-rest-api-客户端 互联网档案馆的存檔,存档日期2013-12-11](https://github.com/datocms/js-rest-api-clients)本项目旨在成为合作的安全和受欢迎的空间,预期捐助者将坚持 [《促进者公约》](http://contributor-covenant.org/) 行为守则.

## 许可证

该软件包可按以下规定作为开源: [MIT 许可证](http://opensource.org/licenses/MIT)。 。 。 .

## 常见问题

### @datocms/rest-api-reference 是什么？

浏览 DatoCMS REST API 参考文件的公用事业

### 如何安装 @datocms/rest-api-reference？

在项目目录运行 npm install @datocms/rest-api-reference，或使用 pnpm add / yarn add / bun add。

### @datocms/rest-api-reference 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @datocms/rest-api-reference 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### @datocms/rest-api-reference 可以商用吗？

@datocms/rest-api-reference 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @datocms/rest-api-reference 的下载量有多少？

根据 npm 官方下载统计，@datocms/rest-api-reference 在 2026/10/12 – 2026/11/10 这 30 天内被下载 91,489 次，日均约 3,050 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @datocms/rest-api-reference 还在维护吗？

最新版本 6\.1\.0 发布于 2026/08/31（2 个月前）；至今共发布 8 个版本，其中过去 12 个月发布了 8 个；首次发布于 2026/04/09。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

