添加错误码分类

修改API的请求头和Cookie标识
This commit is contained in:
Kamisato-Ayaka-233
2023-06-03 14:49:06 +08:00
parent 7816443129
commit 94d9ad14f1
6 changed files with 130 additions and 30 deletions

View File

@@ -10,12 +10,6 @@ _请求方式GET_
`https://api.21cnt.cn/genshin/banner`
<!-- **参数:**
| 字段 | 内容 | 备注 |
| ---- | ---- | --- |
-->
**JSON返回**
根对象:

View File

@@ -18,7 +18,7 @@ _请求方式GET_
| --- | ---- | ---- | ---- |
| gids | num | 游戏ID | |
| page | num | 页数 | 若未指定则为第1页 |
| page_size | num | 每页文章数量<br/>1~50 | 若未指定或超出范围则为每页20篇 |
| page_size | num | 每页文章数量范围为1-50 | 若未指定或超出范围则为每页20篇 |
**JSON返回**
@@ -656,13 +656,16 @@ _请求方式GET_
_请求方式GET_
`https://bbs-api.miyoushe.com/post/wapi/getPostFull`
> _需要验证请求头_
网页:`https://bbs-api.miyoushe.com/post/wapi/getPostFull`
应用:`https://bbs-api.miyoushe.com/post/api/getPostFull`
**参数:**
| 字段 | 类型 | 内容 | 备注 |
| --- | ---- | ---- | ---- |
<!-- | gids | num | 游戏ID | | -->
| post_id | num | 文章ID | |
**JSON返回**
@@ -670,7 +673,7 @@ _请求方式GET_
| 字段 | 类型 | 内容 | 备注 |
| --- | ---- | ---- | ---- |
| retcode | num | 返回码<br/>1 未选择游戏 | |
| retcode | num | 返回码<br>1101 参数`post_id`对应的文章不存在 | |
| message | str | 返回消息 | |
| data | obj | 首页信息 | |

View File

@@ -4,6 +4,7 @@
- [获取首页信息](#genshin-home)
- [获取角色信息](#genshin-characters)
- [获取深境螺旋信息](#genshin-spiral-abyss)
- [每日便签](#genshin-daily-note)
- [获取祈愿记录](#genshin-wish)
- [崩坏:星穹铁道](#崩坏星穹铁道)
- [获取首页信息](#star-rail-home)
@@ -24,8 +25,12 @@ _请求方式GET_
> _需要验证请求头_
>
> `x-rpc-client_type``5`
> 4X`salt`
> `DS2`
>
> _需要验证网页Cookie_
> _需要验证Cookie_
>
> LToken
`https://api-takumi-record.mihoyo.com/game_record/app/genshin/api/index`
@@ -236,8 +241,12 @@ _请求方式GET_
> _需要验证请求头_
>
> `x-rpc-client_type``5`
> 4X`salt`
> `DS2`
>
> _需要验证网页Cookie_
> _需要验证Cookie_
>
> LToken
`https://bbs-api-os.hoyolab.com/game_record/genshin/api/index`
@@ -465,8 +474,12 @@ _请求方式POST_
> _需要验证请求头_
>
> `x-rpc-client_type``5`
> 4X`salt`
> `DS2`
>
> _需要验证网页Cookie_
> _需要验证Cookie_
>
> LToken
`未知`
@@ -483,8 +496,12 @@ _请求方式GET_
> _需要验证请求头_
>
> `x-rpc-client_type``5`
> 4X`salt`
> `DS2`
>
> _需要验证网页Cookie_
> _需要验证Cookie_
>
> LToken
`https://api-takumi-record.mihoyo.com/game_record/app/genshin/api/spiralAbyss`
@@ -1779,8 +1796,12 @@ _请求方式GET_
> _需要验证请求头_
>
> `x-rpc-client_type``5`
> 4X`salt`
> `DS2`
>
> _需要验证网页Cookie_
> _需要验证Cookie_
>
> LToken
`未知`
@@ -1901,8 +1922,12 @@ _请求方式GET_
> _需要验证请求头_
>
> `x-rpc-client_type``5`
> 4X`salt`
> `DS2`
>
> _需要验证网页Cookie_
> _需要验证Cookie_
>
> LToken
`https://api-takumi-record.mihoyo.com/game_record/app/hkrpg/api/index`

View File

@@ -3,7 +3,8 @@
- [用户信息](#用户信息)
- [获取用户完整信息](#获取用户完整信息)
- [获取用户发布的文章](#获取用户发布的文章)
- [通过Cookie获取用户`authkey`](#通过cookie获取用户authkey)
- [通过Cookie获取用户`authkey`A](#通过cookie获取账号authkeya)
- [通过Cookie获取用户`authkey`B](#通过cookie获取账号authkeyb)
---
@@ -339,20 +340,19 @@ _请求方式GET_
| 字段 | 类型 | 内容 | 备注 |
| ---- | ---- | ---- | ---- |
## 通过Cookie获取账号`authkey`A
## 通过Cookie获取用户`authkey`
在请求例如获取用户的游戏抽卡记录等API时需要使用到`authkey`
<!-- `authkey`A。 -->
**国服:**
_请求方式POST_
> _需要验证SToken_
> _需要验证Cookie_
>
> SToken
`https://api-takumi.miyoushe.com/binding/api/genAuthKey`
`https://api-takumi.miyoushe.com/account/auth/api/genAuthKey`
`https://hk4e-sdk.mihoyo.com/hk4e_cn/combo/granter/login/genAuthKey`
**JSON请求**
@@ -366,7 +366,7 @@ _请求方式POST_
| 字段 | 类型 | 内容 | 备注 |
| ---- | ---- | ---- | ---- |
| retcode | num | 返回码<br>1002 请求体的`game_biz`字段不正确<br>-100 Cookie不正确 | |
| retcode | num | 返回码<br>1002 请求体的`game_biz`字段不正确 | |
| message | str | 返回消息 | |
| data | obj | `authkey`信息 | |
@@ -376,7 +376,74 @@ _请求方式POST_
| ---- | ---- | ---- | ---- |
| sign_type | num | 2 | |
| authkey_ver | num | 1 | |
| authkey | str | `authkey` | |
| authkey | str | `authkey`A | |
<details>
<summary>查看示例</summary>
```json
{
"retcode": 0,
"message": "OK",
"data": {
"sign_type": 2,
"authkey_ver": 1,
"authkey": "..."
}
}
```
</details>
**国际服:**
`未知`
## 通过Cookie获取账号`authkey`B
在请求例如获取用户的游戏抽卡记录等API时需要使用到`authkey`B。
**国服:**
_请求方式POST_
> _需要验证请求头_
>
> `x-rpc-client_type``2`
> LK`salt`
> `DS1`
>
> _需要验证Cookie_
>
> SToken
`https://api-takumi.miyoushe.com/binding/api/genAuthKey`
<!--`https://hk4e-sdk.mihoyo.com/hk4e_cn/combo/granter/login/genAuthKey`-->
**JSON请求**
| 字段 | 类型 | 内容 | 备注 |
| ---- | ---- | ---- | ---- |
| game_biz | str | 获取的`authkey`B的游戏<br>hk4e_cn 《原神》<br>hkrpg_cn 《崩坏:星穹铁道》<br> | |
| game_uid | num | 游戏
**JSON返回**
根对象:
| 字段 | 类型 | 内容 | 备注 |
| ---- | ---- | ---- | ---- |
| retcode | num | 返回码<br>1002 请求体的`game_biz`字段不正确 | |
| message | str | 返回消息 | |
| data | obj | `authkey`信息 | |
`data`对象:
| 字段 | 类型 | 内容 | 备注 |
| ---- | ---- | ---- | ---- |
| sign_type | num | 2 | |
| authkey_ver | num | 1 | |
| authkey | str | `authkey`B | |
<details>
<summary>查看示例</summary>

View File

@@ -226,7 +226,7 @@ lettersAndNumbers = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456
salt = "ZSHlXeQUBis52qD1kEgKt5lUYed4b7Bb"
t = int(time.time())
r = random.choices(lettersAndNumbers, k=6)
r = "".join(random.choices(lettersAndNumbers, k=6))
main = f"salt={salt}&t={t}&r={r}"
ds = md5(main.encode(encoding='UTF-8')).hexdigest()

View File

@@ -6,9 +6,20 @@
错误码为API返回JSON中的`retcode`字段。
### `api-takumi-record.mihoyo.com`
| 错误码 | 消息 | 原因 |
| ------------------------------ | ---- | --- |
| -10001 | invalid request | 该API需要验证请求头请求头的`DS`字段缺失<br/>请查看[绕过检测与鉴权](other/authentication.md) |
| -1 | param XXX error: value must be greater than X<br/>param XXX error: value must be in list [X ...] | 传递的参数XXX缺失<br/>传递的参数XXX的值只能是X、...中 |
| ----- | ---- | ---- |
| -10001 | invalid request | 该API需要验证请求头请求头的一些字段缺失或错误<br/>请查看[绕过检测与鉴权](other/authentication.md) |
| -1 | param error<br>param XXX error: value must be greater than X<br>param XXX error: value must be in list [X ...] | 传递的参数值错误<br>传递的参数XXX缺失<br>传递的参数XXX的值只能是X、...中 |
| 1008 | 用户信息不匹配 | 传递的参数不正确<br/>(例如获取用户游戏账号信息的`role_id`为无效UID |
| 10001 | Please login | 该API需要验证Cookie<br/>请查看[绕过检测与鉴权](other/authentication.md#cookie) |
| 1034 | | 请求遇到验证码 |
### `api-takumi.miyoushe.com`
| 错误码 | 消息 | 原因 |
| ----- | ---- | ---- |
| -10001 | invalid request | 该API需要验证请求头请求头的一些字段缺失或错误<br/>请查看[绕过检测与鉴权](other/authentication.md) |
| -502 | Something went wrong...please retry later | 传递的参数错误 |
| -100 | 登录失效,请重新登录 |