Skip to content

Commit 6e16ad7

Browse files
authored
Update README.md
1 parent d61d41b commit 6e16ad7

File tree

1 file changed

+26
-103
lines changed

1 file changed

+26
-103
lines changed

js/README.md

Lines changed: 26 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,127 +1,50 @@
11
<p align="center">
2-
<img width="100" src="/readme-assets/logo-circle.png" alt="e2b logo">
2+
<img width="100" src="https://raw.githubusercontent.com/e2b-dev/E2B/refs/heads/main/readme-assets/logo-circle.png" alt="e2b logo">
33
</p>
44

5-
6-
<h1 align="center">
7-
Code interpreter extension for JavaScript
8-
</h1>
9-
10-
<h4 align="center">
11-
<a href="https://pypi.org/project/e2b/">
12-
<img alt="Last 1 month downloads for the Python SDK" loading="lazy" width="200" height="20" decoding="async" data-nimg="1"
13-
style="color:transparent;width:auto;height:100%" src="https://img.shields.io/pypi/dm/e2b?label=PyPI%20Downloads">
14-
</a>
5+
<h4 align="center">
156
<a href="https://www.npmjs.com/package/e2b">
16-
<img alt="Last 1 month downloads for the Python SDK" loading="lazy" width="200" height="20" decoding="async" data-nimg="1"
7+
<img alt="Last 1 month downloads for the JavaScript SDK" loading="lazy" width="200" height="20" decoding="async" data-nimg="1"
178
style="color:transparent;width:auto;height:100%" src="https://img.shields.io/npm/dm/e2b?label=NPM%20Downloads">
189
</a>
1910
</h4>
2011

12+
<!---
13+
<img width="100%" src="/readme-assets/preview.png" alt="Cover image">
14+
--->
15+
## What is E2B?
16+
[E2B](https://www.e2b.dev/) is an open-source infrastructure that allows you run to AI-generated code in secure isolated sandboxes in the cloud. To start and control sandboxes, use our [JavaScript SDK](https://www.npmjs.com/package/@e2b/code-interpreter) or [Python SDK](https://pypi.org/project/e2b_code_interpreter).
2117

22-
The repository contains a template and modules for the code interpreter sandbox. It is based on the Jupyter server and implements the Jupyter Kernel messaging protocol. This allows for sharing context between code executions and improves support for plotting charts and other display-able data.
23-
24-
## Key Features
25-
26-
- **Stateful Execution**: Unlike traditional sandboxes that treat each code execution independently, this package maintains context across executions.
27-
- **Displaying Charts & Data**: Implements parts of the [Jupyter Kernel messaging protocol](https://jupyter-client.readthedocs.io/en/latest/messaging.html), which support for interactive features like plotting charts, rendering DataFrames, etc.
18+
## Run your first Sandbox
2819

29-
## Installation
20+
### 1. Install SDK
3021

31-
```sh
32-
npm install @e2b/code-interpreter
3322
```
34-
35-
## Examples
36-
37-
### Minimal example with the sharing context
38-
39-
```js
40-
import { Sandbox } from '@e2b/code-interpreter'
41-
42-
const sandbox = await Sandbox.create()
43-
await sbx.runCode()('x = 1')
44-
45-
const execution = await sbx.runCode()('x+=1; x')
46-
console.log(execution.text) // outputs 2
47-
48-
await sandbox.close()
23+
npm i @e2b/code-interpreter
4924
```
5025

51-
### Get charts and any display-able data
52-
53-
```js
54-
import { Sandbox } from '@e2b/code-interpreter'
55-
56-
const sandbox = await Sandbox.create()
57-
58-
const code = `
59-
import matplotlib.pyplot as plt
60-
import numpy as np
61-
62-
x = np.linspace(0, 20, 100)
63-
y = np.sin(x)
64-
65-
plt.plot(x, y)
66-
plt.show()
67-
`
68-
69-
// you can install dependencies in "jupyter notebook style"
70-
await sandbox.runCode('!pip install matplotlib')
71-
72-
const execution = await sandbox.runCode(code)
73-
74-
// this contains the image data, you can e.g. save it to file or send to frontend
75-
execution.results[0].png
76-
77-
await sandbox.kill()
26+
### 2. Get your E2B API key
27+
1. Sign up to E2B [here](https://e2b.dev).
28+
2. Get your API key [here](https://e2b.dev/dashboard?tab=keys).
29+
3. Set environment variable with your API key.
7830
```
31+
E2B_API_KEY=e2b_***
32+
```
7933

80-
### Streaming code output
34+
### 3. Execute code with code interpreter inside Sandbox
8135

82-
```js
36+
```ts
8337
import { Sandbox } from '@e2b/code-interpreter'
8438

85-
const code = `
86-
import time
87-
import pandas as pd
88-
89-
print("hello")
90-
time.sleep(3)
91-
data = pd.DataFrame(data=[[1, 2], [3, 4]], columns=["A", "B"])
92-
display(data.head(10))
93-
time.sleep(3)
94-
print("world")
95-
`
96-
9739
const sandbox = await Sandbox.create()
40+
await sbx.runCode('x = 1')
9841

99-
await sandbox.runCode(code, {
100-
onStdout: (out) => console.log(out),
101-
onStderr: (outErr) => console.error(outErr),
102-
onResult: (result) => console.log(result.text),
103-
})
104-
105-
await sandbox.kill()
42+
const execution = await sbx.runCode('x+=1; x')
43+
console.log(execution.text) // outputs 2
10644
```
10745

108-
### More resources
109-
- Check out the [JavaScript/TypeScript](https://e2b.dev/docs/hello-world/js) and [Python](https://e2b.dev/docs/hello-world/py) "Hello World" guides to learn how to use our SDK.
110-
111-
- See [E2B documentation](https://e2b.dev/docs) to get started.
112-
113-
- Visit our [Cookbook](https://github.com/e2b-dev/e2b-cookbook/tree/main) to get inspired by examples with different LLMs and AI frameworks.
114-
115-
116-
___
46+
### 4. Check docs
47+
Visit [E2B documentation](https://e2b.dev/docs).
11748

118-
<div align='center'>
119-
<!-- <a href="https://e2b.dev/docs" target="_blank">
120-
<img src="https://img.shields.io/badge/docs-%2300acee.svg?color=143D52&style=for-the-badge&logo=x&logoColor=white" alt=docs style="margin-bottom: 5px;"/></a> -->
121-
<a href="https://twitter.com/e2b_dev" target="_blank">
122-
<img src="https://img.shields.io/badge/x (twitter)-%2300acee.svg?color=000000&style=for-the-badge&logo=x&logoColor=white" alt=linkedin style="margin-bottom: 5px;"/></a>
123-
<a href="https://discord.com/invite/U7KEcGErtQ" target="_blank">
124-
<img src="https://img.shields.io/badge/discord -%2300acee.svg?color=143D52&style=for-the-badge&logo=discord&logoColor=white" alt=discord style="margin-bottom: 5px;"/></a>
125-
<a href="https://www.linkedin.com/company/e2b-dev/" target="_blank">
126-
<img src="https://img.shields.io/badge/linkedin-%2300acee.svg?color=000000&style=for-the-badge&logo=linkedin&logoColor=white" alt=linkedin style="margin-bottom: 5px;"/></a>
127-
</div align='center'>
49+
### 5. E2B cookbook
50+
Visit our [Cookbook](https://github.com/e2b-dev/e2b-cookbook/tree/main) to get inspired by examples with different LLMs and AI frameworks.

0 commit comments

Comments
 (0)