---
title: "The extended \"contents\" API, to get file metadata and/or content, or list a directory."
method: GET
path: "/repos/{owner}/{repo}/contents-ext/{filepath}"
tags: ["repository"]
---

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

`GET /repos/{owner}/{repo}/contents-ext/{filepath}`

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.

## Path parameters

- `owner` string, required
- `repo` string, required
- `filepath` string, required

## Query parameters

- `ref` string
- `includes` string

## Response `200`

- ContentsExtResponse
  - `dir_contents` ContentsResponse[] — DirContents contains directory listing when the path represents a directory
    - `_links` FileLinksResponse — FileLinksResponse contains the links for a repo's file
      - `git` string — GitURL is the Git API URL for this file
      - `html` string — HTMLURL is the web URL for this file
      - `self` string — Self is the API URL for this file
    - `content` string — `content` is populated when `type` is `file`, otherwise null
    - `download_url` string — DownloadURL is the direct download URL for this file
    - `encoding` string — `encoding` is populated when `type` is `file`, otherwise null
    - `git_url` string — GitURL is the Git API URL for this blob or tree
    - `html_url` string — HTMLURL is the web URL for this file or directory
    - `last_author_date` string, date-time
    - `last_commit_message` string — LastCommitMessage is the message of the last commit that affected this file
    - `last_commit_sha` string — LastCommitSHA is the SHA of the last commit that affected this file
    - `last_committer_date` string, date-time
    - `lfs_oid` string — LfsOid is the Git LFS object ID if this file is stored in LFS
    - `lfs_size` integer — LfsSize is the file size if this file is stored in LFS
    - `mode` string — `mode` is the Git file mode as an octal string, e.g. `100644` (regular), `100755` (executable), `120000` (symlink), `160000` (submodule)
    - `name` string — Name is the file or directory name
    - `path` string — Path is the full path to the file or directory
    - `sha` string — SHA is the Git blob or tree SHA
    - `size` integer — Size is the file size in bytes
    - `submodule_git_url` string — `submodule_git_url` is populated when `type` is `submodule`, otherwise null
    - `target` string — `target` is populated when `type` is `symlink`, otherwise null
    - `type` string — `type` will be `file`, `dir`, `symlink`, or `submodule`
    - `url` string — URL is the API URL for this file or directory
  - `file_contents` ContentsResponse — ContentsResponse contains information about a repo's entry's (dir, file, symlink, submodule) metadata and content
    - `_links` FileLinksResponse — FileLinksResponse contains the links for a repo's file
      - `git` string — GitURL is the Git API URL for this file
      - `html` string — HTMLURL is the web URL for this file
      - `self` string — Self is the API URL for this file
    - `content` string — `content` is populated when `type` is `file`, otherwise null
    - `download_url` string — DownloadURL is the direct download URL for this file
    - `encoding` string — `encoding` is populated when `type` is `file`, otherwise null
    - `git_url` string — GitURL is the Git API URL for this blob or tree
    - `html_url` string — HTMLURL is the web URL for this file or directory
    - `last_author_date` string, date-time
    - `last_commit_message` string — LastCommitMessage is the message of the last commit that affected this file
    - `last_commit_sha` string — LastCommitSHA is the SHA of the last commit that affected this file
    - `last_committer_date` string, date-time
    - `lfs_oid` string — LfsOid is the Git LFS object ID if this file is stored in LFS
    - `lfs_size` integer — LfsSize is the file size if this file is stored in LFS
    - `mode` string — `mode` is the Git file mode as an octal string, e.g. `100644` (regular), `100755` (executable), `120000` (symlink), `160000` (submodule)
    - `name` string — Name is the file or directory name
    - `path` string — Path is the full path to the file or directory
    - `sha` string — SHA is the Git blob or tree SHA
    - `size` integer — Size is the file size in bytes
    - `submodule_git_url` string — `submodule_git_url` is populated when `type` is `submodule`, otherwise null
    - `target` string — `target` is populated when `type` is `symlink`, otherwise null
    - `type` string — `type` will be `file`, `dir`, `symlink`, or `submodule`
    - `url` string — URL is the API URL for this file or directory

## Other responses

- `404` — APINotFound is a not found empty response

---

[API](https://skmtc.net/gitea/apis/gitea-api.md) · [All operations](https://skmtc.net/gitea/apis/gitea-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/gitea/gitea-api/versions/350de506cefa/schema)
