|
| 1 | +# Onsight API |
| 2 | + |
| 3 | +**Photo infrastructure for AI agents and humans.** Onsight lets you commission a |
| 4 | +real, verified, geotagged photo of a specific place at a specific time — and pay |
| 5 | +for it per request. An AI agent can't walk outside and photograph a storefront, |
| 6 | +a parking lot, or a shelf. Onsight is the API that can. |
| 7 | + |
| 8 | +Live at **[onsight.photo](https://onsight.photo)**. |
| 9 | + |
| 10 | +--- |
| 11 | + |
| 12 | +## What Onsight is |
| 13 | + |
| 14 | +Onsight is a crowdsourced ground-truth photography marketplace: |
| 15 | + |
| 16 | +- A **requester** posts a *mission* — "photograph the queue outside this address, |
| 17 | + today, from the street" — and funds a reward in USDC. |
| 18 | +- Local **photographers** nearby fulfill it and submit photos. |
| 19 | +- The requester picks a winner; the escrowed reward pays out on-chain. |
| 20 | + |
| 21 | +There are **two front doors onto the same rail**: |
| 22 | + |
| 23 | +| Requester | How they order | How they pay | |
| 24 | +|---|---|---| |
| 25 | +| **Human** | web UI at [onsight.photo](https://onsight.photo) | direct USDC deposit (card on-ramp available) | |
| 26 | +| **AI agent** | `POST /agent/missions` | **[x402](https://x402.org)** — pays USDC per call, no account, no key | |
| 27 | + |
| 28 | +Same escrow, same photographer supply, same payout. Only how the order is placed |
| 29 | +and paid differs. |
| 30 | + |
| 31 | +## Why agents need it |
| 32 | + |
| 33 | +Agents are good at reasoning over data they're given and terrible at the physical |
| 34 | +world. They can't verify a place is real, open, busy, or gone. Onsight closes that |
| 35 | +gap: one paid API call returns a fresh, geotagged photograph taken by a real person |
| 36 | +on the ground. It's a ground-truth sensor for the physical world, priced per photo. |
| 37 | + |
| 38 | +## How agent payment works (x402) |
| 39 | + |
| 40 | +[x402](https://x402.org) is the "HTTP 402 Payment Required" standard — the server |
| 41 | +answers a paid request with a `402` and a price, the client pays inline and retries. |
| 42 | +No signup, no API key: **the agent's wallet _is_ the account.** |
| 43 | + |
| 44 | +``` |
| 45 | +1. Agent → POST /agent/missions?rewardUsd=20 (mission body, no payment) |
| 46 | +2. Onsight → 402 Payment Required { price: $20 USDC, payTo: treasury, network: Base } |
| 47 | +3. Agent → signs an EIP-3009 authorization, retries with an X-PAYMENT header |
| 48 | +4. Onsight → verifies + settles USDC on-chain → mission created & funded (escrow) |
| 49 | + returns the mission + the settlement txHash |
| 50 | +``` |
| 51 | + |
| 52 | +Settlement runs through a standard x402 **facilitator** (x402.org on testnet, |
| 53 | +Coinbase CDP on mainnet) — Onsight runs no extra chain infrastructure. Payment is |
| 54 | +on **[Base](https://base.org)** in **USDC**. |
| 55 | + |
| 56 | +> **x402 gates money _in_. A wallet signature gates every owner action.** |
| 57 | +
|
| 58 | +Once a mission is funded, the agent proves ownership of subsequent actions (edit the |
| 59 | +brief, pick a winner, refund) by signing a request with the same wallet — no more |
| 60 | +payments, since the money is already escrowed. |
| 61 | + |
| 62 | +## API surface |
| 63 | + |
| 64 | +Base URL: `https://onsight.photo` |
| 65 | + |
| 66 | +| Agent action | Endpoint | Auth | |
| 67 | +|---|---|---| |
| 68 | +| Post + fund a mission (place a photo order) | `POST /agent/missions?rewardUsd=N` | **x402** (payment = escrow funding) | |
| 69 | +| Read a mission + submitted photos | `GET /agent/missions/:id` | public | |
| 70 | +| Update brief / extend dates | `PATCH /agent/missions/:id` | wallet signature | |
| 71 | +| Pick + pay a winner | `POST /agent/missions/:id/select` `{ photoId }` | wallet signature | |
| 72 | +| Refund / cancel | `POST /agent/missions/:id/refund` | wallet signature | |
| 73 | + |
| 74 | +**Wallet-signature auth** (owner actions): send `X-Wallet-Address`, |
| 75 | +`X-Wallet-Signature`, and `X-Wallet-Timestamp`, signing the message |
| 76 | + |
| 77 | +``` |
| 78 | +Onsight agent: {METHOD} {path} @ {timestamp} body={sha256(body)} |
| 79 | +``` |
| 80 | + |
| 81 | +The signature is action-, time-, and body-bound (5-minute window), so a captured |
| 82 | +`select` signature can't be replayed with a swapped `photoId`. |
| 83 | + |
| 84 | +## Quick start |
| 85 | + |
| 86 | +Get a `402` quote for a $20 photo mission — no wallet required to see the price: |
| 87 | + |
| 88 | +```bash |
| 89 | +curl -i -X POST "https://onsight.photo/agent/missions?rewardUsd=20" \ |
| 90 | + -H "Content-Type: application/json" \ |
| 91 | + -d '{ |
| 92 | + "title": "Storefront at 123 Market St", |
| 93 | + "description": "Street-level photo of the entrance, taken today in daylight.", |
| 94 | + "lat": 37.7897, |
| 95 | + "lng": -122.3972, |
| 96 | + "radiusMeters": 150 |
| 97 | + }' |
| 98 | +# → HTTP/1.1 402 Payment Required |
| 99 | +# → body describes price, payTo (treasury), asset (USDC), and network (Base) |
| 100 | +``` |
| 101 | + |
| 102 | +To actually place and fund the order, an agent signs the payment and retries with an |
| 103 | +`X-PAYMENT` header. The full runnable flow — using [`x402-fetch`](https://www.npmjs.com/package/x402-fetch) |
| 104 | +so payment is handled automatically — is in |
| 105 | +**[`examples/x402-agent-order.js`](examples/x402-agent-order.js)**. |
| 106 | + |
| 107 | +Buying as a human? See **[`examples/human-order.md`](examples/human-order.md)**. |
| 108 | + |
| 109 | +## Examples |
| 110 | + |
| 111 | +- [`examples/x402-agent-order.js`](examples/x402-agent-order.js) — an agent places and |
| 112 | + funds a photo order via x402, then reads it back. |
| 113 | +- [`examples/human-order.md`](examples/human-order.md) — walkthrough for human buyers. |
| 114 | + |
| 115 | +## Status |
| 116 | + |
| 117 | +The USDC escrow rail is live on Base mainnet; the x402 agent channel is rolling out. |
| 118 | +Endpoints and payloads here track the public API — if something drifts, |
| 119 | +[open an issue](../../issues). |
| 120 | + |
| 121 | +## License |
| 122 | + |
| 123 | +[MIT](LICENSE) © squidcode |
0 commit comments