curl --request POST \
--url https://app.codealive.ai/api/tools/read_file \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"path": "<string>",
"data_source": "<string>",
"start_line": 123,
"end_line": 123
}
'import requests
url = "https://app.codealive.ai/api/tools/read_file"
payload = {
"path": "<string>",
"data_source": "<string>",
"start_line": 123,
"end_line": 123
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({path: '<string>', data_source: '<string>', start_line: 123, end_line: 123})
};
fetch('https://app.codealive.ai/api/tools/read_file', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.codealive.ai/api/tools/read_file",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'path' => '<string>',
'data_source' => '<string>',
'start_line' => 123,
'end_line' => 123
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://app.codealive.ai/api/tools/read_file"
payload := strings.NewReader("{\n \"path\": \"<string>\",\n \"data_source\": \"<string>\",\n \"start_line\": 123,\n \"end_line\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://app.codealive.ai/api/tools/read_file")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"path\": \"<string>\",\n \"data_source\": \"<string>\",\n \"start_line\": 123,\n \"end_line\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.codealive.ai/api/tools/read_file")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"path\": \"<string>\",\n \"data_source\": \"<string>\",\n \"start_line\": 123,\n \"end_line\": 123\n}"
response = http.request(request)
puts response.read_body{
"obj": {
"hint": "<string>",
"found": true,
"files": [
{
"identifier": "<string>",
"path": "<string>",
"dataSource": {
"type": "<string>",
"name": "<string>"
},
"fullName": "<string>",
"startLine": 123,
"endLine": 123,
"contentByteSize": 123,
"numberedContent": "<string>"
}
],
"candidates": [
{
"identifier": "<string>",
"path": "<string>",
"dataSource": {
"type": "<string>",
"name": "<string>"
},
"fullName": "<string>"
}
],
"sameNameCandidates": [
{
"identifier": "<string>",
"path": "<string>",
"dataSource": {
"type": "<string>",
"name": "<string>"
},
"fullName": "<string>"
}
],
"sameNameTotalCount": 123,
"error": {
"tool": "<string>",
"detail": "<string>",
"retry": "<string>",
"hint": "<string>"
},
"warnings": [
{
"code": "<string>",
"message": "<string>",
"alias": "<string>",
"canonical": "<string>"
}
]
},
"rendered": "<string>"
}Read a repository file
Reads one file by its exact repository-relative path, returning line-numbered content. This is the fallback reader: when a previous search already returned an artifact identifier for the file, prefer fetch_artifacts. Bound large files with start_line/end_line. When the path does not resolve, the response includes candidate paths with the same file name so the call can be repaired.
curl --request POST \
--url https://app.codealive.ai/api/tools/read_file \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"path": "<string>",
"data_source": "<string>",
"start_line": 123,
"end_line": 123
}
'import requests
url = "https://app.codealive.ai/api/tools/read_file"
payload = {
"path": "<string>",
"data_source": "<string>",
"start_line": 123,
"end_line": 123
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({path: '<string>', data_source: '<string>', start_line: 123, end_line: 123})
};
fetch('https://app.codealive.ai/api/tools/read_file', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.codealive.ai/api/tools/read_file",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'path' => '<string>',
'data_source' => '<string>',
'start_line' => 123,
'end_line' => 123
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://app.codealive.ai/api/tools/read_file"
payload := strings.NewReader("{\n \"path\": \"<string>\",\n \"data_source\": \"<string>\",\n \"start_line\": 123,\n \"end_line\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://app.codealive.ai/api/tools/read_file")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"path\": \"<string>\",\n \"data_source\": \"<string>\",\n \"start_line\": 123,\n \"end_line\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.codealive.ai/api/tools/read_file")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"path\": \"<string>\",\n \"data_source\": \"<string>\",\n \"start_line\": 123,\n \"end_line\": 123\n}"
response = http.request(request)
puts response.read_body{
"obj": {
"hint": "<string>",
"found": true,
"files": [
{
"identifier": "<string>",
"path": "<string>",
"dataSource": {
"type": "<string>",
"name": "<string>"
},
"fullName": "<string>",
"startLine": 123,
"endLine": 123,
"contentByteSize": 123,
"numberedContent": "<string>"
}
],
"candidates": [
{
"identifier": "<string>",
"path": "<string>",
"dataSource": {
"type": "<string>",
"name": "<string>"
},
"fullName": "<string>"
}
],
"sameNameCandidates": [
{
"identifier": "<string>",
"path": "<string>",
"dataSource": {
"type": "<string>",
"name": "<string>"
},
"fullName": "<string>"
}
],
"sameNameTotalCount": 123,
"error": {
"tool": "<string>",
"detail": "<string>",
"retry": "<string>",
"hint": "<string>"
},
"warnings": [
{
"code": "<string>",
"message": "<string>",
"alias": "<string>",
"canonical": "<string>"
}
]
},
"rendered": "<string>"
}Authorizations
API Key authentication using Bearer token. Example: "Authorization: Bearer {apiKey}"
Body
Repository-relative file path returned by get_file_tree, semantic_search, or grep_search.
Optional success projection. Omit to return both obj and rendered; use json for obj only; use agentic for rendered text only. Repairable errors always return both obj.error and rendered.
json, agentic One repository name or id returned by get_data_sources. Required when more than one repository is visible.
Optional 1-based start line.
Optional 1-based end line.
Response
Success envelope. obj has found, files[] with line-numbered content (numberedContent, startLine, endLine), same-name candidates when the path did not resolve, and a hint; rendered is the JSON-serialized form of obj. Repairable failures (missing or invalid arguments, ambiguous or unknown data sources) also return HTTP 200 with obj.error = { code, message, retry, try } and a rendered <tool_error> block; repair the arguments and retry.
Was this page helpful?