Skip to content
Try Gitea Cloud ☁️ for 30 days → Accelerate your Development & Deploys!
This is the documentation of the next version, still under development. See the latest release.

The extended "contents" API, to get file metadata and/or content, or list a directory.

GET
/repos/{owner}/{repo}/contents-ext/{filepath}
curl --request GET \
--url https://gitea.com/api/v1/repos/example/example/contents-ext/example \
--header 'Authorization: Basic <credentials>'

It guarantees that only one of the response fields is set if the request succeeds. Users can pass “includes=file_content” or “includes=lfs_metadata” to retrieve more fields. “includes=file_content” only works for single file, if you need to retrieve file contents in batch, use “file-contents” API after listing the directory.

owner
required
string

Owner of the repo

repo
required
string

Name of the repo

filepath
required
string

Path of the dir, file, symlink or submodule in the repo. Swagger requires path parameter to be “required”, you can leave it empty or pass a single dot (“.”) to get the root directory.

ref
string

The name of the commit/branch/tag, default to the repository’s default branch.

includes
string

By default this API’s response only contains file’s metadata. Use comma-separated “includes” options to retrieve more fields. Option “file_content” will try to retrieve the file content, “lfs_metadata” will try to retrieve LFS metadata, “commit_metadata” will try to retrieve commit metadata, and “commit_message” will try to retrieve commit message.

Media typeapplication/json
object
dir_contents

DirContents contains directory listing when the path represents a directory

Array<object>

ContentsResponse contains information about a repo’s entry’s (dir, file, symlink, submodule) metadata and content

object
_links

FileLinksResponse contains the links for a repo’s file

object
git

GitURL is the Git API URL for this file

string
html

HTMLURL is the web URL for this file

string
self

Self is the API URL for this file

string
content

content is populated when type is file, otherwise null

string
download_url

DownloadURL is the direct download URL for this file

string format: uri
encoding

encoding is populated when type is file, otherwise null

string
git_url

GitURL is the Git API URL for this blob or tree

string format: uri
html_url

HTMLURL is the web URL for this file or directory

string format: uri
last_author_date
string format: date-time
last_commit_message

LastCommitMessage is the message of the last commit that affected this file

string
last_commit_sha

LastCommitSHA is the SHA of the last commit that affected this file

string
last_committer_date
string format: date-time
lfs_oid

LfsOid is the Git LFS object ID if this file is stored in LFS

string
lfs_size

LfsSize is the file size if this file is stored in LFS

integer format: int64
mode

mode is the Git file mode as an octal string, e.g. 100644 (regular), 100755 (executable), 120000 (symlink), 160000 (submodule)

string
name

Name is the file or directory name

string
path

Path is the full path to the file or directory

string
sha

SHA is the Git blob or tree SHA

string
size

Size is the file size in bytes

integer format: int64
submodule_git_url

submodule_git_url is populated when type is submodule, otherwise null

string format: uri
target

target is populated when type is symlink, otherwise null

string
type

type will be file, dir, symlink, or submodule

string
url

URL is the API URL for this file or directory

string format: uri
file_contents

ContentsResponse contains information about a repo’s entry’s (dir, file, symlink, submodule) metadata and content

object
_links

FileLinksResponse contains the links for a repo’s file

object
git

GitURL is the Git API URL for this file

string
html

HTMLURL is the web URL for this file

string
self

Self is the API URL for this file

string
content

content is populated when type is file, otherwise null

string
download_url

DownloadURL is the direct download URL for this file

string format: uri
encoding

encoding is populated when type is file, otherwise null

string
git_url

GitURL is the Git API URL for this blob or tree

string format: uri
html_url

HTMLURL is the web URL for this file or directory

string format: uri
last_author_date
string format: date-time
last_commit_message

LastCommitMessage is the message of the last commit that affected this file

string
last_commit_sha

LastCommitSHA is the SHA of the last commit that affected this file

string
last_committer_date
string format: date-time
lfs_oid

LfsOid is the Git LFS object ID if this file is stored in LFS

string
lfs_size

LfsSize is the file size if this file is stored in LFS

integer format: int64
mode

mode is the Git file mode as an octal string, e.g. 100644 (regular), 100755 (executable), 120000 (symlink), 160000 (submodule)

string
name

Name is the file or directory name

string
path

Path is the full path to the file or directory

string
sha

SHA is the Git blob or tree SHA

string
size

Size is the file size in bytes

integer format: int64
submodule_git_url

submodule_git_url is populated when type is submodule, otherwise null

string format: uri
target

target is populated when type is symlink, otherwise null

string
type

type will be file, dir, symlink, or submodule

string
url

URL is the API URL for this file or directory

string format: uri
Examplegenerated
{
"dir_contents": [
{
"_links": {
"git": "example",
"html": "example",
"self": "example"
},
"content": "example",
"download_url": "https://example.com",
"encoding": "example",
"git_url": "https://example.com",
"html_url": "https://example.com",
"last_author_date": "2026-04-15T12:00:00Z",
"last_commit_message": "example",
"last_commit_sha": "example",
"last_committer_date": "2026-04-15T12:00:00Z",
"lfs_oid": "example",
"lfs_size": 1,
"mode": "example",
"name": "example",
"path": "example",
"sha": "example",
"size": 1,
"submodule_git_url": "https://example.com",
"target": "example",
"type": "example",
"url": "https://example.com"
}
],
"file_contents": {
"_links": {
"git": "example",
"html": "example",
"self": "example"
},
"content": "example",
"download_url": "https://example.com",
"encoding": "example",
"git_url": "https://example.com",
"html_url": "https://example.com",
"last_author_date": "2026-04-15T12:00:00Z",
"last_commit_message": "example",
"last_commit_sha": "example",
"last_committer_date": "2026-04-15T12:00:00Z",
"lfs_oid": "example",
"lfs_size": 1,
"mode": "example",
"name": "example",
"path": "example",
"sha": "example",
"size": 1,
"submodule_git_url": "https://example.com",
"target": "example",
"type": "example",
"url": "https://example.com"
}
}

APINotFound is a not found empty response