From 9b7afcfd51e03ec3457140ad5b3f37a33c73e8d1 Mon Sep 17 00:00:00 2001 From: zhl Date: Tue, 18 Apr 2023 22:14:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=8E=A5=E5=8F=A3=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/apis.md | 119 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 docs/apis.md diff --git a/docs/apis.md b/docs/apis.md new file mode 100644 index 0000000..419956e --- /dev/null +++ b/docs/apis.md @@ -0,0 +1,119 @@ +# 徽章活动相关接口 + +### 说明 +1. 通用返回格式, errcode=0 表示无错误 + +2. 如无特别说明, 以下接口的Response格式指的是 data 字段 +3. 接口名中带*的表示, 需要验证token, token可以设置header的Authorization: Bearer JWT_token, 或Post body的token字段, 或Get的query token + +```json +{ + "errcode": Number, + "errmsg": String, + "data": {} +} +``` + +### 1. 钱包预登录 + +#### Request + +- URL:`/api/user/login` +- 方法:`GET` + +#### Response + +```json +{ + "nonce": String, + "tips": String +} +``` + +### 2. 钱包登录 + +客户端在获得钱包地址后,须先调用预登录方法获取nonce和tips, 然后调用钱包进行EIP-721签名. + +登录成功后返回的jwt需要保存至本地存储, 再次载入后, 可解析并获取exp字段, 判断当前token是否已经过期 + +#### Request + +- URL:`/api/user/login` +- 方法:`POST` +- 头部: + - Content-type: application/json +- Body: + +```json +{ + "nonce": Number, + "signature": String, + "account": String +} +``` + +#### Response + +```json +{ + "token": String, +} +``` + + +### 3. *检查当前用户claim状态 + + +#### Request + +- URL:`/api/user/status` +- 方法:`GET` +- 头部: + - Authorization: Bearer JWT_token +- 参数: + - `uid`(用户 ID) + +#### Response + +- 类型:对象 +- 属性: + - `account`(对象):用户账户信息。 + - `user`(对象):认证用户的信息。 + +### 4. *用户申请claim + + +#### Request + +- URL:`/api/user/claim` +- 方法:`POST` +- 头部: + - Authorization: Bearer JWT_token +- Body: 空对象 `{}`。 + +#### Response + +```json +{ + "taskId": String, +} +``` + +### 5.* 检查claim任务的状态 + + +#### Request + +- URL:`/api/user/claim/:taskId` +- 方法:`GET` +- 头部: + - Authorization: Bearer JWT_token + +#### Response + +```json +{ + "status": Number, + "txHashList": [String], +} +```