Skip to content

API Endpoints

John Williams edited this page Mar 6, 2026 · 1 revision

API Endpoints

Python REST API (Path A — FastAPI)

Start the server:

uvicorn deploy.server:app --host 0.0.0.0 --port 8000

Endpoints

Method Path Description
POST /chat Send a message, get a response
POST /sessions Create a new conversation session
GET /sessions/{id} Get session info and message count
DELETE /sessions/{id} Delete a session
GET /health Health check with credential status
GET /tools List all 28 tools and their file status

POST /chat

Request:

{
  "message": "Show me an account summary for Acme Corp",
  "session_id": "optional-session-id"
}

Response:

{
  "response": "Here's the account summary for Acme Corp...",
  "session_id": "abc-123-def",
  "tool_calls_made": 2
}

GET /health

Response:

{
  "status": "healthy",
  "credentials": {
    "anthropic": true,
    "google_ads": true,
    "cloudinary": false,
    "searchapi": true,
    "gemini": false
  },
  "tools_loaded": 28,
  "model": "claude-opus-4-5-20251101"
}

Buddy API (Path C — Cloudflare Pages Functions)

Brain API — /api/brain

The main AI endpoint for all tool-calling conversations.

Method: POST

Request body:

{
  "action": "chat",
  "sessionId": "user-session-id",
  "message": "Show me my top campaigns",
  "provider": "anthropic",
  "model": "claude-sonnet-4-6",
  "apiKey": "sk-ant-...",
  "gadsCreds": {
    "refreshToken": "1//...",
    "clientId": "...",
    "clientSecret": "...",
    "customerId": "123-456-7890",
    "loginCustomerId": "111-222-3333",
    "developerToken": "..."
  },
  "businessContext": "E-commerce store selling electronics"
}

Response: Server-Sent Events (SSE) stream with chunks of:

  • data: {"type":"text","content":"..."} — text response chunks
  • data: {"type":"tool_call","name":"...","input":{}} — tool call notifications
  • data: {"type":"tool_result","name":"...","result":"..."} — tool results
  • data: {"type":"thinking","content":"..."} — tool execution progress

Google Ads API — /api/gads

Direct Google Ads API access.

Method: POST

Supported actions (47 reads + 62 writes): See Read Tools and Write Tools.

Request body (read):

{
  "action": "list_campaigns",
  "refreshToken": "1//...",
  "clientId": "...",
  "clientSecret": "...",
  "customerId": "123-456-7890",
  "loginCustomerId": "111-222-3333",
  "developerToken": "...",
  "dateRange": "LAST_30_DAYS",
  "status": "ENABLED",
  "limit": 20
}

Request body (write):

{
  "action": "create_campaign",
  "refreshToken": "...",
  "customerId": "...",
  "name": "My New Campaign",
  "budgetAmountDollars": 50,
  "channelType": "SEARCH",
  "biddingStrategy": "MAXIMIZE_CONVERSIONS"
}

Auth — /api/auth

Google OAuth 2.0 flow.

Action Description
login Initiates OAuth flow with Google
callback Handles OAuth callback, creates session
refresh Refreshes expired access token

Other Endpoints

Endpoint Method Description
/api/search GET Public search API for services
/api/crux POST Chrome UX Report proxy
/api/indexnow POST IndexNow API for search engine notification
/api/notifications POST Email, Slack, and webhook notifications
/api/reports POST Report generation and access
/api/compute POST Chart generation and statistical analysis

Rate Limits

All endpoints are rate-limited via _middleware.js:

Endpoint Limit
/api/brain 30 req/min
/api/gads 40 req/min
/api/auth 20 req/min
Others 30 req/min

Clone this wiki locally