auth-helper

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Authentication Helper

身份验证助手

Help users configure
dex_cookie
authentication for the Alph.ai trading platform.
帮助用户为Alph.ai交易平台配置
dex_cookie
身份验证。

Overview

概述

Alph.ai uses browser cookie authentication. The key cookie is
dex_cookie
, which users obtain from the website after logging in.
What this skill does:
  • Guide users to get their
    dex_cookie
  • Help store and manage the cookie securely
  • Verify the cookie works
  • Troubleshoot authentication issues
Alph.ai采用浏览器Cookie身份验证方式。核心Cookie为
dex_cookie
,用户登录网站后即可获取。
本技能可实现:
  • 引导用户获取
    dex_cookie
  • 帮助安全存储和管理该Cookie
  • 验证Cookie是否可用
  • 排查身份验证相关问题

How Authentication Works

身份验证流程

text
1. User logs in at https://www.alph.ai
2. Browser receives dex_cookie from server
3. User copies dex_cookie value
4. Agent uses it in API calls as: Cookie: dex_cookie=<value>
Each user has their own unique
dex_cookie
. It is tied to their account session.
text
1. 用户在https://www.alph.ai登录
2. 浏览器从服务器接收dex_cookie
3. 用户复制dex_cookie的值
4. Agent在API调用中使用该Cookie,格式为:Cookie: dex_cookie=<值>
每个用户都有唯一的
dex_cookie
,该Cookie与用户的账户会话绑定。

Setup Workflow

设置流程

Step 1: Get Your dex_cookie

步骤1:获取你的dex_cookie

Guide the user through these steps:
text
1. Open https://www.alph.ai in your browser
2. Log in to your account
3. Press F12 to open Developer Tools
4. Go to Application tab → Cookies → www.alph.ai
5. Find "dex_cookie" in the list
6. Copy the Value (it looks like: NWMx...NA==)
Alternative method (Network tab):
text
1. After login, press F12 → Network tab
2. Click any page that loads data
3. Click any API request (to b.alph.ai)
4. In Request Headers, find "Cookie:"
5. Copy the dex_cookie=... value
引导用户完成以下步骤:
text
1. 在浏览器中打开https://www.alph.ai
2. 登录你的账户
3. 按下F12打开开发者工具
4. 进入「Application」标签页 → 「Cookies」 → www.alph.ai
5. 在列表中找到"dex_cookie"
6. 复制其「Value」值(格式类似:NWMx...NA==)
替代方法(网络标签页):
text
1. 登录后,按下F12 → 「Network」标签页
2. 点击任意加载数据的页面
3. 点击任意API请求(目标为b.alph.ai)
4. 在「Request Headers」中找到"Cookie:"
5. 复制dex_cookie=...部分的值

Step 2: Store the Cookie

步骤2:存储Cookie

Option A: Environment Variable (Recommended)
bash
undefined
选项A:环境变量(推荐)
bash
undefined

Add to your shell profile (~/.zshrc or ~/.bashrc)

添加到你的shell配置文件(/.zshrc或/.bashrc)

export ALPH_DEX_COOKIE="NWMxMmEwN2Qt...NA=="
export ALPH_DEX_COOKIE="NWMxMmEwN2Qt...NA=="

Reload

重新加载配置

source ~/.zshrc

**Option B: Secure File**

```bash
source ~/.zshrc

**选项B:安全文件**

```bash

Store in a file with restricted permissions

将Cookie存储到权限受限的文件中

echo "NWMxMmEwN2Qt...NA==" > ~/.alph_cookie chmod 600 ~/.alph_cookie
echo "NWMxMmEwN2Qt...NA==" > ~/.alph_cookie chmod 600 ~/.alph_cookie

Read when needed

需要时读取该值

export ALPH_DEX_COOKIE=$(cat ~/.alph_cookie)

**Option C: macOS Keychain**

```bash
export ALPH_DEX_COOKIE=$(cat ~/.alph_cookie)

**选项C:macOS钥匙串**

```bash

Store

存储Cookie

security add-generic-password -a "alph-ai" -s "dex-cookie" -w "NWMxMmEwN2Qt...NA=="
security add-generic-password -a "alph-ai" -s "dex-cookie" -w "NWMxMmEwN2Qt...NA=="

Retrieve

检索Cookie

export ALPH_DEX_COOKIE=$(security find-generic-password -a "alph-ai" -s "dex-cookie" -w)
undefined
export ALPH_DEX_COOKIE=$(security find-generic-password -a "alph-ai" -s "dex-cookie" -w)
undefined

Step 3: Verify Authentication

步骤3:验证身份验证

bash
undefined
bash
undefined

Test with a simple authenticated endpoint

通过简单的需身份验证端点测试

curl -s -X POST "https://b.alph.ai/smart-web-gateway/order/statistic"
-H "Content-Type: application/json"
-H "Cookie: dex_cookie=${ALPH_DEX_COOKIE}"
-d '{"chain":"sol"}'

**Success response:**
```json
{
  "code": "200",
  "data": {
    "code": 200,
    "orderCount": 638,
    "success": true
  }
}
Failed response (expired or invalid cookie):
json
{
  "code": "403",
  "msg": "token error"
}
curl -s -X POST "https://b.alph.ai/smart-web-gateway/order/statistic"
-H "Content-Type: application/json"
-H "Cookie: dex_cookie=${ALPH_DEX_COOKIE}"
-d '{"chain":"sol"}'

**成功响应:**
```json
{
  "code": "200",
  "data": {
    "code": 200,
    "orderCount": 638,
    "success": true
  }
}
失败响应(Cookie过期或无效):
json
{
  "code": "403",
  "msg": "token error"
}

Step 4: Use in API Calls

步骤4:在API调用中使用

All authenticated requests use the same pattern:
bash
curl -s "https://b.alph.ai/smart-web-gateway/..." \
  -H "Cookie: dex_cookie=${ALPH_DEX_COOKIE}"
For POST requests, also add:
bash
  -H "Content-Type: application/json" \
  -d '{"chain":"sol", ...}'
所有需身份验证的请求均采用以下格式:
bash
curl -s "https://b.alph.ai/smart-web-gateway/..." \
  -H "Cookie: dex_cookie=${ALPH_DEX_COOKIE}"
对于POST请求,还需添加:
bash
  -H "Content-Type: application/json" \
  -d '{"chain":"sol", ...}'

Cookie Details

Cookie详情

Format

格式

  • Encoding: Base64
  • Decoded content:
    UUID + timestamp
    (e.g.,
    5c12a07d-6db2-404d-88e3-2832a084d381
    +
    1771918855874
    )
  • Always ends with
    ==
    (base64 padding)
  • 编码方式:Base64
  • 解码后内容
    UUID + 时间戳
    (示例:
    5c12a07d-6db2-404d-88e3-2832a084d381
    +
    1771918855874
  • 始终以
    ==
    结尾(Base64填充字符)

Expiry

有效期

The
dex_cookie
expires after a period of inactivity. When expired:
  1. API returns
    {"code":"403","msg":"token error"}
  2. User needs to re-login at https://www.alph.ai
  3. Copy the new
    dex_cookie
    value
  4. Update the stored value
dex_cookie
会在一段时间无操作后过期。过期后:
  1. API会返回
    {"code":"403","msg":"token error"}
  2. 用户需重新登录https://www.alph.ai
  3. 复制新的
    dex_cookie
  4. 更新已存储的Cookie值

Security

安全注意事项

  • Never commit your
    dex_cookie
    to git or share publicly
  • Never log the cookie value in terminal output
  • Use
    chmod 600
    for cookie files
  • Each cookie is personal - never share between users
  • Add
    .alph_cookie
    to
    .gitignore
  • 绝对不要
    dex_cookie
    提交到git仓库或公开分享
  • 绝对不要在终端输出中记录Cookie值
  • 对存储Cookie的文件使用
    chmod 600
    权限
  • 每个Cookie均为个人专属,不要在用户间共享
  • .alph_cookie
    添加到
    .gitignore

What Needs Authentication

需要身份验证的功能

FeatureAuth Required?
Token prices, ticker dataNo
Holder stats, whale trackingNo
Smart wallet list & analyticsNo
Hot token discoveryNo
Place orders (buy/sell)Yes
Limit/pending ordersYes
Copy trading (follow wallets)Yes
Order history & statisticsYes
Buy/sell settingsYes
Wallet managementYes
功能是否需要身份验证?
代币价格、行情数据
持有者统计、巨鲸追踪
智能钱包列表及分析
热门代币发现
下单(买入/卖出)
限价/挂单
跟单交易(追踪钱包)
订单历史与统计
买卖设置
钱包管理

Troubleshooting

问题排查

"token error" (403)

「token error」(403错误)

Cause: Cookie expired or invalid.
Fix:
  1. Re-login at https://www.alph.ai
  2. Get fresh
    dex_cookie
    from browser DevTools
  3. Update your stored value
原因:Cookie过期或无效。
解决方法
  1. 重新登录https://www.alph.ai
  2. 从浏览器开发者工具获取新的
    dex_cookie
  3. 更新已存储的Cookie值

Cookie doesn't work

Cookie无法使用

Check:
  1. Make sure the value ends with
    ==
    (base64 padding)
  2. Don't include
    dex_cookie=
    prefix in the value - just the Base64 string
  3. Make sure you're using
    Cookie: dex_cookie=...
    as the header format
检查项
  1. 确认Cookie值以
    ==
    结尾(Base64填充字符)
  2. 不要包含
    dex_cookie=
    前缀,仅需Base64字符串
  3. 确保请求头格式为
    Cookie: dex_cookie=...

"sys error" (500)

「sys error」(500错误)

Cause: Server issue or missing required params.
Fix:
  1. Add
    "chain":"sol"
    to POST request body
  2. Check if the endpoint is currently available (some are under maintenance)
  3. Retry after a moment
原因:服务器问题或缺少必填参数。
解决方法
  1. 在POST请求体中添加
    "chain":"sol"
  2. 检查该端点是否可用(部分端点可能处于维护中)
  3. 稍后重试

Example Agent Interaction

Agent交互示例

text
User: "I want to check my orders"

Agent:
1. Check if ALPH_DEX_COOKIE env var exists
2. If not:
   "To use trading features, you need to set up authentication first.

    Please:
    1. Log in at https://www.alph.ai
    2. Press F12 → Application → Cookies → www.alph.ai
    3. Copy the 'dex_cookie' value
    4. Tell me the value (or set it as env var: export ALPH_DEX_COOKIE=...)"
3. If yes: proceed to call order API with the cookie
4. If API returns 403: "Your session has expired. Please re-login and get a new cookie."
text
用户:"我想查看我的订单"

Agent:
1. 检查环境变量ALPH_DEX_COOKIE是否存在
2. 如果不存在:
   "要使用交易功能,你需要先完成身份验证设置。

    请按照以下步骤操作:
    1. 登录https://www.alph.ai
    2. 按下F12 → 「Application」 → 「Cookies」 → www.alph.ai
    3. 复制'dex_cookie'的值
    4. 将该值告知我(或设置为环境变量:export ALPH_DEX_COOKIE=...)"
3. 如果存在:使用该Cookie调用订单API
4. 如果API返回403错误:"你的会话已过期,请重新登录并获取新的Cookie。"

Related Skills

相关技能

  • market-data: Public endpoints work without authentication
  • trading-execution: All trading operations need
    dex_cookie
  • market-data:公开端点无需身份验证即可使用
  • trading-execution:所有交易操作均需
    dex_cookie