Get a raw file¶
GET /api/v5/repos/{owner}/{repo}/raw/{path}
Call this endpoint to retrieve the raw content of a file in the repository; the response body is the file's byte stream.
Supported access tokens¶
- AtomGit user access tokens
Anonymous access allowed¶
This endpoint allows anonymous access.
Request parameters¶
| Parameter | Location | Type | Required | Description |
|---|---|---|---|---|
owner |
path | string | Yes | Namespace address to which the repository belongs (address path of the enterprise, organization, or user) |
repo |
path | string | Yes | Repository path (path) |
path |
path | string | Yes | Path of the file, corresponding to the ** segment of raw/** in the URL; special characters must be encoded |
ref |
query | string | No | Branch, tag, or commit (default: the repository's default branch) |
Response parameters¶
The endpoint returns the raw content of the requested file (a byte stream); the response body is the file content itself with no structured JSON fields, and the returned file type depends on the requested file.
Error response¶
On error, the global exception handler returns a JSON error message; the field names follow what the backend actually returns.
400 Invalid parameters
401 Unauthenticated
404 File does not exist
HTTP status codes¶
| Status code | Description |
|---|---|
200 |
Success (OK); returns the raw file content |
401 |
Authentication required (Requires authentication) |
403 |
Access forbidden (Forbidden); no permission to access this repository |
404 |
Repository or file does not exist (Not found) |
500 |
Internal system error (Internal server error) |
Request example¶
Parameter notes¶
Replace
<owner>with the namespace address to which the repository belongs (address path of the enterprise, organization, or user); replace<repo>with the repository path (path); replace<path>with the file path; paths with multiple directories must be encoded (for example, the/indir/file.mdbecomes%2F); replace<ref>with a branch, tag, or commit; when omitted, the repository's default branch is used.
This endpoint allows anonymous access; to access a private repository, send an AtomGit user access token.
cURL¶
JavaScript¶
// Native fetch (Node.js 18+ / browsers)
const response = await fetch("https://api.atomgit.com/api/v5/repos/<owner>/<repo>/raw/<path>?ref=<ref>");
if (!response.ok) {
throw new Error(`Request failed: ${response.status}`);
}
const data = await response.text();
console.log(data);
Python¶
import requests
resp = requests.get(
"https://api.atomgit.com/api/v5/repos/<owner>/<repo>/raw/<path>",
params={"ref": "<ref>"},
timeout=10,
)
resp.raise_for_status()
print(resp.text)
Response example¶
Status code: 200
The response body is the raw content of the file; for example, fetching the raw content of the repository's README.md:
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 |
Request 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