Skip to content

Get repository license agreement

GET /api/v5/repos/{owner}/{repo}/license

This endpoint returns the license agreement of the specified repository, including the agreement file's name, path, size, access URL, file content, and encoding, together with the SPDX identifier of the license agreement, so that users can review the repository's open source licensing information.

Access token support

  • AtomGit user access tokens

Anonymous access

This endpoint allows anonymous access.

Request parameters

Parameter Location Type Required Description
owner path string Yes Address of the namespace that owns the repository (the address path of the enterprise, organization, or personal namespace)
repo path string Yes Repository path (path)

Response parameters

Field Type Always returned Nullable Description
name string Yes — License agreement file name
path string Yes — License agreement file path
size integer Yes — File size
url string Yes — File access URL
html_url string Yes — URL for accessing the file in the browser
content string Yes — File content
encoding string Yes — Encoding of the file content
license object Yes — License agreement information

license object

Field Type Always returned Nullable Description
license.spdx_id string Yes — SPDX identifier of the license agreement

Error response

This endpoint has no business-level error response.

HTTP response status codes

Status code Description
200 Succeeded (OK)
304 Not modified
401 Authentication required (Requires authentication)
403 Access forbidden (Forbidden)

Request example

Parameter notes

Replace <owner> with the address of the namespace that owns the repository (the address path of the enterprise, organization, or personal namespace); replace <repo> with the repository path (path). This endpoint allows anonymous access, so the request examples do not carry an access token; if needed, you can also pass <token> (an AtomGit user access token) in the query parameters.

cURL

curl -X GET 'https://api.atomgit.com/api/v5/repos/{owner}/{repo}/license' \
  -H 'Accept: application/json'

JavaScript

// Native fetch (Node.js 18+ / browser)
const response = await fetch("https://api.atomgit.com/api/v5/repos/{owner}/{repo}/license", {
  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/repos/{owner}/{repo}/license",
    headers={
        "Accept": "application/json",
    },
    timeout=10,
)
resp.raise_for_status()

print(resp.json())

Response example

Status code: 200

{
  "name": "LICENSE",
  "path": "LICENSE",
  "size": 1073,
  "url": "https://api.atomgit.com/api/v5/repos/{owner}/{repo}/license",
  "html_url": "https://api.atomgit.com/{owner}/{repo}/blob/main/LICENSE",
  "content": "<file content encoded in base64>",
  "encoding": "base64",
  "license": {
    "spdx_id": "MIT"
  }
}

Error codes

Error code Description
401 Unauthenticated or invalid credentials (missing or invalid access credentials)
400 Invalid parameters, or the request cannot be parsed
404 The request path does not exist
405 The request method is not supported
429 Too many requests; rate limit triggered
500 Internal system error

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