Export Slice
curl --request POST \
--url https://api.scale.com/v1/nucleus/slice/{slice_id}/exportForTrainingPage \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"pageToken": "<string>",
"pageSize": 10000
}
'import requests
url = "https://api.scale.com/v1/nucleus/slice/{slice_id}/exportForTrainingPage"
payload = {
"pageToken": "<string>",
"pageSize": 10000
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({pageToken: '<string>', pageSize: 10000})
};
fetch('https://api.scale.com/v1/nucleus/slice/{slice_id}/exportForTrainingPage', 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.scale.com/v1/nucleus/slice/{slice_id}/exportForTrainingPage",
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([
'pageToken' => '<string>',
'pageSize' => 10000
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"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.scale.com/v1/nucleus/slice/{slice_id}/exportForTrainingPage"
payload := strings.NewReader("{\n \"pageToken\": \"<string>\",\n \"pageSize\": 10000\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
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.scale.com/v1/nucleus/slice/{slice_id}/exportForTrainingPage")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"pageToken\": \"<string>\",\n \"pageSize\": 10000\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.scale.com/v1/nucleus/slice/{slice_id}/exportForTrainingPage")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"pageToken\": \"<string>\",\n \"pageSize\": 10000\n}"
response = http.request(request)
puts response.read_body{
"data": [
{
"item": {
"dataset_item_id": "di_zwyt15cag2301b902cw0",
"reference_id": "image_ref_300000",
"original_image_url": "https://your-bucket/example.png",
"metadata": {}
},
"annotations": {
"box": [
{
"label": "car",
"type": "box",
"geometry": {
"x": 648.2,
"y": 264.3,
"width": 70.6,
"height": 50.6
}
}
]
}
}
],
"nextPageToken": "di_zwyt15cag2301b902cw0"
}Export Slice
Export Slice
POST
/
slice
/
{slice_id}
/
exportForTrainingPage
Export Slice
curl --request POST \
--url https://api.scale.com/v1/nucleus/slice/{slice_id}/exportForTrainingPage \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"pageToken": "<string>",
"pageSize": 10000
}
'import requests
url = "https://api.scale.com/v1/nucleus/slice/{slice_id}/exportForTrainingPage"
payload = {
"pageToken": "<string>",
"pageSize": 10000
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({pageToken: '<string>', pageSize: 10000})
};
fetch('https://api.scale.com/v1/nucleus/slice/{slice_id}/exportForTrainingPage', 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.scale.com/v1/nucleus/slice/{slice_id}/exportForTrainingPage",
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([
'pageToken' => '<string>',
'pageSize' => 10000
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"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.scale.com/v1/nucleus/slice/{slice_id}/exportForTrainingPage"
payload := strings.NewReader("{\n \"pageToken\": \"<string>\",\n \"pageSize\": 10000\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
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.scale.com/v1/nucleus/slice/{slice_id}/exportForTrainingPage")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"pageToken\": \"<string>\",\n \"pageSize\": 10000\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.scale.com/v1/nucleus/slice/{slice_id}/exportForTrainingPage")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"pageToken\": \"<string>\",\n \"pageSize\": 10000\n}"
response = http.request(request)
puts response.read_body{
"data": [
{
"item": {
"dataset_item_id": "di_zwyt15cag2301b902cw0",
"reference_id": "image_ref_300000",
"original_image_url": "https://your-bucket/example.png",
"metadata": {}
},
"annotations": {
"box": [
{
"label": "car",
"type": "box",
"geometry": {
"x": 648.2,
"y": 264.3,
"width": 70.6,
"height": 50.6
}
}
]
}
}
],
"nextPageToken": "di_zwyt15cag2301b902cw0"
}Click for Python SDK
Slice.items_and_annotation_generator(
use_mirrored_images: bool = False
) -> Iterable[
Dict[str, Union[
DatasetItem,
Dict[str, List[Annotation]]]
]
]
- Annotation IDs
- Annotation-level metadata
- Reference IDs for annotations (since they are pulled down for the DatasetItem already)
Pagination
Each response has two fields:data: the items of this page, each with its annotations grouped by type.nextPageToken: pass it aspageTokenin the next request. When it is empty or missing, you have received the last page.
pageToken. pageSize is at most 10000 items; lower it if a request times out.Authorizations
Body
application/json