Developer Documentation & Protocol Reference.

Complete technical specification for integrating native zero-iframe ad placements, contextual AI routing, barter clearinghouse settlement, and MRC viewability tracking.

Jump to:
Sub-14ms Cloudflare Edge·Zero-iFrame Native DOM·CLS = 0.00 Guaranteed·FTC & MRC Compliant
Ch:Network Architecture & Clearance
CHAPTER 01·ARCHITECTURE & CLEARANCE

Network Architecture & Clearance Loop

Trade Impression operates a distributed programmatic clearinghouse engineered exclusively for developer-facing software, technical SaaS, and AI agent workflows.

STAGE 01

Context Signal

Publisher app passes slot, publisher_id, and optional contextual keywords (e.g. legal_saas, postgres).

STAGE 02

Edge Auction

Cloudflare Edge worker executes contextual bandit routing against active campaigns in <14ms. Empty fill returns fill: false.

STAGE 03

Native Injection

Creative renders inside host DOM with zero iframe delay, inherits host CSS fonts, and binds FTC-mandated "Sponsored" badge.

STAGE 04

MRC Clearing

After 1.0s continuous 50% viewport dwell, verified impression beacon executes. Clearinghouse credits publisher barter ledger or cash reserve.

Zero-iFrame Isolation: Unlike legacy ad networks that embed heavy, slow iframes, Trade Impression renders lightweight semantic HTML directly inside the host DOM. This ensures instant rendering, sub-1KB payload footprint, and flawless responsive adaptation.
CHAPTER 02·GETTING STARTED

5-Minute Automated Quickstart

Choose between the interactive terminal CLI, the AI coding agent Stdio MCP protocol, or automated GitHub pull request generation.

# Run the automated repository detector in your project root:
npx @tradeimpression/setup --publisher pub_termscore --slot sidebar --context legal_saas --yes

# The CLI will:
# 1. Detect Next.js, Vite, Remix, or static HTML
# 2. Install @tradeimpression/react or inject <ti-placement>
# 3. Create your component file (e.g. components/NetworkPlacement.tsx)
# 4. Perform a pre-flight test against https://tradeimpression.com/v1/placement
Production endpoint: https://tradeimpression.com (Edge) · No API keys required for readsCLS Budget: 0.00 Guaranteed
CHAPTER 03·CLIENT & FRAMEWORK INTEGRATION

Client SDK & Component Pathways

Select your target stack. Every package automatically wraps MRC 1.0s dwell observation, click delegation, and zero-CLS height collapse.

// 1. Install packages
npm install @tradeimpression/react @tradeimpression/sdk

// 2. Mount component inside your layout or page shell
'use client';

import { TiPlacement } from '@tradeimpression/react';

export function SidebarPlacement() {
  return (
    <TiPlacement
      publisherId="pub_termscore"
      slot="sidebar"
      appContext="legal_saas"
      className="my-4 rounded-lg border border-stone-200"
    />
  );
}
Supports slots: sidebar, post_result, below_response, inline_tool, agent_turnBundle weight: 4.8 kB gzipped
Component & Web Component Properties
Property / AttributeTypeRequiredDescription
publisherId / publisher-idstringYesYour registered publisher key (e.g. pub_termscore).
slotstringYesApproved slot identifier: sidebar, post_result, below_response, inline_tool, agent_turn.
appContext / app-contextstringOptionalContextual taxonomy tags to boost clearing CPM (e.g. legal_saas, devtools).
messagesConversationMessage[]For chatPassed to <ConversationPlacement> for real-time contextual relevancy scoring.
onFill(fill: boolean) => voidOptionalCallback fired when placement resolution concludes.
CHAPTER 04·AI CODING AGENTS

Stdio MCP Protocol Tool Suite

When you connect @tradeimpression/mcp to Cursor Composer or Claude Code, your agent gains access to specialized autonomous tools.

Registered Stdio MCP Tools
Tool NameRoleParametersDescription
ti_check_placementPre-flight Probepublisher_id, slot, app_contextValidates slot eligibility, diagnoses unfilled auctions, and probes live edge fill before coding.
ti_validate_integrationVerificationfile_path, publisher_id, slotScans code changes to verify mandatory "Sponsored" disclosure, valid slot id, and zero CLS collapse.
ti_detect_stackEnvironment Scanworkspace_pathDetects Next.js, Vite, Remix, or static HTML in the target workspace.
ti_apply_reactFile Generatorpublisher_id, slot, app_contextGenerates ready-to-mount TiPlacement wrapper components.
ti_apply_patchAuto Patchertarget_file, slot, publisher_idDirectly patches layout or page files to mount placement components cleanly.
ti_audit_brandCompliance Auditcreative, themeAutomated contrast ratio (WCAG 2.1 AA) and brand safety validation.
ti_get_manifestManifest ReadernoneRetrieves live registry of verified publisher properties and allowed slots.
CHAPTER 05·AI & AGENT PLATFORMS

AI Chat & LLM Streaming Integration

Monetize generative AI agents and interactive chat interfaces without adding latency to the streaming token pipeline.

The Parallel Stream Execution Pattern

Never await an ad request before opening the LLM stream. Fire TradeImpression.getPlacements asynchronously alongside your streaming inference call. When token generation finishes, the placement promise is already fulfilled and ready to mount beneath the final assistant response.

app/api/chat/route.ts (Parallel Execution)
import { TradeImpression, trackPlacement } from '@tradeimpression/sdk';

const ti = new TradeImpression({ relevancy: 0.2 });

// 1. Fire ad resolution in parallel with LLM invocation
const adPromise = ti.getPlacements(
  'pub_rescriptum',
  messages,
  [{ slot: 'below_response', placement_id: 'chat_main' }],
  { sessionId: chatSession.id }
);

// 2. Stream tokens immediately to client without blocking
for await (const chunk of streamLLM(messages)) {
  controller.enqueue(chunk);
}

// 3. Await ad promise (already completed during token stream)
const { placements } = await adPromise;
if (placements[0]) {
  await trackPlacement(placements[0]);
  // Yield placement object to client UI
}
CHAPTER 06·HTTP SPECIFICATION

Edge & REST API Reference

Low-latency global endpoints deployed on Cloudflare Workers edge nodes.

GEThttps://tradeimpression.com/v1/placement
Latency: ~12ms

Resolves the highest-clearing contextual campaign for an approved publisher slot.

Query Parameters
publisher_id (string, required): Registered property ID (e.g. pub_termscore)
slot (string, required): Placement slot name (sidebar, post_result, below_response, inline_tool, agent_turn)
app_context (string, optional): Context keywords (e.g. legal_saas)
theme (string, optional): light or dark (default: light)
Response Payload (200 OK)
{
  "fill": true,
  "placement_id": "plc_9f82d1a4",
  "creative": {
    "headline": "Serverless Postgres with Zero Cold Starts",
    "body": "Branch your production database in under 500ms. Built for Next.js and Cloudflare Workers.",
    "cta_text": "Deploy Free Database",
    "cta_url": "https://tradeimpression.com/v1/event/click?c=cmp_neon&p=plc_9f82d1a4",
    "sponsor_name": "Neon",
    "sponsor_domain": "neon.tech",
    "badge_text": "Sponsored"
  },
  "tracking": {
    "impression_beacon": "https://tradeimpression.com/v1/event/impression?p=plc_9f82d1a4&c=cmp_neon",
    "viewability_required_dwell_ms": 1000,
    "viewability_threshold_percent": 0.5
  }
}
GEThttps://tradeimpression.com/v1/event/impression
Idempotent Beacon

Executes after client verifies 1.0 continuous second of 50% placement visibility. Cryptographically records billable impression in the publisher barter clearinghouse.

POSThttps://api.tradeimpression.com/v1/event/conversion
Attribution

Attributes downstream developer conversions (signups, CLI installs, account upgrades) to verified impressions.

POSThttps://api.tradeimpression.com/v1/creative/validate
WCAG Guardrails

Automated contrast ratio validation verifying minimum 4.5:1 body text contrast and 3:1 button contrast before clearing creatives.

CHAPTER 07·UI & LAYOUT STABILITY

Slot Specifications & Zero-CLS Guarantee

Every Trade Impression component enforces strict UX standards. Unfilled auctions instantly collapse with zero cumulative layout shift.

sidebarDesktop Companion

Designed for persistent application sidebars, navigation drawers, and secondary panels. Max width 320px.

post_resultAction Completion

Appears inline directly beneath successful API tests, code executions, or audit reports.

below_responseConversational AI

Positioned beneath streaming AI completions and agent answers. Unobtrusive horizontal card.

inline_toolDeveloper Tooling

Integrated directly into playground panes, query consoles, and terminal shells.

agent_turnAgent Pipelines

Embedded cleanly between sequential autonomous agent actions and subagent tool dispatches.

header_banner / footerShell Placements

High-visibility contextual placements in developer portal headers and footer zones.

CHAPTER 08·ECONOMICS & CLEARING

Barter Clearinghouse & Credit Ledger

Convert impressions into cross-promotional developer attention or hybrid cash payouts without middleman ad exchange taxes.

MINT RATE
80%

80 of every 100 hosted impressions mint Attention Credits for the publisher.

NETWORK RESERVE
20%

20% reserve pool provides immediate demand liquidity for cash advertisers.

SETTLEMENT UNIT
1 Credit ≈ 1 View

1 credit guarantees 1 verified MRC-dwell impression on peer software products.

CHAPTER 09·GOVERNANCE

MRC Viewability, Brand Safety & Privacy

Strict programmatic compliance guarantees for publishers and sponsors.

MRC 1.0-Second Dwell Verification

Zero phantom impressions. Beacons execute only after 50% of pixel surface area dwells in the active browser viewport for at least 1.0 continuous second. Background tabs pause immediately.

Zero Cookie Dependencies (GDPR/ePrivacy)

Trade Impression stores zero cookies in user browsers, collects no PII, and operates entirely on contextual signals passed by the host application. No cookie consent banners required.

Mandatory "Sponsored" Disclosure

Every creative includes clear disclosure identifying the sponsor domain. Preserves host developer trust and complies with FTC and European consumer protection directives.

Publisher Competitor Blacklists

Publishers maintain full sovereignty over which sponsors appear on their properties. Block direct competitors or untrusted domains directly in the Publisher Console.

DEPLOYMENT READY

Ready to wire your first placement?

Run npx @tradeimpression/setup in your project repository or claim your publisher ID in the console.