Quick Start

Get up and running with AgenticAPI by creating a simple NOTIFY endpoint to send notifications. This guide walks you through setting up a FastAPI application and testing it with a custom HTTP verb.

Prerequisites #

  • Python 3.8+
  • Installed dependencies: fastapi, uvicorn, pydantic, httpx, slowapi

Step 1: Create the Application #

Create a file named main.py with the following code:

Python
from fastapi import FastAPI, Request, HTTPException
from pydantic import BaseModel
import logging

app = FastAPI()

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

class NotifyQuery(BaseModel):
    recipient: str
    message: str
    channel: str = "email"  # email, sms
    priority: str = "normal"  # normal, high
    output_format: str = "json"  # json, text

@app.api_route("/notify", methods=["NOTIFY"])
async def notify_user(request: Request, query: NotifyQuery):
    if request.method.upper() != "NOTIFY":
        logger.error(f"Invalid method: {request.method}")
        raise HTTPException(status_code=405, detail="Method not allowed")
    # Simulate notification
    result = {
        "status": f"Notification sent via {query.channel} with {query.priority} priority",
        "recipient": query.recipient,
        "message": query.message
    }
    logger.info(f"Notification successful for {query.recipient}")
    return {"result": result, "used_fallback": False}

This defines a NOTIFY verb that sends a notification to a recipient via a specified channel.

Step 2: Run the Server #

Start the FastAPI server:

Bash
uvicorn main:app --host 0.0.0.0 --port 8000

Step 3: Test the Endpoint #

Test the NOTIFY verb using curl:

Bash
curl -X NOTIFY http://localhost:8000/notify -H "Content-Type: application/json" -d '{
  "recipient": "user@example.com",
  "message": "Task completed",
  "channel": "email",
  "priority": "normal",
  "output_format": "json"
}'

Expected Response:

JSON
{
  "result": {
    "status": "Notification sent via email with normal priority",
    "recipient": "user@example.com",
    "message": "Task completed"
  },
  "used_fallback": false
}

Next Steps #

  • Explore ACTION Verbs to implement other verbs like SUMMARIZE or FETCH.
  • Learn about Chaining Actions to build workflows.
  • Check Integration for REST compatibility and AI agent setup.
What are your feelings
Updated on May 28, 2025