跳转至

获取组织成员详情

GET /api/v5/orgs/{org}/members/{username}

该接口用于获取指定组织下某一成员的详细信息,返回内容包括成员记录ID、组织路径、名称、地址、头像地址,以及成员对应的用户信息(如用户名、显示名称、头像和主页地址)。

访问令牌支持说明

  • AtomGit 用户访问令牌(AtomGit user access tokens)

是否允许匿名访问

此接口不允许匿名访问

请求参数

参数名 位置 类型 必填 说明
org path string 是 组织的路径(path/login)
username path string 是 用户名(username/login)
access_token query string 是 用户授权码

响应参数

字段 类型 必返 可为空 说明
id integer 是 否 成员记录 ID
path string 是 否 组织的路径(path/login)
name string 是 否 名称(可能为空字符串)
url string 是 否 地址(可能为空字符串)
avatar_url string 是 是 头像地址,可为 null
user object 是 否 成员的用户信息

user 对象

字段 类型 必返 可为空 说明
user.id string 是 否 用户唯一标识
user.login string 是 否 用户名(username/login)
user.name string 是 否 用户显示名称
user.avatar_url string 是 是 用户头像地址,可为 null
user.html_url string 是 否 用户主页地址
user.user_id string 否 是 用户 ID
user.object_id string 否 是 对象 ID

失败响应

以下失败响应为通用示例,错误响应体的字段名以后端实际返回为准。

401 未认证

{
  "error": "unauthorized",
  "message": "缺少或无效的访问令牌"
}

404 未找到

{
  "error": "not_found",
  "message": "组织或成员不存在"
}

HTTP 响应状态码

状态码 说明
200 成功(OK)
401 需要认证(Requires authentication)
403 禁止访问(Forbidden)
404 未找到(Not found)

请求示例

参数说明

<org> 替换为组织路径名(企业、组织或个人的地址 path); <username> 替换为成员用户名(username/login); <token> 替换为你的 AtomGit 用户访问令牌。

cURL

curl -X GET 'https://api.atomgit.com/api/v5/orgs/<org>/members/<username>?access_token=<token>' \
  -H 'Accept: application/json'

JavaScript

// 原生 fetch (Node.js 18+ / 浏览器)
const url = new URL("https://api.atomgit.com/api/v5/orgs/<org>/members/<username>");
url.searchParams.set("access_token", "<YOUR-TOKEN>");

const response = await fetch(url, {
  headers: {
    "Accept": "application/json",
  },
});

if (!response.ok) {
  throw new Error(`请求失败: ${response.status}`);
}

const data = await response.json();
console.log(data);

Python

import requests

resp = requests.get(
    "https://api.atomgit.com/api/v5/orgs/<org>/members/<username>",
    params={"access_token": "<YOUR-TOKEN>"},
    headers={
        "Accept": "application/json",
    },
    timeout=10,
)
resp.raise_for_status()

print(resp.json())

响应示例

状态码: 200

{
  "id": 133039,
  "path": "openharmony",
  "name": "",
  "url": "",
  "avatar_url": null,
  "user": {
    "id": "64dc3b13b8b9504cec223ab1",
    "login": "theo6789",
    "name": "TheoCui",
    "avatar_url": null,
    "html_url": "https://api.atomgit.com/theo6789"
  }
}

错误码

错误码 说明
401 未认证或凭证无效(缺少/无效的访问凭证)
400 参数错误或请求无法解析
404 请求路径不存在
405 请求方法不支持
429 请求过于频繁,触发限流
500 系统内部错误

本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 gitcode-dev/atomgit-api-doc