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

# 读取文件 - GET /v1/workspaces/:workspace_id/code-repos/:repo_id/files

> 通过 GET /v1/workspaces/:workspace_id/code-repos/:repo_id/files 读取仓库内某文件的源码。最小角色 viewer。

读取代码仓库内某个文件的源码内容。

## 接口

```http theme={null}
GET /v1/workspaces/:workspace_id/code-repos/:repo_id/files
```

## 认证

`Authorization: Bearer <jwt>` 或 `X-API-Key <sk_...>`。最小角色：**viewer**。

## 路径参数

<ParamField path="workspace_id" type="string" required>
  工作空间 id。
</ParamField>

<ParamField path="repo_id" type="string" required>
  仓库 id。
</ParamField>

## 查询参数

<ParamField query="path" type="string" required>
  仓库内文件相对路径。
</ParamField>

## 响应

<ResponseField name="content" type="string">
  文件源码内容。
</ResponseField>

## 示例

<RequestExample>
  ```bash cURL theme={null}
  curl "https://memo.ariacompute.cn/v1/workspaces/ws_01a2b3c4d5e6/code-repos/repo_01a2b3c4d5e6/files?path=internal/api/api.go" \
    -H "Authorization: Bearer <jwt>"
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "content": "package api\n\nimport (\n\t\"github.com/gin-gonic/gin\"\n)\n\n// RegisterRoutes ...\n"
  }
  ```
</ResponseExample>


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