Execute code in a Jupyter kernel
import requests
url = "https://api.13-215-85-171.sslip.io/v1/machines/{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)curl --request POST \
--url https://api.13-215-85-171.sslip.io/v1/machines/{id}/code/execute \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"code": "<string>"
}
'{
"type": "stdout",
"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>",
"kind": "image",
"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": {}
}
}{
"error": "<string>",
"code": "invalid_request",
"error_detail": {
"code": "unauthorized",
"message": "<string>",
"phase": "auth",
"retryable": true,
"suggested_action": "<string>",
"step_index": 123,
"attempt": 123,
"max_attempts": 123,
"cache_subject": "<string>",
"build_id": "<string>",
"request_id": "<string>",
"details": {}
},
"request_id": "<string>",
"build_id": "<string>"
}Code
Execute code in a Jupyter kernel
Sends code to the in-container Jupyter server for execution.
Returns results as an SSE stream of line-delimited JSON events.
If both context_id and language are provided, context_id takes precedence.
POST
/
v1
/
machines
/
{id}
/
code
/
execute
Execute code in a Jupyter kernel
import requests
url = "https://api.13-215-85-171.sslip.io/v1/machines/{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)curl --request POST \
--url https://api.13-215-85-171.sslip.io/v1/machines/{id}/code/execute \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"code": "<string>"
}
'{
"type": "stdout",
"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>",
"kind": "image",
"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": {}
}
}{
"error": "<string>",
"code": "invalid_request",
"error_detail": {
"code": "unauthorized",
"message": "<string>",
"phase": "auth",
"retryable": true,
"suggested_action": "<string>",
"step_index": 123,
"attempt": 123,
"max_attempts": 123,
"cache_subject": "<string>",
"build_id": "<string>",
"request_id": "<string>",
"details": {}
},
"request_id": "<string>",
"build_id": "<string>"
}Authorizations
API key passed as Bearer token
Path Parameters
Machine ID (e.g. mch_a1b2c3d4)
Body
application/json
Source code to execute
Kernel language used when context_id is omitted.
The server selects or creates the default context for this language.
Kernel context to use.
When present, this takes precedence over language.
Environment variables for this execution
Show child attributes
Show child attributes
Execution timeout in seconds
Response
SSE stream of execution output events
A single SSE event from code execution