Developer Guide

Everything you need to build ANML-powered services and agents. Choose your language, install the SDK, and start publishing or consuming duckuments in minutes.

Choose your role

🤖 Building an Agent (Client)

Your agent needs to discover, fetch, and act on ANML duckuments from services on the web.

You need a client SDK:

  • â€ĸ Discover services via well-known URIs
  • â€ĸ Parse XML/JSON duckuments
  • â€ĸ Evaluate disclosure constraints
  • â€ĸ Execute actions on behalf of users
  • â€ĸ Navigate multi-step flows

đŸ—ī¸ Building a Service (Server)

Your service needs to publish ANML duckuments so agents can understand and interact with it.

You need a server SDK:

  • â€ĸ Build duckuments with type-safe builders
  • â€ĸ Serialize to XML or JSON automatically
  • â€ĸ Serve discovery endpoints
  • â€ĸ Validate documents against the spec
  • â€ĸ Handle content negotiation

Install

Python

Client SDKpip install anml-client
Server SDKpip install anml-server

Node.js / TypeScript

Client SDKnpm install @anml-foundation/client
Server SDKnpm install @anml-foundation/server

Rust

Client SDKcargo add anml-client
Server SDKcargo add anml-server

Client Quick Start

Fetch an ANML duckument, read its knowledge, and execute an action.

Python

import asyncio
from anml_client import AnmlClient, AllowListTrustPolicy

async def main():
    client = (
        AnmlClient.builder()
        .base_url("https://shop.example.com")
        .trust_policy(AllowListTrustPolicy(["https://shop.example.com"]))
        .build()
    )

    # Fetch the service's ANML duckument
    doc = await client.fetch("/.well-known/anml")

    # Read what the service wants to tell us
    for inform in doc.knowledge.inform if doc.knowledge else []:
        print(f"â„šī¸  {inform.content}")

    # Check what data the service needs
    for ask in doc.knowledge.ask if doc.knowledge else []:
        print(f"❓ Needs: {ask.field} (purpose: {ask.purpose})")

    # Execute an action (after getting user consent for disclosed fields)
    response = await client.execute_action(doc, "checkout", {
        "email": "user@example.com",
        "shipping_address": "123 Main St",
    })
    print(f"✅ {response.status_code}")

asyncio.run(main())

Node.js / TypeScript

import { AnmlClient, AllowListTrustPolicy } from '@anml-foundation/client';

const client = AnmlClient.builder()
  .baseUrl('https://shop.example.com')
  .trustPolicy(new AllowListTrustPolicy(['https://shop.example.com']))
  .build();

// Fetch the service's ANML duckument
const doc = await client.fetch('/.well-known/anml');

// Read knowledge the service shares
for (const inform of doc.knowledge?.inform ?? []) {
  console.log(`â„šī¸  ${inform.content}`);
}

// Execute an action
const response = await client.executeAction(doc, 'checkout', {
  email: 'user@example.com',
  shippingAddress: '123 Main St',
});
console.log(`✅ ${response.status}`);

Server Quick Start

Build an ANML duckument that describes your service to agents. The SDK handles serialization, validation, and discovery — you provide the business logic.

Python (FastAPI)

from fastapi import FastAPI, Request
from anml_server import AnmlDocument, negotiate_content_type

app = FastAPI()

@app.get("/.well-known/anml")
async def serve_anml(request: Request):
    doc = (
        AnmlDocument.builder()
        .title("Acme Electronics — Checkout")
        .ttl(300)
        # Brand & persona
        .persona(
            tone="helpful",
            instructions="Show itemized totals. Confirm before payment.",
            brand_color="#4F46E5",
            logo_url="https://acme.example.com/logo.png",
        )
        # Privacy constraints
        .disclosure("payment-credential", requires="explicit-consent")
        .disclosure("shipping-address", requires="explicit-consent")
        .disclosure("email", requires="legitimate-interest")
        # Workflow state
        .flow([
            Step("browse", label="Browse", status="completed"),
            Step("checkout", label="Checkout", status="current", action="submit-order"),
            Step("confirm", label="Confirmed", status="pending"),
        ])
        # Actions the agent can take
        .action(
            "submit-order",
            method="POST",
            endpoint="/api/orders",
            auth="required",
            confirm=True,
        )
        # Knowledge exchange
        .inform("Free shipping on orders over $75. 30-day returns.", ttl=3600)
        .inform("Holiday sale: 20% off all monitors through Dec 31.", ttl=86400)
        .ask("email", action="submit-order", required=True, purpose="receipt")
        .ask("shipping-address", action="submit-order", required=True, purpose="delivery")
        # Usage rights
        .rights("cache")
        # Content
        .body("4K Monitor x1 — $599.00 | USB-C Cable x2 — $29.98 | Subtotal: $628.98")
        .build()
    )

    content_type = negotiate_content_type(request.headers.get("accept", ""))
    return doc.to_response(content_type=content_type)

Node.js (Express)

import express from 'express';
import { AnmlDocument, negotiateContentType } from '@anml-foundation/server';

const app = express();

app.get('/.well-known/anml', (req, res) => {
  const doc = AnmlDocument.builder()
    .title('Acme Electronics — Checkout')
    .ttl(300)
    .persona({
      tone: 'helpful',
      instructions: 'Show itemized totals. Confirm before payment.',
      brandColor: '#4F46E5',
      logoUrl: 'https://acme.example.com/logo.png',
    })
    .disclosure('payment-credential', { requires: 'explicit-consent' })
    .disclosure('shipping-address', { requires: 'explicit-consent' })
    .flow([
      { id: 'browse', label: 'Browse', status: 'completed' },
      { id: 'checkout', label: 'Checkout', status: 'current', action: 'submit-order' },
      { id: 'confirm', label: 'Confirmed', status: 'pending' },
    ])
    .action('submit-order', {
      method: 'POST',
      endpoint: '/api/orders',
      auth: 'required',
      confirm: true,
    })
    .inform('Free shipping on orders over $75. 30-day returns.', { ttl: 3600 })
    .ask('email', { action: 'submit-order', required: true, purpose: 'receipt' })
    .ask('shipping-address', { action: 'submit-order', required: true, purpose: 'delivery' })
    .rights('cache')
    .body('4K Monitor x1 — $599.00 | USB-C Cable x2 — $29.98 | Subtotal: $628.98')
    .build();

  const contentType = negotiateContentType(req.headers.accept);
  res.type(contentType).send(doc.serialize(contentType));
});

app.listen(3000);

Key Concepts

Discovery

Agents find your ANML duckument via /.well-known/anml, Link headers, or HTML <link> tags. The server SDK sets these up automatically. The client SDK checks all three.

Disclosure & Consent

Before sharing user data, agents must evaluate your disclosure constraints. Fields marked 'explicit-consent' require the user to actively agree. The client SDK enforces this — it won't send data that violates constraints.

Knowledge Exchange

Use 'inform' to proactively tell agents things (policies, deals, availability). Use 'ask' to request data from agents (with a stated purpose). Agents decide whether to comply based on their trust policy and user preferences.

Flow State

Multi-step workflows (browse → checkout → payment → confirm) are explicit in the duckument. Agents always know where the user is and what comes next. No inference required.

Persona & Branding

Tell agents how to represent your service: tone, language, brand colors, logo, and specific instructions. The agent adapts its presentation to match your brand identity.

Content Negotiation

Agents request XML or JSON via the Accept header. Your server SDK handles serialization automatically. Both formats are normative and semantically identical.

Trust & Rights

Usage rights (none < display < cache < store < train) tell agents what they can do with your content. Trust delegation via DNS lets you verify third-party serving domains.

Package Registries

All SDKs are published to their language's standard package registry and versioned with semantic versioning.

PackageRegistryInstall
anml-client (Python)PyPIpip install anml-client
anml-server (Python)PyPIpip install anml-server
@anml-foundation/clientnpmnpm install @anml-foundation/client
@anml-foundation/servernpmnpm install @anml-foundation/server
anml-client (Rust)crates.iocargo add anml-client
anml-server (Rust)crates.iocargo add anml-server

Resources

Need help getting started?

We're building the foundation for the agentic web and want to help early adopters succeed. Reach out for integration support, architecture guidance, or to discuss your use case.