Skip to main content
POST
/
v1
/
sandboxes
/
{id}
/
code
/
execute
Execute code in a Jupyter kernel
import requests

url = "https://api.13-215-85-171.sslip.io/v1/sandboxes/{id}/code/execute"

payload = { "code": "<string>" }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
{
  "text": "<string>",
  "html": "<string>",
  "png": "<string>",
  "name": "<string>",
  "value": "<string>",
  "traceback": "<string>",
  "timestamp": 123,
  "is_main_result": true,
  "execution_count": 123,
  "artifact": {
    "id": "<string>",
    "context_id": "<string>",
    "mime_type": "<string>",
    "name": "<string>",
    "size_bytes": 123,
    "sha256": "<string>",
    "created_at": "2023-11-07T05:31:56Z",
    "execution_count": 123,
    "expires_at": "2023-11-07T05:31:56Z",
    "preview_url": "<string>",
    "download_url": "<string>",
    "metadata": {}
  }
}

Authorizations

Authorization
string
header
required

API key passed as Bearer token

Path Parameters

id
string
required

Sandbox ID (e.g. sb_a1b2c3d4)

Body

application/json
code
string
required

Source code to execute

language
string

Kernel language used when context_id is omitted. The server selects or creates the default context for this language.

context_id
string

Kernel context to use. When present, this takes precedence over language.

envs
object

Environment variables for this execution

timeout
integer

Execution timeout in seconds

Response

SSE stream of execution output events

A single SSE event from code execution

type
enum<string>
Available options:
stdout,
stderr,
result,
artifact,
error,
number_of_executions
text
string
html
string
png
string
name
string
value
string
traceback
string
timestamp
integer<int64>
is_main_result
boolean
execution_count
integer
artifact
object