Skip to content

Get the namespace of the authorized user

GET /api/v5/user/namespace

Call this endpoint to get a namespace of the authorized user.

Supported access tokens

  • AtomGit user access token (AtomGit user access tokens)

Anonymous access

This endpoint does not allow anonymous access.

Request parameters

Parameter Location Type Required Description
access_token query string Yes User authorization code
path query string Yes Namespace path (path)

Response parameters

Field Type Always returned Nullable Description
id integer Yes No Namespace ID
path string Yes No Namespace path (path)
name string Yes No Namespace name
html_url string Yes No Namespace URL
type string Yes No Namespace type, enum: user(user)/ group(organization)

Error response

400 Invalid parameters

{
  "error": "invalid_request",
  "message": "Parameter path cannot be empty",
  "field": "path"
}

401 Unauthenticated

{
  "error": "unauthorized",
  "message": "Missing or invalid access token"
}

The actual error field names returned by the backend take precedence.

HTTP status codes

Status code Description
200 Success (OK)
400 Bad request
401 Requires authentication
403 Forbidden
404 Not found
500 Internal server error

Request example

Parameter notes

<path> replace with the namespace path to query (enterprise, organization, or personal address path); <token> replace with your AtomGit user access token.

cURL

curl -X GET 'https://api.atomgit.com/api/v5/user/namespace?access_token=<token>&path=<path>' \
  -H 'Accept: application/json'

JavaScript

// Native fetch (Node.js 18+ / browser)
const params = new URLSearchParams({
  access_token: "<YOUR-TOKEN>",
  path: "<namespace-path>",
});

const response = await fetch(`https://api.atomgit.com/api/v5/user/namespace?${params}`, {
  headers: {
    "Accept": "application/json",
  },
});

if (!response.ok) {
  throw new Error(`Request failed: ${response.status}`);
}

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

Python

import requests

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

print(resp.json())

Response example

Status code: 200

{
  "id": 138108,
  "path": "xiaogang_test",
  "name": "aaasfd/sda/fsdaf/sdfsa",
  "html_url": "https://api.atomgit.com/xiaogang_test",
  "type": "group"
}

Error codes

Error code Description
401 Unauthenticated or invalid credentials (missing or invalid access token)
400 Invalid parameters or unparseable request
403 Forbidden
404 Request path does not exist
500 Internal system error

Markdown source: View on AtomGit·Content from the open-source project gitcode-dev/atomgit-api-doc