> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/zh/web/api-testing/operating-an-endpoint-using-documentation.md).

# 使用文档操作端点

### 利用文档中的 API 端点

**实验目标**

本实验的目标是找到暴露的 API 文档，然后使用一个端点删除该用户 **carlos**. / 提供了一个有效账户用于测试：

* **凭据**: `wiener:peter`

**发现 API 文档**

浏览应用程序后发现有一条路由指向一个 **REST API** 其中包含其文档。/ 该文档清楚地描述了可用端点，甚至还提供了可直接使用的请求示例，包括以 **curl** 命令。

<figure><img src="/files/de2da52e080f7b5ac2120f905137ef257376a366" alt=""><figcaption></figcaption></figure>

**用户信息的获取**

从文档中可以看出，有一个端点允许用户通过指定用户名来检索信息。/ 所提供的请求返回用户数据 **carlos**:

* 请求：
* 方法： `GET`
* 端点： `/api/user/carlos`

{% code overflow="wrap" %}

```bash
curl -vgw "/n" -X GET 'https://0a73004e0348a82c81d3ca78004c00f7.web-security-academy.net/api/user/carlos'
```

{% endcode %}

* 答案：
* 服务器返回一个包含用户名和电子邮件地址的 JSON 对象。

```json
{
  "username": "carlos",
  "email": "carlos@carlos-montoya.net"
}
```

<figure><img src="/files/6a1ab047c4d7195aa7292331865145bf7c1ae5a2" alt=""><figcaption></figcaption></figure>

**删除 carlos 用户**

文档还表明，可以通过专门的请求删除用户。/ 使用相应端点并采用适当的方法：

* 请求：
* 方法： `DELETE`
* 端点： `/api/user/carlos`

{% code overflow="wrap" %}

```bash
curl -vgw "/n" -X DELETE 'https://0a73004e0348a82c81d3ca78004c00f7.web-security-academy.net/api/user/carlos' -d '{}'

```

{% endcode %}

* 结果：
* 服务器接受了该请求，并返回一条确认用户已被删除的消息。

```json
{
  "status": "用户已删除"
}
```

<figure><img src="/files/1b72db5eccc51369722818e86be18cd3931053ac" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://hacking-notes.jord4n.pro/zh/web/api-testing/operating-an-endpoint-using-documentation.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
