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

# Cloud Imports (GCS / S3 / Cloudflare R2 / Hugging Face Buckets)

> Import videos directly from cloud storage

#### upload() for cloud URIs

Provide full `gs://`, `s3://`, or `hf://buckets/...` URIs to import videos from cloud storage.

```python title="Cloud import examples" theme={null}
# Import from GCS
batch = client.upload([
  "gs://drive-monitor/uploads/trip-042/front.mp4",
  "gs://drive-monitor/uploads/trip-042/rear.mp4",
])
# Returns: {"import_job_id": "ij_xxx", "status": "importing"}

# Import from S3 with a specific integration
client.upload(
    "s3://drive-monitor-archive/2024-09-01/front.mp4",
    integration_id="aws-prod",
)

# Import from Cloudflare R2 after saving it as an S3-compatible integration
client.upload(
    "s3://customer-r2/incoming/front.mp4",
    integration_id="r2-prod",
)

# Import into a folder
client.upload(
    ["s3://my-bucket/videos/clip_001.mp4", "s3://my-bucket/videos/clip_002.mp4"],
    folder="fleet_uploads",
    scope="org",
)

# Import from a Hugging Face bucket
client.upload(
    "hf://buckets/JohnnyMnenonic/test/incoming/front.mp4",
    integration_id="hf-bucket-prod",
)
```

**Cloud-specific parameter:**

| Parameter | Type | Default | Description |
| - | - | - | - |
| `integration_id` | `str` | `None` | Saved cloud integration identifier to use for imports. When omitted, the backend resolves access from the bucket when the provider supports it. |

All other parameters (`folder`, `scope`, etc.) are shared with local uploads — see the [full parameter table](https://docs.nomadicml.com/sdk/uploading-videos/local-files-urls.md).

**Returns:** `{"import_job_id": "ij_xxx", "status": "importing"}`

> [!NOTE]
>
> Ordinary video imports accept `.mp4` objects referenced by full `gs://bucket/object.mp4`, `s3://bucket/object.mp4`, or `hf://buckets/namespace/name/object.mp4` URIs. Wildcard patterns are not supported—list each object explicitly. Zendar recording directories use the separate `source_format` option below. For Hugging Face buckets, when no `integration_id` is provided the backend first checks for a saved `hf_bucket` integration matching the bucket and otherwise falls back to public bucket access automatically.

> [!NOTE]
>
> For S3-compatible providers such as Cloudflare R2, keep using `s3://bucket/object.mp4` URIs. The provider-specific endpoint belongs on the saved cloud integration, not in the import URI itself.

> [!NOTE]
>
> Cloud import requests are acknowledged asynchronously. Even when a request later fails validation or authorization in background processing, the API still returns an `import_job_id`; those failures surface as `UPLOADING_FAILED` rows in `get_import_job_videos()`.

#### Zendar recording directories (upcoming SDK release)

> [!NOTE]
>
> This feature requires the upcoming SDK release and account enablement by Nomadic.
> Nomadic copies each recording directory into its own storage, converts it with the
> existing Zendar converter, then ingests the resulting MCAP and sensor assets.

**1. Grant read access once.** Obtain Nomadic's Google service account identity:

```python theme={null}
setup = client.cloud_integrations.get_gcs_storage_transfer_setup()
print(setup["google_service_account_email"])
```

Grant that identity read access on each bucket you import from, and repeat the grant
for any new bucket. No service account key, `integration_id`, or bucket registration
with Nomadic is required. The account is dedicated to your organization, so your
grants decide which buckets your uploads can read. Source buckets must be regional
`us-central1`.

```bash theme={null}
RECORDING_BUCKET="zendar-batch-bucket-us"
NOMADIC_TRANSFER_ACCOUNT="<google_service_account_email returned above>"
for role in roles/storage.objectViewer roles/storage.legacyBucketReader; do
  gcloud storage buckets add-iam-policy-binding "gs://$RECORDING_BUCKET" \
    --member="serviceAccount:$NOMADIC_TRANSFER_ACCOUNT" \
    --role="$role" --condition=None
done
```

**2. Upload one directory or a list.** Each path is the parent directory of one
finalized recording, containing its Parquet files, calibration, and optional camera
MP4 plus frame timestamps. Keep those files unchanged until copying finishes.

```python theme={null}
job = client.upload(
    "gs://zendar-batch-bucket-us/segments/segment-0042/",
    source_format="zendar_parquet",
    folder="2026-09-21",
)
print(job["import_job_id"], job["video_id"])

job = client.upload(
    [
        "gs://zendar-batch-bucket-us/segments/segment-0042/",
        "gs://zendar-batch-bucket-us/segments/segment-0043/",
    ],
    source_format="zendar_parquet",
    folder="2026-09-21",
)
for video in job["videos"]:
    print(video["source_uri"], video["video_id"])
```

One call returns one job immediately after acceptance, with one reserved video ID
per directory. `wait_for_uploaded` does not change this asynchronous behavior.
Each call accepts 1–1,000 directories in one bucket; ZIPs, individual Parquet files,
and recursive discovery beneath a collection of recordings are not supported.

**Large batches.** Submit up to 1,000 directories in one call; you don't need to
pace or stagger uploads. Nomadic queues the recordings and processes them at the
rate its copy and ingestion capacity allows, so a large batch can take several
hours to finish. The SDK automatically generates an idempotency key for each
upload call and reuses it for automatic retries, so no key is needed in your code.
For more than 1,000 directories, submit one call per chunk:

```python theme={null}
jobs = []
for i in range(0, len(dirs), 1000):
    job = client.upload(
        dirs[i : i + 1000],
        source_format="zendar_parquet",
        folder="2026-09-21",
    )
    jobs.append(job["import_job_id"])
```

Names default to directory basenames. To choose names or folders individually:

```python theme={null}
job = client.upload(
    [
        {"source_uri": "gs://zendar-batch-bucket-us/segments/segment-0042/", "name": "Morning drive"},
        {"source_uri": "gs://zendar-batch-bucket-us/segments/segment-0043/", "folder": "2026-09-22"},
    ],
    source_format="zendar_parquet",
    folder="2026-09-21",
)
```

An item inherits the top-level folder unless it overrides it. `folder=None` keeps
an item unfiled. Use `scope="org"` for an organization folder. Folders group recordings
for analysis; uploading does not start analysis.

**3. Check the job or individual videos.**

```python theme={null}
status = client.get_import_job(job["import_job_id"])
print(status["status"], status["summary"])

page = client.get_import_job_videos(job["import_job_id"], limit=1000)
for video in page["videos"]:
    print(video["name"], video["import_status"], video["progress"], video["error"])

# Optional: block until every input finishes (default timeout: 24 hours).
result = client.wait_for_import_job(job["import_job_id"])
```

`status["summary"]` counts `completed`, `partial`, `failed`, and `in_progress`
inputs. `get_import_job` suggests how long to wait before polling again in
`poll_after_seconds` (30 seconds for jobs over 100 inputs). Videos are returned in
video ID order, not submission order; match them to your inputs by `name` or
`import_source_uri`.

An individual `import_status` moves through `queued`, `validating`, `copying`,
`converting`, and `ingesting`, then ends as `completed`, `partial`, or `failed`.
While an input waits for capacity, `progress["stage"]` says why, for example
`waiting_for_copy_slot`. Waiting never fails an input.
The job remains `processing` while any input is unfinished, including when siblings
have failed. `terminal=True` means all inputs have finished. The existing uppercase
`status` field describes video upload readiness; `import_status` covers the full
recording and its required sensor assets.

Use `next_cursor` when `has_more=True`; start from `cursor=None` for each new status
refresh. A cursor marks a page position, not a stream of changes. Waiting returns
failed/partial outcomes too; a local timeout leaves server processing running.

```python theme={null}
failed_ids = [v["video_id"] for v in page["videos"] if (v["error"] or {}).get("retryable")]
if failed_ids:
    client.retry_import_job(job["import_job_id"], video_ids=failed_ids)
```

Retry keeps the same job and video IDs and resumes the failed stage. Omit
`video_ids` to retry all eligible failures. Corrected source files require a new
upload. To resume monitoring after restarting your client, use the saved
`import_job_id` with `get_import_job()` or `wait_for_import_job()`. A new `upload()`
call creates a new import. If you need to safely repeat the submission itself
across restarts, supply the same optional `idempotency_key` and identical inputs,
names, folders, and scope; changing the request under that key returns HTTP 409.

#### Managing Cloud Integrations

Use this helper to manage reusable GCS/S3 credentials for cloud imports. See [Cloud Storage Uploads](https://docs.nomadicml.com/sdk/cloud-storage.md) for instructions on creating service-account keys and web UI setup.

```python title="Cloud integrations helper" theme={null}
# List every integration visible to your user/org
client.cloud_integrations.list()

# Filter by provider
client.cloud_integrations.list(type="gcs")

# Add a new GCS integration using a service account JSON file
client.cloud_integrations.add(
    type="gcs",
    name="Fleet bucket",
    bucket="drive-monitor",
    prefix="uploads/",
    credentials="service-account.json",  # path or dict/bytes
)

# Add a new S3 integration
client.cloud_integrations.add(
    type="s3",
    name="AWS archive",
    bucket="drive-archive",
    prefix="raw/",
    region="us-east-1",
    credentials={
        "accessKeyId": "...",
        "secretAccessKey": "...",
        "sessionToken": "...",  # optional
    },
)

# Add a Cloudflare R2 integration using the same S3 helper
client.cloud_integrations.add(
    type="s3",
    name="Customer R2",
    bucket="customer-r2",
    prefix="incoming/",
    endpoint_url="https://<account>.r2.cloudflarestorage.com",
    region="auto",
    credentials={
        "accessKeyId": "...",
        "secretAccessKey": "...",
    },
)

# Import from R2 using a normal s3:// URI and the saved integration id
client.upload(
    "s3://customer-r2/incoming/front.mp4",
    integration_id="r2-prod",
)
```

For Cloudflare R2 and other S3-compatible providers, keep using `s3://bucket/key.mp4`
URIs in `client.upload(...)`. The custom endpoint stays on the saved integration
via `endpoint_url`; it does not go into the import URI.

#### Multi-view (cloud)

Cloud multi-view uploads use dict mappings with `gs://` or `s3://` URIs. `front` is required in every set.

```python theme={null}
# Single cloud multi-view set
multi = client.upload(
  {
    "front": "s3://drive-monitor/uploads/trip-042/front.mp4",
    "left": "s3://drive-monitor/uploads/trip-042/left.mp4",
    "right": "s3://drive-monitor/uploads/trip-042/right.mp4",
  },
  folder="fleet_uploads",
  scope="org",
)
# Returns: {"import_job_id": "ij_xxx", "status": "importing"}
```

* Multiple cloud multi-view sets submitted in one `upload([...])` call produce one import job.
* `wait_for_uploaded=True` is ignored for cloud multi-view uploads.
* For multi-view import jobs, `client.get_import_job_videos()` returns front rows only and `total` is the requested set count.

#### get\_import\_job()

Fetch metadata for a cloud import job.

```python theme={null}
upload = client.upload(
    [
        "s3://drive-monitor-archive/2024-09-01/front.mp4",
        "s3://drive-monitor-archive/2024-09-01/rear.mp4",
    ],
    wait_for_uploaded=False,
)

job = client.get_import_job(upload["import_job_id"])
print(job["job_id"], job["total"])
```

**Required Parameters:**

| Parameter | Type | Description |
| - | - | - |
| `import_job_id` | `str` | Cloud import job ID returned by `upload()` |

**Returns:** Dict with job metadata fields such as:

* `job_id`
* `source` (`"s3"`, `"gcs"`, or `"hf_bucket"`)
* `bucket`
* `prefix`
* `folder_id`
* `folder_name`
* `total`
* timestamps (`created_at`, `completed_at`, `updated_at` when available)

#### Hugging Face integrations via the SDK

If you want to create and reuse a saved Hugging Face integration from the SDK,
create it with the cloud integrations helper and then pass its
`integration_id` into `upload()`:

```python theme={null}
integration = client.cloud_integrations.add_hf_bucket(
    name="HF footage",
    bucket="JohnnyMnenonic/test",
    token="hf_xxx",
    prefix="incoming/",
)

result = client.upload(
    "hf://buckets/JohnnyMnenonic/test/incoming/front.mp4",
    integration_id=integration["id"],
    wait_for_uploaded=False,
)
```

Prefer a fine-grained token if Hugging Face supports the required bucket
access. If bucket-specific scoping is unavailable, use a dedicated token or
account reserved for storage imports.

Outside of integration creation, the SDK does not accept Hugging Face tokens.
Use `client.upload("hf://buckets/...")` with an `integration_id`, or omit
`integration_id` and let the backend resolve a saved integration or public
access for that bucket.

> [!NOTE]
>
> For high-volume imports, treat `total` + `client.get_import_job_videos()` as the readiness contract.

#### get\_import\_job\_videos()

Fetch paginated per-video upload statuses for a cloud import job.

This endpoint is designed for large import jobs where returning all rows in one
response would be expensive (for example, thousands to hundreds of thousands of
videos). For jobs with more than \~1,000 videos, prefer cursor-based pagination
(`limit` + `cursor`) instead of requesting everything at once.

```python theme={null}
upload = client.upload(
    [
        "gs://drive-monitor/uploads/trip-042/front.mp4",
        "gs://drive-monitor/uploads/trip-042/rear.mp4",
    ],
    wait_for_uploaded=False,
)

cursor = None  # First page: no cursor
while True:
    result = client.get_import_job_videos(
        upload["import_job_id"],
        limit=500,
        cursor=cursor,  # Pass cursor from previous response
    )

    print(result["import_job_id"])
    print(result["video_count"], result["has_more"], result["next_cursor"])  # page_size, more pages?, next anchor
    print(result["videos"][:3])  # [{video_id, status, import_source_uri}, ...]

    if not result["has_more"]:
        break
    cursor = result["next_cursor"]  # Use this value for the next page
```

**Required Parameters:**

| Parameter | Type | Description |
| - | - | - |
| `import_job_id` | `str` | Cloud import job ID returned by `upload()` |

**Optional Parameters:**

| Parameter | Type | Default | Description |
| - | - | - | - |
| `limit` | `int` | `500` | Max videos to return in one page |
| `cursor` | `str` | `None` | Last `video_id` from previous page |
| `offset` | `int` | `None` | Offset-based fallback pagination (do not combine with `cursor`). Not supported for multi-view import jobs. |

**Returns:** Dict with:

* `import_job_id`
* `total` (requested count for this job; for multi-view jobs this is the requested set count)
* `limit`
* `cursor`
* `has_more`
* `next_cursor`
* `videos` (list of `{video_id, status, import_source_uri}` entries for detailed polling; multi-view jobs return front rows only)
* `video_count`

**Cursor Notes:**

* `cursor` is the last `video_id` from the previous response's `next_cursor`.
* Start with `cursor=None` for the first page.
* Stop paging when `has_more` is `False`.
* Prefer `cursor` pagination for large jobs; `offset` is mainly a fallback/debug option.
* Do not pass both `cursor` and `offset` in the same request.
* For multi-view cloud imports, `videos` contains currently materialized IDs (best-effort); use `total` as the requested target count.

> [!NOTE]
>
> `client.get_import_job_uploaded_video_ids()` remains available as a deprecated alias of `client.get_import_job_videos()`.

#### End-to-end cloud import example

```python theme={null}
import time

# 1. Start the cloud import — returns an import_job_id, NOT a video_id
result = client.upload([
    "s3://my-bucket/videos/clip_001.mp4",
    "s3://my-bucket/videos/clip_002.mp4",
    "s3://my-bucket/videos/clip_003.mp4",
])
print(result)
# {"import_job_id": "ij_a1b2c3d4e5f6", "status": "importing"}

job_id = result["import_job_id"]

# 2. Poll import-job videos until returned IDs reach the requested total
#    and each returned row is terminal.
TERMINAL = {"UPLOADED", "UPLOADING_FAILED"}
seen = {}
while True:
    job = client.get_import_job(job_id)
    target_total = int(job.get("total") or 0)
    cursor = None
    while True:
        page = client.get_import_job_videos(job_id, limit=500, cursor=cursor)
        for row in page["videos"]:
            seen[row["video_id"]] = row["status"]
        if not page["has_more"]:
            break
        cursor = page["next_cursor"]

    if target_total > 0:
        all_ids_materialized = len(seen) >= target_total
        all_terminal = all(status in TERMINAL for status in seen.values())
        print(f"Import progress: ids={len(seen)}/{target_total}")
        if all_ids_materialized and all_terminal:
            break
    time.sleep(10)

# 3. Use uploaded IDs for analysis
video_ids = [vid for vid, status in seen.items() if status == "UPLOADED"]

print(f"Imported {len(video_ids)} videos: {video_ids[:5]}...")

# 4. Now use the video IDs for analysis
client.analyze(
    video_ids,
    prompt="detect lane departure events",
)
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.