Read File
curl --request GET \
--url https://api.example.com/browser/sessions/{id}/fs/fileimport requests
url = "https://api.example.com/browser/sessions/{id}/fs/file"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.example.com/browser/sessions/{id}/fs/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://api.example.com/browser/sessions/{id}/fs/file",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/browser/sessions/{id}/fs/file"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.example.com/browser/sessions/{id}/fs/file")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/browser/sessions/{id}/fs/file")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"path": "<string>",
"content": "<string>",
"bytes": 123,
"truncated": true
}Filesystem
Read File
Read a file from the session workspace. Path is relative to the workspace root.
GET
/
browser
/
sessions
/
{id}
/
fs
/
file
Read File
curl --request GET \
--url https://api.example.com/browser/sessions/{id}/fs/fileimport requests
url = "https://api.example.com/browser/sessions/{id}/fs/file"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.example.com/browser/sessions/{id}/fs/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://api.example.com/browser/sessions/{id}/fs/file",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/browser/sessions/{id}/fs/file"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.example.com/browser/sessions/{id}/fs/file")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/browser/sessions/{id}/fs/file")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"path": "<string>",
"content": "<string>",
"bytes": 123,
"truncated": true
}Overview
Returns the base64-encoded content of a file in the session’s workspace. The workspace is a per-session scratch directory inside the sandbox; paths must be relative (no leading/, no .., no NUL byte, up to 4096 bytes). Large files are truncated at the sandbox-enforced read limit — check truncated in the response.
Path Parameters
string
required
Browser session ID (UUID).
Query Parameters
string
required
Workspace-relative file path, e.g.
notes/todo.txt.Example Request
curl -G "https://api.scrapengine.io/api/v1/browser/sessions/baa3f390-fa6e-4a24-b84a-a575a5f3a9c7/fs/file" \
-H "Authorization: Bearer $SCRAPENGINE_API_KEY" \
--data-urlencode "path=notes/todo.txt"
import os, requests
response = requests.get(
"https://api.scrapengine.io/api/v1/browser/sessions/baa3f390-fa6e-4a24-b84a-a575a5f3a9c7/fs/file",
headers={"Authorization": f"Bearer {os.environ['SCRAPENGINE_API_KEY']}"},
params={"path": "notes/todo.txt"},
)
data = response.json()
Response
Success Response (200)
string
The requested workspace-relative path.
string
Base64-encoded file content.
integer
Decoded byte length of the file.
boolean
True when the content was truncated to the maximum read size.
{
"path": "notes/todo.txt",
"content": "SGVsbG8gV29ybGQ=",
"bytes": 11,
"truncated": false
}
Error Responses
| Status | Description |
|---|---|
400 | Invalid path — leading /, contains .., NUL byte, or exceeds 4096 bytes. |
401 | Unauthorized — invalid or missing API key. |
404 | Session or file not found. |
413 | File exceeds the maximum read size. |
Was this page helpful?