toon-package

Basic OpenAPI Example

This example demonstrates how to use Toon Agent Bridge with a simple OpenAPI 3.0 schema.

Prerequisites

Setup

  1. Install dependencies:
cd examples/basic-openapi
pnpm install
  1. Start the server:
pnpm start

The server will start on http://localhost:3000.

Endpoints

Once the server is running, you can access:

Testing the API

Using curl

# Get all users
curl http://localhost:3000/users

# Create a user
curl -X POST http://localhost:3000/users \
  -H "Content-Type: application/json" \
  -d '{"name": "John Doe", "email": "john@example.com"}'

# Get user by ID
curl http://localhost:3000/users/1

Using the Event Stream

Open http://localhost:3000/events in your browser or use curl:

curl http://localhost:3000/events

You’ll see events streamed in real-time as you make API calls.

Frontend Integration

You can use the React components from @programsmagic/toon-frontend to visualize the agent events:

import { AgentVisualizer } from '@programsmagic/toon-frontend';
import '@programsmagic/toon-frontend/styles';

function App() {
  return (
    <AgentVisualizer
      url="http://localhost:3000/events"
      protocol="sse"
      autoConnect={true}
    />
  );
}

Next Steps