首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何从Mastodon API获取公共用户信息?

如何从Mastodon API获取公共用户信息?
EN

Stack Overflow用户
提问于 2022-11-18 15:17:58
回答 1查看 36关注 0票数 0

我看到像https://mastodon.lol/@rosinmas这样的用户,根据文档,API端点应该是:https://mastodon.lol/api/v1/accounts/@rosinmas

但我明白:

代码语言:javascript
复制
{"error":"Record not found"}

为什么使用端点不是公共的?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-11-18 22:10:56

您可以使用以下格式调用API,从而获得JSON (不需要身份验证)的帐户信息:

代码语言:javascript
复制
https://[server_name]/api/v1/accounts/[account_id]

例如:

代码语言:javascript
复制
https://mastodon.social/api/v1/accounts/1

会给你:

代码语言:javascript
复制
{
  "id": "1",
  "username": "Gargron",
  "acct": "Gargron",
  "display_name": "Eugen Rochko",
  "locked": false,
  "bot": false,
  "discoverable": true,
  "group": false,
  "created_at": "2016-03-16T00:00:00.000Z",
  "note": "<p>Founder, CEO and lead developer <span class=\"h-card\"><a href=\"https://mastodon.social/@Mastodon\" class=\"u-url mention\">@<span>Mastodon</span></a></span>, Germany.</p>",
  "url": "https://mastodon.social/@Gargron",
  "avatar": "https://files.mastodon.social/accounts/avatars/000/000/001/original/dc4286ceb8fab734.jpg",
  "avatar_static": "https://files.mastodon.social/accounts/avatars/000/000/001/original/dc4286ceb8fab734.jpg",
  "header": "https://files.mastodon.social/accounts/headers/000/000/001/original/3b91c9965d00888b.jpeg",
  "header_static": "https://files.mastodon.social/accounts/headers/000/000/001/original/3b91c9965d00888b.jpeg",
  "followers_count": 222337,
  "following_count": 326,
  "statuses_count": 72729,
  "last_status_at": "2022-11-18",
  "noindex": false,
  "emojis": [],
  "fields": [
    {
      "name": "Patreon",
      "value": "<a href=\"https://www.patreon.com/mastodon\" target=\"_blank\" rel=\"nofollow noopener noreferrer me\"><span class=\"invisible\">https://www.</span><span class=\"\">patreon.com/mastodon</span><span class=\"invisible\"></span></a>",
      "verified_at": null
    }
  ]
}

要获得给定usernameusername,可以传递以下API调用:

代码语言:javascript
复制
https://[server_name]/api/v2/search?q=[username]

例如:

代码语言:javascript
复制
https://mastodon.social/api/v2/search?q=Gargron

会给你关于服务器上所有Gargron用户名的详细信息.

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74491788

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档