Python (SDK)
from latitudesh_python_sdk import Latitudesh
import os
with Latitudesh(
bearer=os.getenv("LATITUDESH_BEARER", ""),
) as latitudesh:
res = latitudesh.sandboxes_preview.exec_sandbox(sandbox_id="sbx-demo", data={
"attributes": {
"command": [
"python",
"-V",
],
},
})
# Handle response
print(res)curl --request POST \
--url https://api.latitude.sh/sandboxes/{sandbox_id}/exec \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"data": {
"attributes": {
"command": [
"python",
"-V"
]
}
}
}
'const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({data: {attributes: {command: ['python', '-V']}}})
};
fetch('https://api.latitude.sh/sandboxes/{sandbox_id}/exec', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.latitude.sh/sandboxes/{sandbox_id}/exec",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'data' => [
'attributes' => [
'command' => [
'python',
'-V'
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.latitude.sh/sandboxes/{sandbox_id}/exec"
payload := strings.NewReader("{\n \"data\": {\n \"attributes\": {\n \"command\": [\n \"python\",\n \"-V\"\n ]\n }\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.latitude.sh/sandboxes/{sandbox_id}/exec")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"data\": {\n \"attributes\": {\n \"command\": [\n \"python\",\n \"-V\"\n ]\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.latitude.sh/sandboxes/{sandbox_id}/exec")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"data\": {\n \"attributes\": {\n \"command\": [\n \"python\",\n \"-V\"\n ]\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "sbx-demo",
"type": "sandbox_execs",
"attributes": {
"stdout": "Python 3.12.0\n",
"stderr": "",
"exit_code": 0,
"truncated": false
}
}
}Sandboxes (Preview)
Run a command in a sandbox
Preview. Available to teams with the sandboxes_api feature flag. The shape of this
endpoint may change before general availability.
Run a command in a sandbox and wait for its output.
POST
/
sandboxes
/
{sandbox_id}
/
exec
Python (SDK)
from latitudesh_python_sdk import Latitudesh
import os
with Latitudesh(
bearer=os.getenv("LATITUDESH_BEARER", ""),
) as latitudesh:
res = latitudesh.sandboxes_preview.exec_sandbox(sandbox_id="sbx-demo", data={
"attributes": {
"command": [
"python",
"-V",
],
},
})
# Handle response
print(res)curl --request POST \
--url https://api.latitude.sh/sandboxes/{sandbox_id}/exec \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"data": {
"attributes": {
"command": [
"python",
"-V"
]
}
}
}
'const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({data: {attributes: {command: ['python', '-V']}}})
};
fetch('https://api.latitude.sh/sandboxes/{sandbox_id}/exec', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.latitude.sh/sandboxes/{sandbox_id}/exec",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'data' => [
'attributes' => [
'command' => [
'python',
'-V'
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.latitude.sh/sandboxes/{sandbox_id}/exec"
payload := strings.NewReader("{\n \"data\": {\n \"attributes\": {\n \"command\": [\n \"python\",\n \"-V\"\n ]\n }\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.latitude.sh/sandboxes/{sandbox_id}/exec")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"data\": {\n \"attributes\": {\n \"command\": [\n \"python\",\n \"-V\"\n ]\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.latitude.sh/sandboxes/{sandbox_id}/exec")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"data\": {\n \"attributes\": {\n \"command\": [\n \"python\",\n \"-V\"\n ]\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "sbx-demo",
"type": "sandbox_execs",
"attributes": {
"stdout": "Python 3.12.0\n",
"stderr": "",
"exit_code": 0,
"truncated": false
}
}
}Was this page helpful?