Add items to an existing dataset
Add one or more items in a single batch to a dataset that already exists.
Use this to append items to an existing dataset; to create a dataset together with its initial items in one call, use POST /v5/datasets instead (this endpoint does not create datasets). Items are only ever added in a batch — there is no single-item create endpoint. The target dataset is identified by the required dataset_id in the request body, and each entry in data (at least one is required) becomes one item, optionally paired with the files entry at the same list index — when files is supplied it must be the same length as data. Each referenced file must exist and be a supported media format, and item keys may not collide with reserved dataset- or evaluation-item field names. The target dataset must not be archived. The batch is applied as a new dataset version snapshot rather than mutating existing versions, and the created items are returned.
Add items to an existing dataset
import os
from scale_gp_beta import SGPClient
client = SGPClient(
api_key=os.environ.get("SGP_API_KEY"), # This is the default and can be omitted
)
response = client.dataset_items.batch_create(
data=[{
"foo": "bar"
}],
dataset_id="dataset_id",
)
print(response.items){
"items": [
{
"id": "id",
"content_hash": "content_hash",
"created_at": "2019-12-27T18:11:19.117Z",
"created_by": {
"id": "id",
"type": "user",
"object": "identity"
},
"data": {
"foo": "bar"
},
"updated_at": "2019-12-27T18:11:19.117Z",
"archived_at": "2019-12-27T18:11:19.117Z",
"dataset_id": "dataset_id",
"files": {
"foo": "string"
},
"object": "dataset.item"
}
],
"object": "list"
}Returns Examples
{
"items": [
{
"id": "id",
"content_hash": "content_hash",
"created_at": "2019-12-27T18:11:19.117Z",
"created_by": {
"id": "id",
"type": "user",
"object": "identity"
},
"data": {
"foo": "bar"
},
"updated_at": "2019-12-27T18:11:19.117Z",
"archived_at": "2019-12-27T18:11:19.117Z",
"dataset_id": "dataset_id",
"files": {
"foo": "string"
},
"object": "dataset.item"
}
],
"object": "list"
}