SDK v0.1 — Node.js ≥ 18 — Base / USDC

Visualize, Optimize, and Monetize AI Traffic

Stop guessing how AI agents use your site. Apptvty gives you the visibility and tools to own your relationship with the agentic web:

  • Surface Agentic Traffic

    Real-time visibility into GPTBot, ClaudeBot, PerplexityBot, and more — classified in-process from the User-Agent header with zero latency.

  • Optimize for AEO

    Tailor how agents read and understand your site with a dedicated /query endpoint. Apptvty answers using RAG over your indexed content.

  • Monetize the Bots

    Turn agentic queries into a new revenue stream. Earn USDC from sponsors when their ads match the intent of an AI agent query.

bash
npm install apptvty

Quick Start

Get running in under 5 minutes. No account or email needed — the CLI creates a wallet for you.

1

Install

bash
npm install apptvty
# or
pnpm add apptvty
2

Register your site

bash
# Interactive (human)
npx apptvty init

# Non-interactive (agent / CI)
npx apptvty init --domain mysite.com --framework nextjs --non-interactive

Writes APPTVTY_API_KEY and APPTVTY_SITE_ID to your env file. CLI reference →

3

Add to your framework

See Next.js or Express sections below for full examples.

4

Verify

bash
# Simulate a GPTBot request
curl -A 'GPTBot/1.1' https://yoursite.com/

# Test the query endpoint
curl 'https://yoursite.com/query?q=What+does+this+site+do'

Open your dashboard and watch the request appear in real time.


How it works

Apptvty provides the infrastructure to visualize, optimize, and monetize your site's agentic interactions with zero impact on human user experience.

  1. 01

    Request interception

    The SDK middleware (Next.js or Express) inspects every incoming request. It reads the User-Agent header and classifies the requester against a built-in database of known AI crawlers — in-process, with zero latency.

  2. 02

    Background logging

    Request metadata (crawler type, response time, path, IP) is batched and flushed to Apptvty's analytics API asynchronously. Your response time is never affected.

  3. 03

    Content indexing

    When a crawler visits a page, Apptvty indexes the content using OpenAI's text-embedding-3-small model. Embeddings are stored in a pgvector database so RAG queries are fast (<50ms).

  4. 04

    AEO query answering

    When an AI agent calls your /query endpoint, Apptvty embeds the question, retrieves the most semantically relevant content chunks, and calls Claude to generate a structured answer with source citations.

  5. 05

    Ad matching & billing

    Relevant sponsor ads are matched to the query semantically. If a match is found, the ad is included in the response. The advertiser is charged per impression in USDC; 70% goes to you.


Next.js Integration

Two files. Supports App Router and Pages Router. Full guide →

middleware.ts
import { withApptvty } from 'apptvty/nextjs';

export default withApptvty({
  apiKey: process.env.APPTVTY_API_KEY!,
  siteId: process.env.APPTVTY_SITE_ID!,
});

export const config = {
  matcher: ['/((?!_next/static|_next/image|favicon.ico).*)'],
};
app/query/route.ts
import { createNextjsQueryHandler } from 'apptvty/nextjs';

export const GET = createNextjsQueryHandler({
  apiKey: process.env.APPTVTY_API_KEY!,
  siteId: process.env.APPTVTY_SITE_ID!,
});
The /query route file is optional but recommended — it makes your site queryable by AI agents like Claude, Perplexity, and ChatGPT plugins. Without it, Apptvty only logs traffic.

Express Integration

Drop-in middleware and query handler for Express 4+ and any Connect-compatible framework. Full guide →

server.ts
import express from 'express';
import {
  createExpressMiddleware,
  createExpressQueryHandler,
} from 'apptvty/express';

const app = express();
const config = {
  apiKey: process.env.APPTVTY_API_KEY!,
  siteId: process.env.APPTVTY_SITE_ID!,
};

// Log every request
app.use(createExpressMiddleware(config));

// AEO query endpoint
app.get('/query', createExpressQueryHandler(config));

app.listen(3000);

Query Endpoint (AEO)

AEO — Agent Experience Optimization — is the AI equivalent of SEO. Your /query endpoint lets AI agents ask natural language questions and get accurate, source-cited answers about your content.

How agents find your /query endpoint: Apptvty registers your site with a structured schema. When agents like Claude or GPT search for information, they can discover your endpoint via your /agents.txt file (automatically served by the SDK) or through Apptvty's agent discovery index.

Request

http
GET https://yoursite.com/query?q=What+are+your+pricing+plans
# or
POST https://yoursite.com/query
Content-Type: application/json

{ "q": "What are your pricing plans?", "max_tokens": 800 }

Response

json
{
  "query_id": "q_abc123",
  "answer": "Apptvty offers a free tier with up to 10,000 requests/month...",
  "sources": [
    { "url": "/pricing", "title": "Pricing", "relevance": 0.94 },
    { "url": "/docs", "title": "Documentation", "relevance": 0.87 }
  ],
  "confidence": 0.94,
  "response_time_ms": 312,
  "tokens_used": 420,
  "sponsored": {
    "label": "Sponsored",
    "text": "Acme Analytics — Enterprise-grade observability for AI-first teams.",
    "url": "https://acme.example.com",
    "advertiser": "Acme Analytics"
  }
}

Full query endpoint reference →


Ad Monetization

Agentic ad impressions are a new revenue stream. Unlike display ads (which AI crawlers ignore), Apptvty ads are embedded directly in query responses — read and processed by the agent.

70%

Publisher share

You keep 70% of every agentic impression bid.

USDC

Payment currency

Paid on Base L2. Withdraw to any compatible wallet.

Enable ads

Ads are opt-in. Enable them from your site settings or via the API:

bash
# Enable via CLI
npx apptvty config --site-id $APPTVTY_SITE_ID --ads-enabled true

When enabled, Apptvty shows Apptvty house ads by default (no revenue, but zero clutter). Advertiser-matched ads replace them when campaigns are active.


Analytics

The Apptvty dashboard shows real-time AI traffic, crawler breakdown, query history, and wallet earnings. It's also accessible via API — useful for coding agents that need to read analytics without a browser.

EndpointReturns
GET /v1/sites/{id}/stats30-day overview (total requests, AI %, avg response time)
GET /v1/sites/{id}/stats/dailyDay-by-day request counts, AI vs human split
GET /v1/sites/{id}/crawlersCrawler type breakdown with last-seen timestamps
GET /v1/sites/{id}/queriesRecent agent queries with answers and token usage
GET /v1/sites/{id}/walletUSDC balance, total earned, total spent

All analytics endpoints accept your APPTVTY_API_KEY as a Bearer token — no browser login needed for programmatic access.


FAQ

What is Apptvty?
Apptvty is an analytics and monetization platform for the agentic web. It provides real-time visibility into AI traffic, tools to optimize your content for AI search (AEO), and a way to earn USDC from the bots crawling your site.
What AI crawlers does Apptvty detect?
GPTBot (OpenAI), ClaudeBot (Anthropic), PerplexityBot, Google-Extended, Bingbot, YouBot, and Meta-ExternalAgent — all identified in-process from the User-Agent header with no external network call.
What is AEO (Agent Experience Optimization)?
AEO is the practice of optimizing your website so AI agents can discover, read, and query it. Your /query endpoint is the core of AEO — it lets agents ask natural language questions and get structured, source-cited answers. It's the AI equivalent of SEO.
How do I get my site indexed for RAG queries?
Apptvty automatically indexes your page content when AI crawlers visit them. You can also trigger a full crawl via the CLI: npx apptvty crawl --site-id $APPTVTY_SITE_ID.
How are publishers paid?
When an advertiser's campaign matches an agentic query on your site, the advertiser is charged their bid per view in USDC. 70% of each bid goes to your Apptvty wallet. You can withdraw to any Base L2-compatible wallet at any time.
Is there a free tier?
Yes. Analytics and the query endpoint are free. Revenue sharing begins immediately when ads are enabled and advertiser campaigns are active.
Can AI agents use this endpoint directly?
Yes. The /query endpoint is designed for programmatic access. It requires only a GET request with a q parameter or a POST with a JSON body. No authentication is needed to query — authentication is tied to the site's API key at the backend.

Ready to own your AI traffic?

Install the SDK, surface your agentic traffic, and start monetizing the bots crawling your site today.