Aperture API

Quickstart

Fastest path: the browser form — no account, no setup

Open https://api.apertureapi.com/ in a browser, choose a hologram, and submit. Nothing to install and no credentials required. Wait about three seconds after the page loads before submitting; the form carries a short-lived page token and a faster submission is rejected.

From the command line, no account

The same no-account path in two calls. Fetch a page token, wait out the dwell, then submit it with your file:

TOKEN=$(curl -sS https://api.apertureapi.com/public/form_token \
  | grep -o '"token":"[^"]*"' | cut -d'"' -f4)

sleep 3

curl -sS -X POST https://api.apertureapi.com/public/reconstruct \
  -F "file=@hologram.png" \
  -F "form_token=$TOKEN" \
  -F "holography_mode=inline" \
  -F "wavelength_um=0.635" \
  -F "pixel_pitch_um=1.85" \
  -F "z_min_mm=0.5" \
  -F "z_max_mm=3.0" \
  -o reconstruction.zip

No hologram yet? Use the sample: https://api.apertureapi.com/static/samples/inline-sample-512.png (the settings above are the sample's). holography_mode is inline, off-axis (the default) or auto — set it to match your setup, or the reconstruction runs with the wrong model.

On this path the optical parameters are form fields. The token is bound to your IP and User-Agent, so both calls must come from the same client, and each token may be used once. Public access is rate-limited — see the tier-limits page.

With an API account

Requires an API account. /reconstruct_pdhm is authenticated: pass your API key as a bearer credential. See the auth-and-signup page to get one. This path accepts larger inputs and higher quota.

curl -sS -X POST "https://api.apertureapi.com/reconstruct_pdhm?\
wavelength_um=0.635&pixel_pitch_um=1.85&z_min_mm=0.5&z_max_mm=3.0" \
  -H "Authorization: Bearer $APERTURE_API_KEY" \
  -F "file=@hologram.png" \
  -o reconstruction.zip

Here the optical parameters are query parameters, not form fields — that differs from the public path above. Add &holography_mode=inline for in-line setups.

From Python

import time, requests
API = "https://api.apertureapi.com"
s = requests.Session()          # same client for both calls
token = s.get(f"{API}/public/form_token").json()["token"]
time.sleep(3)
with open("hologram.png", "rb") as f:
    r = s.post(f"{API}/public/reconstruct", files={"file": f}, data={
        "form_token": token, "holography_mode": "inline",
        "wavelength_um": 0.635, "pixel_pitch_um": 1.85,
        "z_min_mm": 0.5, "z_max_mm": 3.0}, timeout=300)
r.raise_for_status()
open("reconstruction.zip", "wb").write(r.content)

In both cases

The response is a ZIP archive — save it as .zip, not .npz. The archive contains an .npz of the raw arrays alongside the other outputs; see the output-zip page.