如何使用 StackExchange API 从用户个人资料页面获取 "top x% this y"?

How can I get "top x% this y" from a user profile page using the StackExchange API?

使用 the StackExchange API,可以了解有关用户的很多信息:

{
  "badge_counts": {
    "bronze": 3,
    "silver": 2,
    "gold": 1
  },
  "view_count": 1000,
  "down_vote_count": 50,
  "up_vote_count": 90,
  "answer_count": 10,
  "question_count": 12,
  "account_id": 1,
  "is_employee": false,
  "last_modified_date": 1625694512,
  "last_access_date": 1625737712,
  "reputation_change_year": 9001,
  "reputation_change_quarter": 400,
  "reputation_change_month": 200,
  "reputation_change_week": 800,
  "reputation_change_day": 100,
  "reputation": 9001,
  "creation_date": 1625694512,
  "user_type": "registered",
  "user_id": 1,
  "accept_rate": 55,
  "about_me": "about me block",
  "location": "An Imaginary World",
  "website_url": "http://example.com/",
  "link": "http://example.stackexchange.com/users/1/example-user",
  "profile_image": "https://www.gravatar.com/avatar/a007be5a61f6aa8f3e85ae2fc18dd66e?d=identicon&r=PG",
  "display_name": "Example User"
}

此外,我想获取您在 activity 概览中总声誉旁边找到的字符串,例如,

top 5.43% this year

是否可以使用 API 以某种方式获取它?

the SE API nor SEDE 均未提供此类字段。相反,您可以

GET /users/rank?userId=<userId>

然后解析返回的HTML得到你想要的百分比。对于你(?user=353337),它看起来像这样:

<a href="https://stackexchange.com/leagues/1/year/Whosebug/2021-01-01/353337#353337" target="_blank">top <b>0.20%</b> this year</a>