Documentation Index Fetch the complete documentation index at: https://e2b.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Reading files
You can read files from a volume using the readFile() / read_file() method.
JavaScript & TypeScript
Python
import { Volume } from 'e2b'
const volume = await Volume. create ( 'my-volume' )
const content = await volume. readFile ( '/path/to/file' )
console. log (content)
Writing files
You can write files to a volume using the writeFile() / write_file() method.
JavaScript & TypeScript
Python
import { Volume } from 'e2b'
const volume = await Volume. create ( 'my-volume' )
await volume. writeFile ( '/path/to/file' , 'file content' )
Creating directories
You can create directories in a volume using the makeDir() / make_dir() method.
JavaScript & TypeScript
Python
import { Volume } from 'e2b'
const volume = await Volume. create ( 'my-volume' )
await volume. makeDir ( '/path/to/dir' )
// Create nested directories with force option
await volume. makeDir ( '/path/to/nested/dir' , { force: true })
Listing directory contents
You can list the contents of a directory in a volume using the list() method.
JavaScript & TypeScript
Python
import { Volume } from 'e2b'
const volume = await Volume. create ( 'my-volume' )
const entries = await volume. list ( '/path/to/dir' )
console. log (entries)
// [
// { name: 'file.txt', type: 'file', path: '/path/to/dir/file.txt', size: 13, ... },
// { name: 'subdir', type: 'directory', path: '/path/to/dir/subdir', size: 0, ... },
// ]
Removing files or directories
You can remove files or directories from a volume using the remove() method.
JavaScript & TypeScript
Python
import { Volume } from 'e2b'
const volume = await Volume. create ( 'my-volume' )
// Remove a file
await volume. remove ( '/path/to/file' )
// Remove a directory recursively
await volume. remove ( '/path/to/dir' , { recursive: true })