# 授权 & 接口规范

## 1. 对接专用auth

针对页面访问的接口，使用cookie校验用户态，您可以使用cookie中的数据进行对接测试，但不建议作为给用户的对接方案，一方面此数据有效期仅为30天。

开放API接口仅可使用个人详情页中提供的第三方对接专用auth，此auth有效期为180天。

目前针对页面访问的接口，cookie auth和第三方对接auth均可使用，未来有可能限制为仅可使用cookie auth访问。

## 2. 接口规范

本站目前提供了有限的开放API接口，如不满足需求，请向管理员提需求。不过您可以暂时使用本站页面所对应的接口。目前暂未总结不同接口的调用规范，但有一些明确的规范可以提供给到您，方便您进行问题排查。

### 2.1 请求方式

本站POST接口请求标头(Content-Type)有不同的设计。

添加种子的接口由于要上传文件，因此采用的是 `multipart/form-data` 。

大部分POST接口采用的都是  `application/json。`

也有部分POST接口由于入参较为简单拼在了URI后，或者没有入参，此时就不需要设置此标头。

> 如果请求失败，请优先检查您的请求标头是否与本站页面访问保持一致。

### 2.2 返回结果

除种子下载的链接外，其他URI返回的内容均为JSON格式。

```json
{
    "success": true,
    "showType": 0,
    "errorMessage": "访问异常时提示的信息",
    "data": [] // list为[] object为{}
}
```

当success为true时，则表明请求成功，如果为false，则errorMessage字段表明访问失败的原因。

### 2.3 开放API接口

开放API正在建设中，具体已开放接口可查看[开放API](/developer/open-api.md)。

## 3. 协助排查问题

相信您能够独立完成对接，但如果实在无法解决问题，请向 <develop@yemapt.org> 邮箱发送邮件，邮件内容须包含请求的接口、请求的参数、测试的时间、以及请求返回header中的traceid。

最好是打开浏览器开发者工具，打开网络，找到出错的请求，右键->复制-> 以 fetch 格式复制/以 cURL (bash) 格式复制。

<figure><img src="/files/M2nwsXi1EzBh7o3xK7s0" alt=""><figcaption><p>复制出错请求</p></figcaption></figure>

<figure><img src="/files/rRdoXu73JRMBIZCtNgAx" alt=""><figcaption><p>响应标头中的traceid</p></figcaption></figure>


---

# Agent Instructions: 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:

```
GET https://wiki1.yemapt.org/developer/auth.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
