> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-framing-web-ui.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 通过 Postman 以编程方式访问 API

> 本指南将帮助您使用 Postman 测试 ClickHouse Cloud API

export const Image = ({img, alt, size = "lg"}) => {
  const normalizedSize = ["sm", "md", "lg"].includes(size) ? size : "lg";
  return <div className={`ch-image-${normalizedSize}`}>
      <Frame>
        <img src={img} alt={alt} />
      </Frame>
    </div>;
};

本指南将帮助你使用 [Postman](https://www.postman.com/product/what-is-postman/) 测试 ClickHouse Cloud API。
你可以直接在 Web 浏览器中使用 Postman 应用程序，也可以将其下载到桌面端。

<div id="create-an-account">
  ### 创建账户
</div>

* 可在 [https://www.postman.com](https://www.postman.com) 注册免费账户。

<Image img="https://mintcdn.com/private-7c7dfe99-framing-web-ui/U0HPKhAsvpqpReQJ/images/cloud/manage/postman/postman1.webp?fit=max&auto=format&n=U0HPKhAsvpqpReQJ&q=85&s=d1c55981999d9c3404b11577142858f0" size="md" alt="Postman 网站" border width="1621" height="1011" data-path="images/cloud/manage/postman/postman1.webp" />

<div id="create-a-workspace">
  ### 创建工作区
</div>

* 给工作区命名并设置可见性级别。

<Image img="https://mintcdn.com/private-7c7dfe99-framing-web-ui/U0HPKhAsvpqpReQJ/images/cloud/manage/postman/postman2.webp?fit=max&auto=format&n=U0HPKhAsvpqpReQJ&q=85&s=a4a9e16a29fbaa0b486216594856fd6c" size="md" alt="创建工作区" border width="784" height="760" data-path="images/cloud/manage/postman/postman2.webp" />

<div id="create-a-collection">
  ### 创建集合
</div>

* 在左上角菜单中，点击 "Explore" 下方的 "Import"：

<Image img="https://mintcdn.com/private-7c7dfe99-framing-web-ui/U0HPKhAsvpqpReQJ/images/cloud/manage/postman/postman3.webp?fit=max&auto=format&n=U0HPKhAsvpqpReQJ&q=85&s=5f16b2a2eceec65d4633f0d6aeeeb02f" size="md" alt="Explore > 导入" border data-og-width="1317" width="1317" data-og-height="647" height="647" data-path="images/cloud/manage/postman/postman3.webp" data-optimize="true" data-opv="3" srcset="https://mintcdn.com/private-7c7dfe99-framing-web-ui/U0HPKhAsvpqpReQJ/images/cloud/manage/postman/postman3.webp?w=280&fit=max&auto=format&n=U0HPKhAsvpqpReQJ&q=85&s=d0f5de63384d47d4b38907c6831c1dc2 280w, https://mintcdn.com/private-7c7dfe99-framing-web-ui/U0HPKhAsvpqpReQJ/images/cloud/manage/postman/postman3.webp?w=560&fit=max&auto=format&n=U0HPKhAsvpqpReQJ&q=85&s=ed88341a270de9cf29874d017d04af18 560w, https://mintcdn.com/private-7c7dfe99-framing-web-ui/U0HPKhAsvpqpReQJ/images/cloud/manage/postman/postman3.webp?w=840&fit=max&auto=format&n=U0HPKhAsvpqpReQJ&q=85&s=8e72ab345cd6c381315088d4f570001f 840w, https://mintcdn.com/private-7c7dfe99-framing-web-ui/U0HPKhAsvpqpReQJ/images/cloud/manage/postman/postman3.webp?w=1100&fit=max&auto=format&n=U0HPKhAsvpqpReQJ&q=85&s=5beb256832a89edd0478c829e0bd8ce6 1100w, https://mintcdn.com/private-7c7dfe99-framing-web-ui/U0HPKhAsvpqpReQJ/images/cloud/manage/postman/postman3.webp?w=1650&fit=max&auto=format&n=U0HPKhAsvpqpReQJ&q=85&s=a3aca081c3f00095282abda7b54f07d3 1650w, https://mintcdn.com/private-7c7dfe99-framing-web-ui/U0HPKhAsvpqpReQJ/images/cloud/manage/postman/postman3.webp?w=2500&fit=max&auto=format&n=U0HPKhAsvpqpReQJ&q=85&s=db317aec0ffd0792a2876406ae1d7199 2500w" />

* 此时会弹出一个模态窗口：

<Image img="https://mintcdn.com/private-7c7dfe99-framing-web-ui/U0HPKhAsvpqpReQJ/images/cloud/manage/postman/postman4.webp?fit=max&auto=format&n=U0HPKhAsvpqpReQJ&q=85&s=376da7939fbacdc2b331cb179e034700" size="md" alt="API URL 输入项" border width="659" height="471" data-path="images/cloud/manage/postman/postman4.webp" />

* 输入 API 地址："[https://api.clickhouse.cloud/v1\&quot;，然后按下](https://api.clickhouse.cloud/v1\&quot;，然后按下) 'Enter'：

* 点击 "Import" 按钮，选择 "Postman Collection"：

<Image img="https://mintcdn.com/private-7c7dfe99-framing-web-ui/U0HPKhAsvpqpReQJ/images/cloud/manage/postman/postman6.webp?fit=max&auto=format&n=U0HPKhAsvpqpReQJ&q=85&s=9c646be6cf698a06863aa7aecf684f90" size="md" alt="集合 > 导入" border data-og-width="666" width="666" data-og-height="253" height="253" data-path="images/cloud/manage/postman/postman6.webp" data-optimize="true" data-opv="3" srcset="https://mintcdn.com/private-7c7dfe99-framing-web-ui/U0HPKhAsvpqpReQJ/images/cloud/manage/postman/postman6.webp?w=280&fit=max&auto=format&n=U0HPKhAsvpqpReQJ&q=85&s=b83d46402802d4b234a23fe37b7672b4 280w, https://mintcdn.com/private-7c7dfe99-framing-web-ui/U0HPKhAsvpqpReQJ/images/cloud/manage/postman/postman6.webp?w=560&fit=max&auto=format&n=U0HPKhAsvpqpReQJ&q=85&s=3381c23400820cb2ffd8e3dc14c36a61 560w, https://mintcdn.com/private-7c7dfe99-framing-web-ui/U0HPKhAsvpqpReQJ/images/cloud/manage/postman/postman6.webp?w=840&fit=max&auto=format&n=U0HPKhAsvpqpReQJ&q=85&s=acef379a5a887ba208565688c603e8eb 840w, https://mintcdn.com/private-7c7dfe99-framing-web-ui/U0HPKhAsvpqpReQJ/images/cloud/manage/postman/postman6.webp?w=1100&fit=max&auto=format&n=U0HPKhAsvpqpReQJ&q=85&s=47f053e97c8a883716612dffe0524597 1100w, https://mintcdn.com/private-7c7dfe99-framing-web-ui/U0HPKhAsvpqpReQJ/images/cloud/manage/postman/postman6.webp?w=1650&fit=max&auto=format&n=U0HPKhAsvpqpReQJ&q=85&s=4771d9bd783f89a441952adbecdde358 1650w, https://mintcdn.com/private-7c7dfe99-framing-web-ui/U0HPKhAsvpqpReQJ/images/cloud/manage/postman/postman6.webp?w=2500&fit=max&auto=format&n=U0HPKhAsvpqpReQJ&q=85&s=87d7a6ca82ed581838c78b3f1307fcbc 2500w" />

<div id="interface-with-the-clickhouse-cloud-api-spec">
  ### 使用 ClickHouse Cloud API 规范
</div>

* “ClickHouse Cloud 的 API 规范”现在会显示在“集合” (左侧导航) 中。

<Image img="https://mintcdn.com/private-7c7dfe99-framing-web-ui/U0HPKhAsvpqpReQJ/images/cloud/manage/postman/postman7.webp?fit=max&auto=format&n=U0HPKhAsvpqpReQJ&q=85&s=69769789a50dbeefab342e36c16df21e" size="md" alt="导入 API" border width="949" height="446" data-path="images/cloud/manage/postman/postman7.webp" />

* 点击“ClickHouse Cloud 的 API 规范”。然后在中间面板中选择“Authorization”选项卡：

<Image img="https://mintcdn.com/private-7c7dfe99-framing-web-ui/U0HPKhAsvpqpReQJ/images/cloud/manage/postman/postman8.webp?fit=max&auto=format&n=U0HPKhAsvpqpReQJ&q=85&s=66a2465ff4a8d431d1dea01e45b0caa3" size="md" alt="导入完成" border width="872" height="420" data-path="images/cloud/manage/postman/postman8.webp" />

<div id="set-authorization">
  ### 设置授权
</div>

* 在下拉菜单中选择“Basic Auth”：

<Image img="https://mintcdn.com/private-7c7dfe99-framing-web-ui/U0HPKhAsvpqpReQJ/images/cloud/manage/postman/postman9.webp?fit=max&auto=format&n=U0HPKhAsvpqpReQJ&q=85&s=fa33b09fc05033202cea0a2832622e6e" size="md" alt="Basic Auth" border width="789" height="620" data-path="images/cloud/manage/postman/postman9.webp" />

* 输入您在设置 ClickHouse Cloud API keys 时收到的用户名和密码：

<Image img="https://mintcdn.com/private-7c7dfe99-framing-web-ui/U0HPKhAsvpqpReQJ/images/cloud/manage/postman/postman10.webp?fit=max&auto=format&n=U0HPKhAsvpqpReQJ&q=85&s=c0659a2675ca38729df167c7bc0f9307" size="md" alt="凭据" border width="951" height="700" data-path="images/cloud/manage/postman/postman10.webp" />

<div id="enable-variables">
  ### 启用变量
</div>

* [变量](https://learning.postman.com/docs/sending-requests/variables/)可用于在 Postman 中存储和重复使用值，从而简化 API 测试。

<div id="set-the-organization-id-and-service-id">
  #### 设置 Organization ID 和 Service ID
</div>

* 在“集合”中，点击中间窗格里的“变量”选项卡 (Base URL 已在之前导入 API 时设置) ：
* 在 `baseURL` 下方，点击空白字段“Add new value”，然后填入你的 Organization ID 和 Service ID：

<Image img="https://mintcdn.com/private-7c7dfe99-framing-web-ui/U0HPKhAsvpqpReQJ/images/cloud/manage/postman/postman11.webp?fit=max&auto=format&n=U0HPKhAsvpqpReQJ&q=85&s=2075b97a4d8a04bf2efd6f0815fb20b1" size="md" alt="Organization ID 和 Service ID" border width="1057" height="558" data-path="images/cloud/manage/postman/postman11.webp" />

<div id="test-the-clickhouse-cloud-api-functionalities">
  ## 测试 ClickHouse Cloud API 的各项功能
</div>

<div id="test-get-list-of-available-organizations">
  ### 测试“GET 可用组织列表”
</div>

* 在“ClickHouse Cloud 的 OpenAPI 规范”下，展开 > V1 > organizations 文件夹
* 点击“GET 可用组织列表”，然后点击右侧蓝色的“Send”按钮：

<Image img="https://mintcdn.com/private-7c7dfe99-framing-web-ui/U0HPKhAsvpqpReQJ/images/cloud/manage/postman/postman12.webp?fit=max&auto=format&n=U0HPKhAsvpqpReQJ&q=85&s=ccc27a3df5a214bf301b62e136042038" size="md" alt="测试获取组织信息" border width="1797" height="972" data-path="images/cloud/manage/postman/postman12.webp" />

* 返回结果应显示你的组织详细信息，且 `"status": 200`。 (如果你收到 `"status": 400`，但没有任何组织信息，则说明配置不正确。)

<Image img="https://mintcdn.com/private-7c7dfe99-framing-web-ui/U0HPKhAsvpqpReQJ/images/cloud/manage/postman/postman13.webp?fit=max&auto=format&n=U0HPKhAsvpqpReQJ&q=85&s=38efcf4ba7e0e9a1765468ff49e6c4a9" size="md" alt="状态" border width="1797" height="972" data-path="images/cloud/manage/postman/postman13.webp" />

<div id="test-get-organizational-details">
  ### 测试“GET organizational details”
</div>

* 在 `organizationid` 文件夹下，找到“GET organizational details”：
* 在中间窗格菜单的 Params 下，需要填写 `organizationid`。

<Image img="https://mintcdn.com/private-7c7dfe99-framing-web-ui/U0HPKhAsvpqpReQJ/images/cloud/manage/postman/postman14.webp?fit=max&auto=format&n=U0HPKhAsvpqpReQJ&q=85&s=318d252aca144bbfbec1efaa022a886c" size="md" alt="测试获取组织详细信息" border width="1797" height="972" data-path="images/cloud/manage/postman/postman14.webp" />

* 将此值改为花括号中的 `orgid`：`{{orgid}}` (如果你之前已设置过该值，会出现一个包含该值的菜单) ：

<Image img="https://mintcdn.com/private-7c7dfe99-framing-web-ui/U0HPKhAsvpqpReQJ/images/cloud/manage/postman/postman15.webp?fit=max&auto=format&n=U0HPKhAsvpqpReQJ&q=85&s=af80debdaa5202730e4478042562c495" size="md" alt="提交测试" border width="1797" height="972" data-path="images/cloud/manage/postman/postman15.webp" />

* 点击“Save”按钮后，再点击屏幕右上角蓝色的“Send”按钮。

<Image img="https://mintcdn.com/private-7c7dfe99-framing-web-ui/U0HPKhAsvpqpReQJ/images/cloud/manage/postman/postman16.webp?fit=max&auto=format&n=U0HPKhAsvpqpReQJ&q=85&s=db3a599110c2c8b87ba9444a0a510f10" size="md" alt="返回值" border width="1797" height="972" data-path="images/cloud/manage/postman/postman16.webp" />

* 返回结果应包含你的组织详细信息，且 "status": 200。 (如果返回的是 "status" 400，且没有组织信息，则说明你的配置不正确。)

<div id="test-get-service-details">
  ### 测试“GET service details”
</div>

* 点击“GET service details”
* 分别将 `organizationid` 和 `serviceid` 的值编辑为 `{{orgid}}` 和 `{{serviceid}}`。
* 点击“Save”，然后点击右侧蓝色的“Send”按钮。

<Image img="https://mintcdn.com/private-7c7dfe99-framing-web-ui/U0HPKhAsvpqpReQJ/images/cloud/manage/postman/postman17.webp?fit=max&auto=format&n=U0HPKhAsvpqpReQJ&q=85&s=2a41e050f34f0c88bebd1211feca0f2b" size="md" alt="服务列表" border width="1537" height="867" data-path="images/cloud/manage/postman/postman17.webp" />

* 返回结果应显示你的服务列表及其详细信息，且 `"status": 200`。 (如果你收到 `"status"` 400，且没有任何服务信息，则说明你的配置不正确) 。
