登录记录

查询登录记录

https://api.bilibili.com/x/safecenter/login_notice

请求方式:GET

认证方式:Cookie(SESSDATA)

url参数:

参数名类型内容必要性备注
midnum用户mid必要
buvidstr设备虚拟id非必要web端为操作登录接口时Cookie中的buvid3
若登录设备无buvid则留空

json回复:

根对象:

字段类型内容备注
codenum返回值0:成功
-101:账号未登录
-400:请求错误
messagestr错误信息默认为0
ttlnum1
dataobj信息本体

data对象:

字段类型内容备注
midnum登录用户mid
device_namestr登录设备依靠操作登录接口时的UA决定
login_typestr登录方式根据登录接口决定
login_timestr登录时间YYYY-MM-DD hh:mm:ss
locationstr登录位置依靠ip决定
ipstr登录ip部分用*打码

示例:

查询用户293793435设备id为fuck_chenrui的登录记录

curl -G 'https://api.bilibili.com/x/safecenter/login_notice' \
--data-urlencode 'mid=293793435' \
--data-urlencode 'buvid=fuck_chenrui' \
-b 'SESSDATA=xxx'
查看响应示例:
{
    "code": 0,
    "message": "0",
    "ttl": 1,
    "data": {
        "mid": 293793435,
        "device_name": "Chrome浏览器",
        "login_type": "扫码登录",
        "login_time": "2020-10-02 22:42:38",
        "location": "中国陕西渭南",
        "ip": "36.40.***.**"
    }
}

最近一周的登录情况

https://api.bilibili.com/x/member/web/login/log

请求方式: GET

认证方式: Cookie (SESSDATA)

URL参数:

参数名类型内容必要性备注
jsonpstr回调函数名?非必要默认 jsonp
web_locationstr网页位置?非必要默认 333.33

JSON回复:

根对象:

字段类型内容备注
codenum返回值0:成功
-101:账号未登录
messagestr错误信息默认为 0
ttlnum1
dataobj信息本体

data对象:

字段类型内容备注
countnum记录总数
listarr登录记录列表

data中的list数组:

类型内容备注
0obj登录记录1
……obj……
nobj登录记录(n+1)

list数组中的对象:

字段类型内容备注
ipstr登录 IP末两位以 * 打码
timenum登录时间UNIX 秒级时间戳
time_atstr登录时间格式为 yyyy-MM-dd HH:mm:ss
statusbool是否登录成功?
typenum登录方式?
geostr登录地理位置

示例:

查询本用户最近一周的登录情况

curl -G "https://api.bilibili.com/x/member/web/login/log" \
-b "SESSDATA=xxx"
查看响应示例:
{
  "code": 0,
  "message": "0",
  "ttl": 1,
  "data": {
    "count": 14,
    "list": [
      {
        "ip": "108.181.*.*",
        "time": 1722036741,
        "time_at": "2024-07-27 07:32:21",
        "status": true,
        "type": 0,
        "geo": "美国加利福尼亚州洛杉矶telus.com"
      },
      {
        "ip": "104.28.*.*",
        "time": 1722040653,
        "time_at": "2024-07-27 08:37:33",
        "status": true,
        "type": 0,
        "geo": "巴西"
      },
      {
        "ip": "104.28.*.*",
        "time": 1721950332,
        "time_at": "2024-07-26 07:32:12",
        "status": true,
        "type": 0,
        "geo": "新加坡cloudflare.com"
      },
      {
        "ip": "104.28.*.*",
        "time": 1721964627,
        "time_at": "2024-07-26 11:30:27",
        "status": true,
        "type": 0,
        "geo": "美国弗吉尼亚州雷斯顿cloudflare.com"
      },
      {
        "ip": "143.92.*.*",
        "time": 1721861861,
        "time_at": "2024-07-25 06:57:41",
        "status": true,
        "type": 0,
        "geo": "中国香港特别行政区"
      },
      {
        "ip": "143.92.*.*",
        "time": 1721861855,
        "time_at": "2024-07-25 06:57:35",
        "status": true,
        "type": 0,
        "geo": "中国香港特别行政区"
      },
      {
        "ip": "104.28.*.*",
        "time": 1721709514,
        "time_at": "2024-07-23 12:38:34",
        "status": true,
        "type": 0,
        "geo": "日本千叶县成田市cloudflare.com"
      },
      {
        "ip": "104.28.*.*",
        "time": 1721709618,
        "time_at": "2024-07-23 12:40:18",
        "status": true,
        "type": 0,
        "geo": "日本千叶县成田市cloudflare.com"
      },
      {
        "ip": "143.92.*.*",
        "time": 1721636125,
        "time_at": "2024-07-22 16:15:25",
        "status": true,
        "type": 0,
        "geo": "中国香港特别行政区"
      },
      {
        "ip": "143.92.*.*",
        "time": 1721636111,
        "time_at": "2024-07-22 16:15:11",
        "status": true,
        "type": 0,
        "geo": "中国香港特别行政区"
      },
      {
        "ip": "104.28.*.*",
        "time": 1721539870,
        "time_at": "2024-07-21 13:31:10",
        "status": true,
        "type": 0,
        "geo": "美国加利福尼亚州东洛杉矶cloudflare.com"
      },
      {
        "ip": "104.28.*.*",
        "time": 1721539965,
        "time_at": "2024-07-21 13:32:45",
        "status": true,
        "type": 0,
        "geo": "美国加利福尼亚州东洛杉矶cloudflare.com"
      },
      {
        "ip": "42.2.*.*",
        "time": 1721477962,
        "time_at": "2024-07-20 20:19:22",
        "status": true,
        "type": 0,
        "geo": "中国香港特别行政区pccw.com"
      },
      {
        "ip": "42.2.*.*",
        "time": 1721477960,
        "time_at": "2024-07-20 20:19:20",
        "status": true,
        "type": 0,
        "geo": "中国香港特别行政区pccw.com"
      }
    ]
  }
}