---
title: "Get the metadata and contents of requested files"
method: GET
path: "/repos/{owner}/{repo}/file-contents"
tags: ["repository"]
---

# Get the metadata and contents of requested files

`GET /repos/{owner}/{repo}/file-contents`

## Request

- Base URL: `https://demo.gitea.com/api/v1`
- URL: `https://demo.gitea.com/api/v1/repos/{owner}/{repo}/file-contents`
- Auth: one of:
  - HTTP basic
  - API key in query parameter `token`
  - API key in query parameter `access_token`
  - API key in header `Authorization`
  - API key in query parameter `sudo`
  - API key in header `Sudo`
  - API key in header `X-GITEA-OTP`
- TypeScript: <https://skmtc.dev/gitea/apis/gitea-api/docs/repos/:owner/:repo/file-contents/get.ts> (a function with typed inputs; its response is checked against the schema)

See the POST method. This GET method supports using JSON encoded request body in query parameter.

## Path parameters

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

## Query parameters

- `ref` string
- `body` string, required

## Response `200`

ContentsListResponse

- ContentsResponse[]
  - `_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

- `default`: APIError is error format response

## Changes

- **2026-10-28** `7ef50c4c527f`: 1 info
  - removed the non-success response with the status `404`
- **2025-05-20** `4ff3544d6eb3`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/gitea/apis/gitea-api/changes/repos/:owner/:repo/file-contents/get.md)

---

[API](https://skmtc.dev/gitea/apis/gitea-api.md) - [All operations](https://skmtc.dev/gitea/apis/gitea-api/llms.txt) - [OpenAPI document](https://skmtc.dev/gitea/apis/gitea-api/revisions/7ef50c4c527f?raw)
