Get a file blob¶
GET /api/v5/repos/{owner}/{repo}/git/blobs/{sha}
This endpoint retrieves the file Blob content for the specified repository and file Blob SHA. It returns the content size, resource access URL, the Base64-encoded content, and its encoding method.
Access token support¶
- AtomGit user access tokens (AtomGit user access tokens)
Anonymous access¶
This endpoint allows anonymous access.
Request parameters¶
| Parameter | Location | Type | Required | Description |
|---|---|---|---|---|
owner |
path | string | Yes | Namespace address the repository belongs to (organization or personal path) |
repo |
path | string | Yes | Repository path (path) |
sha |
path | string | Yes | Blob SHA of the file; you can obtain it through the "Get contents at a specific repository path" endpoint |
Response parameters¶
| Field | Type | Always returned | Nullable | Description |
|---|---|---|---|---|
sha |
string | Yes | No | Blob SHA of the file |
size |
integer | Yes | No | File content size (in bytes) |
url |
string | Yes | No | Access URL of the Blob resource |
content |
string | Yes | No | File content (Base64-encoded) |
encoding |
string | Yes | No | File content encoding; the example value is base64 |
Error responses¶
The following are examples of errors this endpoint may return; the error field names are subject to the actual backend response. If you cannot confirm them, refer to the actual response.
400 Invalid parameters
401 Unauthenticated
404 Resource not found
HTTP response status codes¶
| Status code | Description |
|---|---|
200 |
Success (OK) |
401 |
Authentication required (Requires authentication) |
403 |
Forbidden |
404 |
Resource not found (Not found) |
Request example¶
Parameter notes¶
Replace
<owner>with the namespace address the repository belongs to (enterprise, organization, or personal path); replace<repo>with the repository path (path); replace<sha>with the Blob SHA of the file.This endpoint allows anonymous access, so the examples can omit the access token. If needed, you can include an AtomGit user access token.
cURL¶
curl -X GET 'https://api.atomgit.com/api/v5/repos/<owner>/<repo>/git/blobs/<sha>' -H 'Accept: application/json'
JavaScript¶
// Native fetch (Node.js 18+ / browser)
const response = await fetch("https://api.atomgit.com/api/v5/repos/<owner>/<repo>/git/blobs/<sha>", {
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>/git/blobs/<sha>",
headers={
"Accept": "application/json",
},
timeout=10,
)
resp.raise_for_status()
print(resp.json())
Response example¶
Status code: 200
{
"sha": "e5699fe1b360d6c799ee58b24fb5a670b1e14851",
"size": 19,
"url": "https://api.atomgit.com/api/v5/repos/daming_1/zhu_di/git/blobs/e5699fe1b360d6c799ee58b24fb5a670b1e14851",
"content": "JXU2RDRCJXU4QkQ1d2ViaG9vaw==",
"encoding": "base64"
}
Error codes¶
| Error code | Description |
|---|---|
401 |
Unauthenticated or invalid credentials (missing/invalid access credentials) |
400 |
Invalid parameters or the request cannot be parsed |
404 |
The requested path does not exist |
405 |
Request method 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