AbsoluteJS

Audience Audiense Adapter

@absolutejs/audience-audiensev0.0.1betaCommerce & Growth

Audiense adapter for @absolutejs/audience — implements the AudienceSource contract against the Audiense Insights API (reports, demographics, affinities, influencers, audience overlap). The premium social-graph backfill for AbsoluteJS audience intelligence.

#Installation

BASH
bun add @absolutejs/audience-audiense @absolutejs/audience

#Capabilities

Overview

Audiense adapter for @absolutejs/audience. Implements the AudienceSource contract against the Audiense Insights API — reports, demographics, influencer/brand affinities, and audience overlap — so an AbsoluteJS app can use measured audience intelligence wherever it otherwise derives it (e.g. the Trust & Fit / OPA audience-overlap signal).

This is the premium social-graph backfill: the parts of audience intelligence you can't derive yourself (Audiense's proprietary follower/affinity graph), behind the same interface as the own-it primitives.

Use

Every method is optional on AudienceSource, so consumers feature-detect:

Auth

Client-credentials OAuth: POST {baseUrl}/login/token with Authorization: Basic base64(clientId:clientSecret) and grant_type=client_credentials. The returned bearer token is cached until just before it expires. Get credentials from your Audiense account (or your Audiense data-partnership contact).

Config

Field — Default — Notes

clientId / clientSecret — — — Audiense API credentials (required).

baseUrl — https://api.audiense.com/v1 — Override for a partnership/sandbox feed.

Show 3 more

defaultBaselineId — — — Baseline audience to compare affinities against; override per call via a ref's meta.baselineId.

fetch — global fetch — Inject for tests / custom runtimes.

now — Date.now — Inject a clock for tests.

Overlap

Audiense exposes no two-audience intersection endpoint at the API tier this adapter targets (it's a UI report), so overlap is computed from shared affinities (affinityItemsOverlap from @absolutejs/audience — a weighted cosine over the two affinity graphs, plus the shared items). If your data partnership grants a native intersection endpoint, swap it in at the overlap implementation.

Field-mapping note

Response shapes are modeled from Audiense's own official client (audienseco/mcp-audiense-insights). A few field names weren't public, so the types are tolerant and the mappers degrade gracefully when a field is absent. Confirm exact field names against the live API (or your partnership feed) — the mappers are centralized in src/index.ts.

Outcomes

What you can build

Overview

Audiense adapter for @absolutejs/audience. Implements the AudienceSource contract against the Audiense Insights API — reports, demographics, influencer/brand affinities, and audience overlap — so an AbsoluteJS app can use measured audience intelligence wherever it otherwise derives it (e.g. the Trust & Fit / OPA audience-overlap signal).

Use

Every method is optional on AudienceSource, so consumers feature-detect:

Auth

Client-credentials OAuth: POST {baseUrl}/login/token with Authorization: Basic base64(clientId:clientSecret) and grant_type=client_credentials. The returned bearer token is cached until just before it expires. Get credentials from your Audiense account (or your Audiense data-partnership contact).

Hardening checklist

Production guidance

Make every external boundary explicitPin the deployed @absolutejs/audience-audiense version, replace example or memory-backed dependencies with durable implementations, bound external calls, protect credentials, and emit enough evidence to retry or recover safely.

Follow in order

Troubleshooting path

1
Trace from the first failed boundary
Reproduce the smallest canonical @absolutejs/audience-audiense example, confirm the supported entry point and version in the API explorer, then inspect the first boundary that did not produce its documented result.

#Use

Partial snippet

Working example for Use.

TS
import { audienseSource } from "@absolutejs/audience-audiense";

const audience = audienseSource({
  clientId: process.env.AUDIENSE_CLIENT_ID!,
  clientSecret: process.env.AUDIENSE_CLIENT_SECRET!,
  defaultBaselineId: process.env.AUDIENSE_BASELINE_ID, // baseline to compare affinities against
});

const reports = await audience.listAudiences?.();
const profile = await audience.getAudience?.(reports![0]);   // size, segments, demographics, affinities
const overlap = await audience.overlap?.(reportA, reportB);  // { score, sharedAffinities, method }

#Use 2

Partial snippet

Every method is optional on AudienceSource, so consumers feature-detect:

TS
const score = audience.overlap
  ? (await audience.overlap(a, b)).score   // measured, from Audiense
  : affinityOverlap(profA, profB).score;   // derived fallback (@absolutejs/audience)

#Package commands

Scripts declared by this project’s package manifest.

bun run buildrm -rf dist && bun build src/index.ts --outdir dist --target=bun --external @absolutejs/audience && tsc --emitDeclarationOnly --project tsconfig.json
bun run testbun test
bun run typechecktsc --noEmit