Documentation Index
Fetch the complete documentation index at: https://docs.topsort.com/llms.txt
Use this file to discover all available pages before exploring further.
Das JavaScript SDK von Topsort ist die offizielle Client-Bibliothek zur Integration mit den Auktions- und Ereignisverfolgung-APIs von Topsort. In TypeScript entwickelt, vereinfacht dieses SDK die Integration und ermöglicht die Erstellung eines End-to-End-Workflows in wenigen Minuten.
Installation
<script
async
type="module"
src="https://unpkg.com/@topsort/sdk@latest/dist/index.mjs"
></script>
<script>
window.TS = {
token: "TSE_XXXXXXXXXXXX", // Ersetzen Sie dies durch Ihren Topsort API-Schlüssel
};
</script>
Erstellen einer Auktion
import { TopsortClient } from "https://unpkg.com/@topsort/sdk@latest/dist/index.mjs";
const topsortClient = new TopsortClient({ apiKey: window.TS.token });
const auctionDetails = {
auctions: [
{
type: "listings",
slots: 3,
searchQuery: "winter",
},
{
type: "banners",
slots: 1,
device: "desktop",
slotId: "slot123",
},
],
};
topsortClient
.createAuction(auctionDetails)
.then((result) => console.log("Auktionsergebnis", result))
.catch((error) => console.error("Auktionsfehler", error));
Ereignismeldung
const winners = auctionResult.results.flatMap((result) => result.winners || []);
if (winners.length > 0) {
const impressions = winners.map((winner) => ({
resolvedBidId: winner.resolvedBidId,
id: crypto.randomUUID(),
occurredAt: new Date().toISOString(),
opaqueUserId: crypto.randomUUID(),
placement: { path: "/search/winter" },
}));
topsortClient
.reportEvent({ impressions })
.then((result) => console.log("Ereignisergebnis", result))
.catch((error) => console.error("Ereignisfehler", error));
}
Wiederholbare Fehler
Die Funktion reportEvent gibt retry: true für 429- oder 5xx-Fehler zurück:
topsortClient.reportEvent(eventPayload).then((result) => {
if (result.retry) {
console.warn("Vorübergehender Fehler. Aufruf wiederholen.");
}
});
Für die vollständige Dokumentation und End-to-End-Beispiele besuchen Sie das GitHub-Repository.