Adsourcer Developer
Quickstart
Add sponsored recommendations to an AI app in four steps.
Markdown for agents · llms-full.txt
1. Get an API key
Publishers need an API key with the publisher tenant type. Advertisers can sign up in the dashboard to receive advertiser-scoped keys.
2. Install the SDK
bash
npm install @adsourcer/sdk# orpip install adsourcerPrefer REST? Skip the SDK and call endpoints directly — see the API reference.
3. Request recommendations
TypeScript
typescript
import { Adsourcer } from "@adsourcer/sdk"; const client = new Adsourcer({ apiKey: process.env.ADSOURCER_API_KEY! }); const result = await client.ads.recommend({ query: userMessage, context: { currency: "EUR", location: "NO", session_id: sessionId }, max_results: 3,}); if (result.decision === "SHOW") { for (const ad of result.ads) { // Render ad.title, ad.price, ad.disclosure // Link CTA to ad.click_url }}4. Disclose and track
Every ad includes sponsored: true and a disclosure string. Display these labels in your UI — they are required.
Use click_url as the href on ad links. Adsourcer records the click and redirects to the advertiser destination. Optionally fire impression events when ads are rendered.
Privacy
Use anonymous session IDs. Do not send PII in context fields or event payloads.