AI agents
Using an AI coding agent (Claude Code, Cursor, GitHub Copilot, Codex…) to connect your site or system to Emda? Give it these, and it can write the integration correctly the first time.
| File | What it is |
|---|---|
| emda.io/llms.txt | A short index of Emda’s docs for AI agents |
| emda.io/llms-full.txt | All the docs in one plain-text file: Page API, Remote API, features and setup |
| emda.io/emda.d.ts | TypeScript types for window.Emda |
| emda.io/openapi.json | The Remote API as OpenAPI 3.1, for generating clients |
npm install @emda/web (coming soon) |
Helpers, types and a fake kiosk for local development |
Quick start
Tell your agent:
Read https://emda.io/llms-full.txt and add Emda receipt printing to the checkout page. Use the types from https://emda.io/emda.d.ts.
For a lasting setup, add the rules below to your project’s agent instructions: AGENTS.md,
CLAUDE.md, .cursor/rules/emda.md or .github/copilot-instructions.md. Then save
emda.d.ts in your project (for example src/types/emda.d.ts) so the types are always
there.
Rules for your agent
Copy this block as it is:
## Emda kiosk integration
This site runs on Emda kiosks (https://emda.io). Full reference: https://emda.io/llms-full.txt.
Types for window.Emda: https://emda.io/emda.d.ts (save as src/types/emda.d.ts), or use the
@emda/web package (whenReady, printReceipt, …; @emda/web/mock gives a fake kiosk for development).
Remote API as OpenAPI 3.1: https://emda.io/openapi.json.
Page API (JavaScript in our pages, running in the kiosk):
- `window.Emda` is undefined outside Emda, and each part exists only when the kiosk enables it:
page integration (`version`, `getDeviceInfo`, `print`, `printUrl`, `home/reload/back/forward`),
`Emda.receipt` (receipt printer) and `Emda.scale` (scale). Always feature-detect:
`window.Emda?.receipt`, never assume.
- Wait for it: `if (window.Emda) start(); else addEventListener('emda:ready', start, { once: true });`
Also keep a normal path for regular browsers (the same page may open on a phone or a PC).
- Receipts are HTML printed at paper width: 58 mm = 384 CSS px, 80 mm = 576 CSS px, 1 CSS px = 1
printer dot, black on white. Use inline styles and inline (data:) or https images; scripts in the
receipt don't run. Hebrew and RTL work (`dir="rtl"`). ~24px is a normal line, ~40px a heading.
- Receipt and print calls resolve `{ ok: true }` or `{ ok: false, error }`; they don't throw. Show a
friendly message for `printer-unreachable`, `printer-failed`, `receipt-disabled`, `not-licensed`.
- Scale calls reject with `{ code, status, message }` (`not_connected`, `timeout`, `not_supported`,
…). Use `Emda.scale.waitForStable({ onReading })` for live weight and keep its `cancel()` for
cleanup. Weights are in kilograms.
- `Emda.printUrl(url)` and `Emda.receipt.printUrl(url)` only print pages the kiosk's site rules
allow (`error: 'blocked'` otherwise).
- Don't depend on `deviceId` for security: any page in the kiosk can read it.
Remote API (our server or tools, over the local network):
- `http://<kiosk IP>:8081/api/v1/...` with `Authorization: Bearer <token>`; JSON bodies;
responses `{ ok: true, ... }` or `{ ok: false, error }` with an HTTP status.
- Never call it from browser code (no CORS) and never ship the token to the client.
- 402 `not-licensed` means the kiosk's licence doesn't include that feature; 409 `admin-open`
means someone is in the kiosk's Settings: retry later.
Tips
- Test without a kiosk: keep the page working when
window.Emdais missing, and ask the agent to add a small fakewindow.Emdafor local development that logs receipts instead of printing. - Receipts: ask for a print-preview element sized 384 or 576 px wide, so you can check the layout in a normal browser before printing.
- Turn the features on in Emda: the page API parts appear only when enabled in the kiosk: Settings → Remote API → Allow page integration, Settings → Devices → Use a receipt printer, Settings → Devices → Use a scale.
- Human docs: Page API, Remote API.