> ## Documentation Index
> Fetch the complete documentation index at: https://end-docs.shallow.ink/llms.txt
> Use this file to discover all available pages before exploring further.

# 抽卡数据分析

> 使用 Endfield API 获取和分析抽卡记录数据。

## 概述

Endfield API 提供完整的抽卡记录获取、全服统计和卡池分析功能。

## 公开数据（无需 Framework Token）

### 全服统计

```bash theme={"theme":{"light":"github-light","dark":"vitesse-dark"}}
curl https://api.end.shallow.ink/api/endfield/gacha/global-stats \
  -H "X-API-Key: sk_your_api_key"
```

返回全服用户的抽卡统计数据，包括各卡池的平均出货数、保底率等。

### 卡池角色分布

```bash theme={"theme":{"light":"github-light","dark":"vitesse-dark"}}
curl https://api.end.shallow.ink/api/endfield/gacha/pool-chars \
  -H "X-API-Key: sk_your_api_key"
```

返回各卡池中 6★/5★/4★ 角色的出现概率和 UP 信息。

## 个人数据（需要 Framework Token）

### 同步抽卡记录

```bash theme={"theme":{"light":"github-light","dark":"vitesse-dark"}}
# 1. 获取可用账号列表
curl https://api.end.shallow.ink/api/endfield/gacha/accounts \
  -H "X-API-Key: sk_your_api_key" \
  -H "X-Framework-Token: your_framework_token"

# 2. 同步抽卡记录（异步任务）
curl -X POST https://api.end.shallow.ink/api/endfield/gacha/fetch \
  -H "X-API-Key: sk_your_api_key" \
  -H "X-Framework-Token: your_framework_token" \
  -d '{"account_uid": "081587252"}'

# 3. 查询同步状态
curl https://api.end.shallow.ink/api/endfield/gacha/sync/status \
  -H "X-API-Key: sk_your_api_key" \
  -H "X-Framework-Token: your_framework_token"

# 4. 获取已保存的记录
curl https://api.end.shallow.ink/api/endfield/gacha/records \
  -H "X-API-Key: sk_your_api_key" \
  -H "X-Framework-Token: your_framework_token"
```

### 认证链流程

抽卡记录获取需要经过四层认证链：

```
HypergryphToken（登录时保存）
    ↓ Grant API
app_token
    ↓ Bindings API
绑定账号列表
    ↓ 选择账号
hgUid
    ↓ U8Token API
u8_token
    ↓ Records API
抽卡记录
```

<Note>
  整个认证链由后端自动处理，开发者只需提供 Framework Token 即可。
</Note>

### 多账号处理

用户可能绑定了多个游戏账号（官服 + B服），需要先获取账号列表再选择：

```javascript theme={"theme":{"light":"github-light","dark":"vitesse-dark"}}
const accounts = await fetchAPI('/api/endfield/gacha/accounts');
if (accounts.need_select) {
  // 让用户选择账号
  const selected = await showAccountSelector(accounts.accounts);
  await fetchAPI('/api/endfield/gacha/fetch', {
    method: 'POST',
    body: JSON.stringify({ account_uid: selected.uid })
  });
} else {
  // 只有一个账号，直接同步
  await fetchAPI('/api/endfield/gacha/fetch', { method: 'POST' });
}
```

## 模拟寻访

无需 Framework Token，所有用户均可使用。

### 获取可模拟卡池

```bash theme={"theme":{"light":"github-light","dark":"vitesse-dark"}}
curl https://api.end.shallow.ink/api/endfield/gacha/simulate/pools \
  -H "X-API-Key: sk_your_api_key"
```

### 模拟抽卡

```bash theme={"theme":{"light":"github-light","dark":"vitesse-dark"}}
# 单抽
curl -X POST https://api.end.shallow.ink/api/endfield/gacha/simulate/single \
  -H "X-API-Key: sk_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"pool_id": "pool_id_here"}'

# 十连
curl -X POST https://api.end.shallow.ink/api/endfield/gacha/simulate/ten \
  -H "X-API-Key: sk_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"pool_id": "pool_id_here"}'

# 免费十连
curl -X POST https://api.end.shallow.ink/api/endfield/gacha/simulate/free-ten \
  -H "X-API-Key: sk_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"pool_id": "pool_id_here"}'
```

### 批量模拟

```bash theme={"theme":{"light":"github-light","dark":"vitesse-dark"}}
curl -X POST https://api.end.shallow.ink/api/endfield/gacha/simulate/batch \
  -H "X-API-Key: sk_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"pool_id": "pool_id_here", "count": 100}'
```

## 卡池类型

| 类型  | 值                                   | 说明   |
| --- | ----------------------------------- | ---- |
| 限定池 | `E_CharacterGachaPoolType_Special`  | 特许寻访 |
| 常驻池 | `E_CharacterGachaPoolType_Standard` | 基础寻访 |
| 新手池 | `E_CharacterGachaPoolType_Beginner` | 启程寻访 |
| 武器池 | `weapon`                            | 武器寻访 |
