GET
/
boxes
/
{boxId}
/
fs
/
read
JavaScript
import GboxSDK from "gbox-sdk";

const gboxSDK = new GboxSDK({
  apiKey: process.env["GBOX_API_KEY"] // This is the default and can be omitted
});

async function main() {
  const box = await gboxSDK.create({ type: "linux" });

  // Read a file
  const readResult = await box.fs.read({
    path: "/home/user/example.txt"
  });

  console.log(`File content:\n${readResult.content}`);

  // Read and parse a JSON file
  const configResult = await box.fs.read({
    path: "/home/user/config.json"
  });

  const parsedConfig = JSON.parse(configResult.content);
  console.log("Parsed configuration:", parsedConfig);
}

main();
{
  "content": "{\n  \"name\": \"My Project\",\n  \"version\": \"1.0.0\"\n}"
}

Authorizations

Authorization
string
header
required

Enter your API Key in the format: Bearer <token>. Get it from https://gbox.ai

Path Parameters

boxId
string
required

Box ID

Example:

"c9bdc193-b54b-4ddb-a035-5ac0c598d32d"

Query Parameters

workingDir
string

Working directory. If not provided, the file will be read from the box.config.workingDir directory.

Example:

"/home/user/documents"

path
string
required

Target path in the box. If the path does not start with '/', the file will be read from the working directory.

Example:

"/home/user/documents/config.json"

Response

200
application/json

Read file

Response containing file content