> ## Documentation Index
> Fetch the complete documentation index at: https://api-reference.scale.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Add Images

> [!NOTE]
>
> **[Click for Python SDK](https://docs.nucleus.scale.com/en/latest/api/nucleus/index.html#nucleus.Dataset.append)**
>
> ```
> Dataset.append(
>     items: List[DatasetItem],
>     update: bool = False
> ) -> AsyncJob
> ```

A `Dataset` can be populated with labeled and unlabeled data. Using Nucleus, you can filter down the data inside your dataset using custom metadata about your images.

For instance, your local dataset may contain `Sunny`, `Foggy`, and `Rainy` folders of images. All of these images can be uploaded into a single Nucleus `Dataset`, with added metadata like `{"weather": "Sunny"}`.

To update an item's metadata, you can re-ingest the same items with the `update` argument set to true. Existing metadata will be overwritten for `DatasetItems` in the payload that share a `reference_id` with a previously uploaded `DatasetItem`. To retrieve your existing `reference_id`s, see [Get Dataset Items](https://api-reference.scale.com/docs/nucleus/api-reference/list-dataset-items.md).

<details>
  <summary>**Remote vs. Local Data Upload**</summary>

  Remote uploads take in a list of `DatasetItems` whereas local uploads must occur item-by-item, one API call at a time.

  #### Uploading remotely hosted data

  1. Keep the `content-type` of the request as `application/json`.
  2. Specify the URL of the image location. Make sure Scale can access this URL.
  3. We currently support remote URLs with prefixes: `gs:`, `s3:`, `http:`, or `https:`.

  #### Uploading from local storage

  1. Change the `content-type` of the request to `multipart/form-data`.
  2. In the `image` field, provide a local path on disk to the image.
  3. In the `item` field, provide information about the image such as your self-defined `reference_id` and any associated metadata.

  ```
  curl "https://api.scale.com/v1/nucleus/dataset/ds_bw6de8s84pe0vbn6p5zg/append" \
    -u "YOUR_SCALE_API_KEY:" \
    -H "Content-Type:multipart/form-data" \
    -X POST \
    -F "item={
        \"reference_id\": \"image_ref_300000\",
        \"metadata\": {
          \"License Plate\": \"ZPH-J27\",
          \"Recording Date\": \"2019-09-15\",
          \"Recording Time\": \"14:24:21\",
          \"weather\": \"sunny\",
          \"camera\": \"back\"
        }
      };type=application/json" \
    -F "image=@{PATH_TO_IMAGE}"
  ```
</details>

The asynchronous endpoint returns an `AsyncJob` object that can sleep until complete, return current status, or return errors. There are two stages: first the metadata for the images is pulled into a reupload queue. Then the images are processed in batches of 3000. During this phase, the status will be updated every 3000 images.


## OpenAPI

````yaml openapi/nucleus.json POST /dataset/{dataset_id}/append
openapi: 3.1.0
info:
  title: Nucleus API
  version: '1.1'
servers:
  - url: https://api.scale.com/v1/nucleus
security:
  - sec0: []
paths:
  /dataset/{dataset_id}/append:
    post:
      summary: Add Images
      operationId: add-images
      parameters:
        - name: dataset_id
          in: path
          description: The Scale-generated ID of the Dataset.
          schema:
            type: string
          required: true
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required:
                - items
              properties:
                items:
                  type: array
                  description: The list of image `DatasetItems` to upload.
                  items:
                    properties:
                      image_url:
                        type: string
                        description: The Scale-accessible remote URL containing the image.
                      reference_id:
                        type: string
                        description: User-specified identifier to reference the image.
                      metadata:
                        type: object
                        description: >-
                          Optional metadata to include with the item. Camera
                          parameters should be built into a object and passed in
                          as metadata with the key `"camera_params"`.
                    required:
                      - image_url
                      - reference_id
                    type: object
                update:
                  type: boolean
                  description: >-
                    Whether to overwrite existing `DatasetItems` with
                    conflicting `reference_ids`. The default behavior (`False`)
                    is to ignore conflicting uploads. This is the main way we
                    recommend to update or add to metadata: simply rerun your
                    ingestion with `update=True`.
                  default: false
      responses:
        '200':
          description: '200'
          content:
            application/json:
              examples:
                Result:
                  value:
                    dataset_id: ds_c6ka7tfaypgg05rf2ts0
                    new_items: 1
                    updated_items: 0
                    ignored_items: 0
                    rows:
                      - data_id: di_c6m14zv4gt3g060pwsz0
                        metadata:
                          foo: bar
                (local):
                  value:
                    dataset_id: ds_bw6de8s84pe0vbn6p5zg
                    new_items: 1
                    updated_items: 0
                    ignored_items: 0
                    upload_errors: 0
                    error_payload: []
              schema:
                oneOf:
                  - type: object
                    properties:
                      dataset_id:
                        type: string
                        example: ds_c6ka7tfaypgg05rf2ts0
                      new_items:
                        type: integer
                        example: 1
                        default: 0
                      updated_items:
                        type: integer
                        example: 0
                        default: 0
                      ignored_items:
                        type: integer
                        example: 0
                        default: 0
                      rows:
                        type: array
                        items:
                          type: object
                          properties:
                            data_id:
                              type: string
                              example: di_c6m14zv4gt3g060pwsz0
                            metadata:
                              type: object
                              properties:
                                foo:
                                  type: string
                                  example: bar
                  - title: (local)
                    type: object
                    properties:
                      dataset_id:
                        type: string
                        example: ds_bw6de8s84pe0vbn6p5zg
                      new_items:
                        type: integer
                        example: 1
                        default: 0
                      updated_items:
                        type: integer
                        example: 0
                        default: 0
                      ignored_items:
                        type: integer
                        example: 0
                        default: 0
                      upload_errors:
                        type: integer
                        example: 0
                        default: 0
                      error_payload:
                        type: array
                        items:
                          type: object
                          properties: {}
        '400':
          description: '400'
          content:
            application/json:
              examples:
                Result:
                  value: {}
              schema:
                type: object
                properties: {}
      deprecated: false
components:
  securitySchemes:
    sec0:
      type: http
      scheme: basic

````