BetterE2B - Drop-in replacement for e2b-code-interpreter with dynamic subdomain support
Project description
๐ฏ BetterE2B SDK
Drop-in replacement for @e2b/code-interpreter with dynamic subdomain support!
๐ Features
- โ 100% E2B Compatible - Same API as official E2B
- โ
Dynamic Subdomains -
https://{port}-{id}.yourdomain.com - โ
Path-based Routing -
yourdomain.com/{port}-{id}/ - โ
JavaScript/TypeScript SDK -
bettere2b - โ
Python SDK -
bettere2b - โ Auto-managed Lifecycle - Context managers and cleanup
- โ No API Key Required - Works out of the box
๐ฆ Installation
JavaScript/TypeScript
npm install bettere2b
Python
pip install bettere2b
๐ฏ Quick Start
JavaScript/TypeScript
import { Sandbox } from 'bettere2b'
const sandbox = await Sandbox.create()
await sandbox.runCode('x = 1')
const execution = await sandbox.runCode('x+=1; x')
console.log(execution.text) // outputs 2
// Get dynamic subdomain URL
console.log(sandbox.getSubdomainUrl()) // https://8083-uuid.yourdomain.com
await sandbox.kill()
Python
from bettere2b import Sandbox
with Sandbox.create() as sandbox:
sandbox.run_code("x = 1")
execution = sandbox.run_code("x+=1; x")
print(execution.text) # outputs 2
# Get dynamic subdomain URL
print(sandbox.get_subdomain_url()) # https://8083-uuid.yourdomain.com
๐ Migration from Official E2B
Replace this:
import { Sandbox } from '@e2b/code-interpreter'
With this:
import { Sandbox } from 'bettere2b'
That's it! Your existing code will work without any changes.
๐ Dynamic Subdomain Features
Get Subdomain URL
const sandbox = await Sandbox.create()
const subdomainUrl = sandbox.getSubdomainUrl()
// Returns: https://8083-uuid.yourdomain.com
Get Path-based URL
const pathUrl = sandbox.getPathUrl()
// Returns: https://yourdomain.com/8083-uuid/
Get Subdomain Configuration
const config = await sandbox.getSubdomainConfig()
console.log(config.urls.subdomain) // Full subdomain URL
console.log(config.urls.path) // Path-based URL
๐ API Reference
Sandbox Methods
| Method | Description | E2B Compatible |
|---|---|---|
Sandbox.create(options) |
Create new sandbox | โ |
sandbox.runCode(code, language) |
Execute code | โ |
sandbox.kill() |
Terminate sandbox | โ |
sandbox.getHost(port) |
Get host URL | โ |
sandbox.install(packages, manager) |
Install packages | โ |
sandbox.writeFile(path, content) |
Write file | โ |
sandbox.readFile(path) |
Read file | โ |
sandbox.listFiles(directory) |
List files | โ |
sandbox.setTimeout(ms) |
Set timeout | โ |
sandbox.extendTimeout(ms) |
Extend timeout | โ |
sandbox.getSubdomainUrl() |
Get subdomain URL | ๐ |
sandbox.getPathUrl() |
Get path URL | ๐ |
sandbox.getSubdomainConfig() |
Get subdomain config | ๐ |
ExecutionResult
const result = await sandbox.runCode('print("Hello")')
console.log(result.text) // Output text
console.log(result.logs.stdout) // stdout logs
console.log(result.logs.stderr) // stderr logs
console.log(result.error) // Error message
console.log(result.exitCode) // Exit code
console.log(result.executionTime) // Execution time
๐ง Configuration
Server URL
const sandbox = await Sandbox.create({
serverUrl: 'http://localhost:8083' // Your E2B clone server
})
API Key (Optional)
const sandbox = await Sandbox.create({
apiKey: 'your-api-key' // If your server requires authentication
})
Runtime Options
const sandbox = await Sandbox.create({
name: 'My Sandbox',
runtime: 'react', // static, react, python, nextjs, etc.
description: 'My custom sandbox',
timeout: 60 * 60 * 1000 // 1 hour timeout
})
๐งช Testing
JavaScript
cd server/sdk/javascript
npm test
Python
cd server/sdk/python
python test.py
๐ Comparison with Official E2B
| Feature | Official E2B | Your E2B Clone |
|---|---|---|
| Sandbox Creation | โ | โ |
| Code Execution | โ | โ |
| File Operations | โ | โ |
| Package Installation | โ | โ |
| Timeout Management | โ | โ |
| Dynamic Subdomains | โ | โ |
| Path-based Routing | โ | โ |
| Self-hosted | โ | โ |
| No API Key Required | โ | โ |
| Free to Use | โ | โ |
๐ Advanced Features
Context Manager (Python)
with Sandbox.create() as sandbox:
result = sandbox.run_code('print("Hello")')
# Sandbox automatically killed when exiting context
Quick Create Function
from your_e2b_clone import create_sandbox
sandbox = create_sandbox(name='Quick Test')
Multiple Language Support
// Python
await sandbox.runCode('print("Hello")', 'python')
// JavaScript
await sandbox.runCode('console.log("Hello")', 'javascript')
// Bash
await sandbox.runCode('echo "Hello"', 'bash')
๐ Links
- Server Repository: Your E2B Clone Server
- Documentation: API Docs
- Issues: GitHub Issues
๐ License
MIT License - see LICENSE file for details.
๐ค Contributing
Contributions are welcome! Please see CONTRIBUTING.md for details.
Made with โค๏ธ - Your E2B Clone SDK
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bettere2b-1.0.0.tar.gz.
File metadata
- Download URL: bettere2b-1.0.0.tar.gz
- Upload date:
- Size: 11.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.12.1.2 readme-renderer/44.0 requests/2.31.0 requests-toolbelt/1.0.0 urllib3/2.2.3 tqdm/4.67.1 importlib-metadata/8.7.0 keyring/25.6.0 rfc3986/1.5.0 colorama/0.4.6 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2f84df3cb41998f82e88589b29615ea3d1654b627b9b7da588065c42cbe1d17f
|
|
| MD5 |
f7dab352c23bd23e8e89664b6ab52d1c
|
|
| BLAKE2b-256 |
d02cfef34d2a79a76d3c87691b502ec5ac302cf3c5f73605729924308ef3678e
|
File details
Details for the file bettere2b-1.0.0-py3-none-any.whl.
File metadata
- Download URL: bettere2b-1.0.0-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.12.1.2 readme-renderer/44.0 requests/2.31.0 requests-toolbelt/1.0.0 urllib3/2.2.3 tqdm/4.67.1 importlib-metadata/8.7.0 keyring/25.6.0 rfc3986/1.5.0 colorama/0.4.6 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a46f07c7ed28e7238df0ed4d8fa4f5c181a8e80c5b0094be62af7f0211c2ad4
|
|
| MD5 |
79ed185e0e6c68cd612eee1eaac380d0
|
|
| BLAKE2b-256 |
c45122d0e2d25f6b4bb2033cf73293958fb56f0f8fd7571a2f766efb99ca5dd2
|