# JapanLanded API (agents)

Estimates only. Not a checkout. Missing yen amounts are `null`, never invent zeros, VAT totals, FX, or DHL rates.

## Base URL

- Production: `https://japanlanded.com` (Worker `japanlanded-api` on `/v1/*` and `/mcp`)
- Local: `http://127.0.0.1:8788`

OpenAPI: [/openapi.json](/openapi.json)

## Auth

None. Rate limit: 60 requests / minute / IP.

## Endpoints

### `GET /v1/health`
Dataset version and `dataAsOf`.

### `POST /v1/estimate`
Body (JSON):

```json
{
  "price_jpy": 4500,
  "quantity": 1,
  "category": "figures",
  "country": "US",
  "weight_g": 600,
  "source_site": "mercari",
  "shipping_method": "ems",
  "lithium": "unspecified",
  "lang": "en"
}
```

Returns per-proxy `payNow` / `beforeItShips` / `onArrival` line items, `knownPartial` (not a landed total), `shippability`, `dutyNotes`, `gaps`, `sources`, and a `referral` object. `isLandedTotal` is always false.

### Partial sums: read before comparing proxies (added 2026-11-10)

Each item in `estimates[]` has:

| Field | Meaning |
|---|---|
| `knownPartial` | Sum of the lines that have numbers. **Not** what the buyer pays. |
| `totalIsPartial` | Always `true`. |
| `excludedUnknownCosts` | `[{code, label, certainty}]` costs that apply but have no number in the dataset, so they are left out of `knownPartial` (e.g. `payment_fee`, `domestic_shipping`, duty). |
| `partialNote` | One sentence naming those costs. |
| `notComparableBecause` | Costs this proxy includes or leaves out differently from the others. |

The result also has:

- `partialSumsComparable` — `false` when proxies leave out different costs.
- `comparisonNote` — e.g. Buyee's sum includes domestic shipping (150–1,500 yen) while most others leave it out, so Buyee can look more expensive than it is. **Do not rank proxies by `knownPartial`.** Compare line by line; treat `null` as unknown.

No numbers were changed by these fields.

## Errors

Bad input returns `400` with `{"error":"invalid_input","message":"..."}`, for example:

- `price_jpy must be a number (for example 8000), not the text "x".`
- `country is required: an ISO 3166-1 alpha-2 code such as US, GB or DE.` (estimate, check, compare)
- `Unknown country "ZZ". Use an ISO code such as US, GB, AU, CA, or DE.`
- `alcohol_abv above 0 is only accepted for category sake or whisky.`

Numeric fields accept numbers or plain numeric strings (`"8000"`). `429` = rate limit.

### `POST /v1/check`
Export check only (`allowed` | `conditional` | `blocked`).

### `POST /v1/compare`
Multi-item cart. `ranking.cheapest` and `ranking.fastest` stay `null`.

### `POST /v1/referral-link`
Buyee affiliate URL when enrolled and category is not alcohol. Sake/whisky → `suppressed: true`, `url: null`. Other proxies → public page, `placeholder: true` (White Rabbit Express → `https://whiterabbitexpress.com/`).

### `GET /v1/proxies` · `/v1/countries` · `/v1/weights` · `/v1/datasets`

## Rules for agents

1. Never treat `null` as `0`.
2. Never fetch `item_url` server-side (the API does not).
3. Do not execute purchases. Hand the human the referral URL when present. For Buyee, the first-party referral page is https://japanlanded.com/go/buyee/home/ (affiliate link, same destination).
4. Cite `datasetVersion` and `dataAsOf` in answers.
5. Alcohol pages/tools stay information-only (no affiliate).

## MCP

Streamable HTTP (stateless) at `/mcp`. See [mcp.md](./mcp.md).
