---
title: "Get file contents"
method: GET
path: "/api/source"
tags: ["Git"]
---

# Get file contents

`GET /api/source`

Returns the raw source content of a file at a given repository path and optional git ref.

## Query parameters

- `path` string, required
- `repo` string, required
- `ref` string

## Response `200`

File source and metadata.

- PublicFileSourceResponse
  - `source` string, required
  - `language` string, required
  - `path` string, required
  - `repo` string, required
  - `repoCodeHostType` 'github' | 'gitlab' | 'gitea' | 'gerrit' | 'bitbucketServer' | 'bitbucketCloud' | 'genericGitHost' | 'azuredevops', required
  - `repoDisplayName` string
  - `repoExternalWebUrl` string
  - `webUrl` string, required
  - `externalWebUrl` string
  - `blobSha` string

## Other responses

- `400` — Invalid query parameters or git ref.
- `404` — Repository or file not found.
- `500` — Unexpected file retrieval failure.

---

[API](https://skmtc.dev/sourcebot/apis/sourcebot-public-api.md) · [All operations](https://skmtc.dev/sourcebot/apis/sourcebot-public-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/sourcebot/sourcebot-public-api/revisions/b0ed96fb7103/schema)
