Installation
Add the script tag to your page. Pass your channel API key as a query parameter:window.AIARCO object with all SDK methods. The SDK is lightweight (~4KB) and has no external dependencies.
Quick Start
Render a single ad in a container:API Reference
AIARCO.fetchAd(opts)
Fetch offers from the API. Returns a Promise resolving to the full API response.
| Option | Type | Description |
|---|---|---|
query | string | User’s search query or intent text. |
context | string | Page context or category. |
limit | number | Number of ads to fetch (1–8, default 1). |
userId | string | Stable user identifier (not PII). |
sessionId | string | Session identifier. |
signals | Signal[] | Typed intent signals. |
AIARCO.renderAd(containerId, opts)
Fetch and render a single ad into a DOM element. Automatically sets up IntersectionObserver for viewability tracking.
AIARCO.renderAds(containerId, opts)
Fetch and render multiple ads into a container. Defaults to 3 ads.
AIARCO.trackImpressions(ids)
Manually track impression viewability for one or more offer IDs. This is handled automatically by renderAd and renderAds via IntersectionObserver, but can be called directly for custom rendering.
AIARCO.getSystemPromptOffers(opts)
Fetch offers and return a serialized XML string for injection into an LLM system prompt. See Woven Offers for the complete guide.
AIARCO.trackWovenImpressions(ids)
Track which woven offer IDs appeared in the rendered LLM response. Only call for offers whose clickUrl was included in the rendered text.
Configuration
The SDK auto-configures from the script tag URL parameters:| Parameter | Description |
|---|---|
api_key | Your channel API key (required). |
placement | Default ad placement type (default: sponsored_result). |
Automatic Features
- Viewability tracking — when using
renderAdorrenderAds, the SDK automatically tracks when ads are visible to the user. - Device detection — automatically detects device type and sends it with each request.
- Locale detection — detects the user’s locale automatically.
- Deduplication — each impression is only tracked once.
Need server-side integration?
Use the REST API for full control over ad fetching and rendering from your
backend.