# Quickstart — Argus

Upload multiple panoramas or pinhole images in a ZIP, submit an Argus task, and retrieve its reconstruction outputs.

Canonical: https://developer.realsee.ai/docs/argus/quickstart
Source: https://developer.realsee.ai/docs/argus/quickstart.md
Language: en

Use multiple **2:1 equirectangular panoramas** or multiple **1:1 pinhole images** to reconstruct a scene. Package one input type per batch in a ZIP. This guide uses the overseas gateway and Node.js on your backend.

```text
Authenticate → GET file/token → upload input.zip → POST task/submit → GET task/info → download output.zip
```

## Before you start

[Open Apps](https://developer.realsee.ai/dashboard/apps) and select the owning Team. Use an enabled Developer app, or have a Team owner create a trial app. Each Team may have up to 10 apps; expired or disabled apps still count. A new app has the default 14-day trial. Its App request completes when the app and AK binding are confirmed; reconstruction has its own task status.

The app uses the shared `/open` scope. No separate Argus capability application is required. Keep AK/SK, gateway tokens, upload credentials, and orchestration on your backend. Configure `REALSEE_APP_KEY` and `REALSEE_APP_SECRET` in your local server environment; never paste the SK into a prompt or browser code.

Use Node.js 24 and install the uploader with the AWS adaptor's runtime dependency for the overseas storage service:

```bash
npm install @realsee/universal-uploader@0.1.1 @aws-sdk/client-s3@3.1084.0
```

## Prepare the input ZIP

Put 1–99 JPEG, PNG, or WebP images directly at the archive root. Images must be RGB, 8-bit per channel. Use either 2:1 panoramas throughout, or 1:1 pinhole images throughout. Do not combine both types in this workflow.

```text
input.zip
├── entrance.jpg
├── living-room.jpg
└── kitchen.jpg
```

Use distinct filenames without directories, path traversal, control characters, duplicate stems, or names that collide after Unicode normalization and case folding. The output manifest's `name_mapping` will identify which output belongs to each input.

Argus's ZIP has no `manifest.json` or `images/` subdirectory. [Pano-to-VR](https://developer.realsee.ai/docs/pano-to-vr) is a separate API with its own package format.

## Implement the server workflow

Save the following as `argus.mjs` in your backend project. The three Argus routes are defined in the [API Reference](https://developer.realsee.ai/docs/argus/reference).

```js
import { Uploader } from '@realsee/universal-uploader'
import { AwsAdaptor } from '@realsee/universal-uploader/adaptors/aws'

const gateway = 'https://app-gateway.realsee.ai'

async function readData(response) {
  if (!response.ok) throw new Error(`Argus HTTP error: ${response.status}`)
  const payload = await response.json()
  if (payload.code !== 0 || !payload.data || typeof payload.data !== 'object' || Array.isArray(payload.data)) {
    throw new Error('Argus request was not successful')
  }
  return payload.data
}

export async function getArgusAccessToken() {
  const appKey = process.env.REALSEE_APP_KEY
  const appSecret = process.env.REALSEE_APP_SECRET
  if (!appKey || !appSecret) throw new Error('Configure server-side app credentials')
  const response = await fetch(`${gateway}/auth/access_token`, {
    method: 'POST',
    headers: { 'content-type': 'application/x-www-form-urlencoded' },
    body: new URLSearchParams({ app_key: appKey, app_secret: appSecret }),
    signal: AbortSignal.timeout(30_000),
  })
  const data = await readData(response)
  if (typeof data.access_token !== 'string' || !data.access_token || !Number.isInteger(data.expire_at) || data.expire_at * 1000 <= Date.now()) {
    throw new Error('Argus returned an invalid access token')
  }
  return data.access_token
}

async function requestArgus(path, accessToken, body) {
  return readData(await fetch(`${gateway}${path}`, {
    method: body === undefined ? 'GET' : 'POST',
    headers: {
      authorization: accessToken,
      ...(body === undefined ? {} : { 'content-type': 'application/json' }),
    },
    ...(body === undefined ? {} : { body: JSON.stringify(body) }),
    signal: AbortSignal.timeout(30_000),
  }))
}

export async function createArgusUpload(accessToken) {
  const lease = await requestArgus('/open/v1/argus/file/token', accessToken)
  for (const field of ['tmpSecretId', 'tmpSecretKey', 'sessionToken', 'bucket', 'region', 'prefix']) {
    if (typeof lease[field] !== 'string' || !lease[field]) {
      throw new Error('Argus returned an incomplete upload lease')
    }
  }
  return lease
}

export async function uploadArgusZip(accessToken, filePath) {
  const uploader = new Uploader(AwsAdaptor, {
    getToken: () => createArgusUpload(accessToken),
  })
  const receipt = await uploader.uploadFile('input.zip', filePath)
  if (!receipt.objectPath) throw new Error('Upload did not return a full object key')
  return receipt.objectPath
}

export async function submitArgusTask(accessToken, privateCosKey, title) {
  if (!privateCosKey || !title?.trim()) throw new Error('Object key and title are required')
  // Submit once. A lost response can mean the server already created the task.
  const data = await requestArgus('/open/v1/argus/task/submit', accessToken, {
    private_cos_keys: [privateCosKey],
    title,
  })
  if (typeof data.task_code !== 'string' || !data.task_code) {
    throw new Error('Submission returned no task code; do not resubmit automatically')
  }
  return data.task_code
}

export async function pollArgusTask(accessToken, taskCode) {
  if (!taskCode) throw new Error('Task code is required')
  const query = new URLSearchParams({ task_code: taskCode })
  // Ten minutes is this example's waiting policy, not a service completion SLA.
  for (let attempt = 0; attempt < 300; attempt += 1) {
    const data = await requestArgus(`/open/v1/argus/task/info?${query}`, accessToken)
    if (data.status === 2) {
      if (typeof data.output_url !== 'string' || !data.output_url || !Number.isInteger(data.expiration_timestamp) ||
          data.expiration_timestamp * 1000 <= Date.now()) {
        throw new Error('Task succeeded without a usable result URL; query task info again')
      }
      return data
    }
    if (data.status === 3) throw new Error('Argus task failed; inspect its task info on your backend')
    if (data.status !== 0 && data.status !== 1) throw new Error('Unexpected Argus task status')
    await new Promise((resolve) => setTimeout(resolve, 2000))
  }
  throw new Error('Stopped waiting; resume queries with the existing task code')
}
```

The uploader's `receipt.objectPath` is the full object key, including the granted prefix. Pass that value unchanged in `private_cos_keys`; do not submit a download URL or prepend the prefix a second time. The submit request has no `type` parameter.

## Upload and submit once

Use this sequence from your server after validating `input.zip`:

```js
import { getArgusAccessToken, uploadArgusZip, submitArgusTask } from './argus.mjs'

const accessToken = await getArgusAccessToken()
const privateCosKey = await uploadArgusZip(accessToken, './input.zip')
const taskCode = await submitArgusTask(accessToken, privateCosKey, 'My reconstruction')
// Persist taskCode with your task record before starting status queries.
```

Do not submit if upload fails. Submission is not idempotent: if the request outcome is unknown, investigate the existing task instead of automatically resubmitting it. Resume status queries using the saved `task_code`, including after restarting your backend.

## Query and collect the result

Call `pollArgusTask` with a current access token and the saved task code. Task status is `0` queued, `1` processing, `2` succeeded, or `3` failed. Keep polling on your backend; the example stops waiting after ten minutes without creating another task.

After task success, download `output_url` before the returned Unix timestamp `expiration_timestamp`. Stream the ZIP into your controlled storage and avoid logging or exposing its temporary URL. The response does not promise a fixed download lifetime or permanent file retention.

Read `output.json` inside the ZIP before using its products. Its `success`, `partial`, and `error` statuses are separate from the gateway task status. See [Outputs and Result Handling](https://developer.realsee.ai/docs/argus/outputs) for the EXR depth maps, merged GLB point cloud, camera poses, and validation rules. These products are not a complete Five SDK Work payload or a ready-made VR tour.

## Continue

- [API Reference](https://developer.realsee.ai/docs/argus/reference): exact request and response fields.
- [Outputs and Result Handling](https://developer.realsee.ai/docs/argus/outputs): file formats, coordinates, and partial results.
- [Pano-to-VR](https://developer.realsee.ai/docs/pano-to-vr): create a browsable Realsee project through the separate Pano-to-VR API.
- [Realsee Discord community](https://discord.gg/JvxBZJkbNZ): integration questions; never share SK or tokens.

Run the workflow with your Team's app and input ZIP. Check task completion and the downloaded output manifest before using the reconstruction.
