> ## Documentation Index
> Fetch the complete documentation index at: https://docs.patch.gg/llms.txt
> Use this file to discover all available pages before exploring further.

# A file in a repo

> At a branch, tag or commit: its text up to 512 KiB, `truncated` past that, or `binary`, and its size. A file in Git LFS has its hash, size and a download link in `big_file`, and the link is null unless this repo holds the file or it's one of the library's public files. `raw_url` is where a browser gets its bytes. 404 `ref_not_found`, `path_not_found` or `not_a_file`.



## OpenAPI

````yaml /api-reference/openapi.json get /projects/{owner}/{slug}/repo/file
openapi: 3.1.0
info:
  title: Patch API
  version: 1.0.0
  description: >-
    The public API behind patch.gg, the desktop app and pch. Changes within v1
    are additive only. Errors are { error: { code, message, details } }; branch
    on code.
servers:
  - url: https://patch.gg/api/v1
security: []
paths:
  /projects/{owner}/{slug}/repo/file:
    get:
      tags:
        - Repos
      summary: A file in a repo
      description: >-
        At a branch, tag or commit: its text up to 512 KiB, `truncated` past
        that, or `binary`, and its size. A file in Git LFS has its hash, size
        and a download link in `big_file`, and the link is null unless this repo
        holds the file or it's one of the library's public files. `raw_url` is
        where a browser gets its bytes. 404 `ref_not_found`, `path_not_found` or
        `not_a_file`.
      parameters:
        - schema:
            type: string
            example: patch
          required: true
          name: owner
          in: path
        - schema:
            type: string
            example: demo-mod
          required: true
          name: slug
          in: path
        - schema:
            type: string
            pattern: ^\S{1,255}$
            description: >-
              A branch, a tag or a full commit hash: the default branch unless
              you say. A branch comes before a tag of the same name, and
              `refs/tags/v1` says which.
            example: main
          required: false
          description: >-
            A branch, a tag or a full commit hash: the default branch unless you
            say. A branch comes before a tag of the same name, and
            `refs/tags/v1` says which.
          name: ref
          in: query
        - schema:
            type: string
            minLength: 1
            maxLength: 4096
            description: A file in the repo, from its top
            example: docs/guide.md
          required: true
          description: A file in the repo, from its top
          name: path
          in: query
      responses:
        '200':
          description: The file
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RepoFile'
        '308':
          description: Renamed; follow the Location header
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Not signed in
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Not allowed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: '`on_github`: its home is GitHub, which has its files'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: >-
            Too many requests: wait as long as `Retry-After` says
            (`retry_after_s` in `details`), then retry
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '502':
          description: It couldn't be read
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: Reading repos isn't set up here, or the repo is waking up
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    RepoFile:
      type: object
      properties:
        ref:
          type: string
          description: >-
            The branch, tag or full commit hash it was asked for: the default
            branch unless given.
        commit:
          type: string
          description: The full commit hash that resolved to.
        path:
          type: string
        type:
          type: string
          enum:
            - blob
            - exec
            - symlink
            - gitlink
        mode:
          type: string
          example: '100644'
        hash:
          type: string
          description: >-
            Its git object. For a submodule, the commit it's at, or empty when
            that can't be found.
        size:
          type: integer
          description: >-
            Its size in bytes: for a file in Git LFS, the big file's, not its
            pointer's.
        binary:
          type: boolean
          description: >-
            Whether it has no text to show: a NUL in its first 8 KB, not valid
            UTF-8, a big file or a submodule.
        text:
          type:
            - string
            - 'null'
          description: Its text, its first 512 KiB at most.
        truncated:
          type: boolean
          description: Whether `text` stops before the file does.
        big_file:
          type:
            - object
            - 'null'
          properties:
            sha256:
              type: string
            size:
              type: integer
            download_url:
              type:
                - string
                - 'null'
              description: >-
                A signed link that downloads it. Null when this repo doesn't
                hold the file, whatever its pointer says.
            expires_at:
              type:
                - string
                - 'null'
              format: date-time
          required:
            - sha256
            - size
            - download_url
            - expires_at
          description: The big file, when this is a Git LFS pointer.
        raw_url:
          type:
            - string
            - 'null'
          description: >-
            Where a browser gets its bytes at this commit, from outside
            patch.gg. Null for a submodule.
      required:
        - ref
        - commit
        - path
        - type
        - mode
        - hash
        - size
        - binary
        - text
        - truncated
        - big_file
        - raw_url
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              example: version_exists
            message:
              type: string
            details: {}
          required:
            - code
            - message
      required:
        - error

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.