Get the metadata and contents of requested files
const url = 'https://gitea.com/api/v1/repos/example/example/file-contents';const options = { method: 'POST', headers: {Authorization: 'Basic <credentials>', 'Content-Type': 'application/json'}, body: '{"files":["example"]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://gitea.com/api/v1/repos/example/example/file-contents \ --header 'Authorization: Basic <credentials>' \ --header 'Content-Type: application/json' \ --data '{ "files": [ "example" ] }'Uses automatic pagination based on default page size and max response size and returns the maximum allowed number of files. Files which could not be retrieved are null. Files which are too large are being returned with encoding == null, content == null and size > 0, they can be requested separately by using the download_url.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Owner of the repo
Name of the repo
Query Parameters
Section titled “Query Parameters”The name of the commit/branch/tag. Default to the repository’s default branch.
Request Body
Section titled “Request Body”GetFilesOptions options for retrieving metadate and content of multiple files
object
Examplegenerated
{ "files": [ "example" ]}GetFilesOptions options for retrieving metadate and content of multiple files
object
Responses
Section titled “Responses”ContentsListResponse
ContentsResponse contains information about a repo’s entry’s (dir, file, symlink, submodule) metadata and content
object
FileLinksResponse contains the links for a repo’s file
object
content is populated when type is file, otherwise null
encoding is populated when type is file, otherwise null
submodule_git_url is populated when type is submodule, otherwise null
target is populated when type is symlink, otherwise null
type will be file, dir, symlink, or submodule
Examplegenerated
[ { "_links": { "git": "example", "html": "example", "self": "example" }, "content": "example", "download_url": "example", "encoding": "example", "git_url": "example", "html_url": "example", "last_author_date": "2026-04-15T12:00:00Z", "last_commit_sha": "example", "last_committer_date": "2026-04-15T12:00:00Z", "name": "example", "path": "example", "sha": "example", "size": 1, "submodule_git_url": "example", "target": "example", "type": "example", "url": "example" }]APINotFound is a not found empty response