Klient publiczny
Kiedy używać klienta publicznego
Section titled “Kiedy używać klienta publicznego”createTipplyPublicClient() jest właściwym wyborem, gdy chcesz:
- czytać widget celu użytkownika
- pobierać publiczną konfigurację
TIPS_GOAL - pobierać publiczne szablony
TIPS_GOALiGOAL_VOTING - pobierać CSS z template fonts
- odczytywać
widgetMessage - uruchomić listener
TIP_ALERTbez sesji auth
Utworzenie klienta
Section titled “Utworzenie klienta”import { createTipplyPublicClient } from "tipply-sdk-ts/public";
const client = createTipplyPublicClient();Praca w scope użytkownika
Section titled “Praca w scope użytkownika”Większość publicznych endpointów działa w scope user(userId).
import { asGoalId, asUserId } from "tipply-sdk-ts";import { createTipplyPublicClient } from "tipply-sdk-ts/public";
const client = createTipplyPublicClient();const user = client.user(asUserId("user-123"));
const goalsTemplates = await user.goals.templates.list();const goalsConfiguration = await user.goals.configuration.get();const goalWidget = await user.goals.id(asGoalId("goal-123")).widget.get();const votingTemplates = await user.voting.templates.list();const votingConfiguration = await user.voting.configuration.get();const templateFontsCss = await user.templateFonts.get();const widgetMessageEnabled = await user.widgetMessage.get();Co zwraca klient publiczny
Section titled “Co zwraca klient publiczny”goals.templates.list()
Section titled “goals.templates.list()”Lista publicznych szablonów typu TIPS_GOAL.
goals.configuration.get()
Section titled “goals.configuration.get()”Publiczna konfiguracja widgetu celu użytkownika.
goals.id(goalId).widget.get()
Section titled “goals.id(goalId).widget.get()”Widok konkretnego widgetu celu.
voting.templates.list()
Section titled “voting.templates.list()”Lista publicznych szablonów GOAL_VOTING.
voting.configuration.get()
Section titled “voting.configuration.get()”Konfiguracja publicznego votingu.
templateFonts.get()
Section titled “templateFonts.get()”Surowy CSS jako string.
widgetMessage.get()
Section titled “widgetMessage.get()”Flaga boolean określająca dostępność widget message.
Publiczne social linki profilu
Section titled “Publiczne social linki profilu”To wywołanie jest wystawione na auth kliencie, ale korzysta z publicznego proxy endpointu:
import { createTipplyClient } from "tipply-sdk-ts";
const client = createTipplyClient({ authCookie: process.env.TIPPLY_AUTH_COOKIE!,});
const socialLinks = await client.profile.public("streamer-link").socialLinks.list();TIP_ALERT bez auth tokena
Section titled “TIP_ALERT bez auth tokena”Jeżeli znasz userId, możesz utworzyć listener bezpośrednio:
const listener = client.user(asUserId("user-123")).tipAlerts.createListener();Jeżeli znasz tylko widget URL, SDK wyciągnie userId samo:
const listener = client.tipAlerts.fromWidgetUrl( "https://widgets.tipply.pl/TIP_ALERT/user-123",);Szczegóły eventów i lifecycle listenera są w Realtime Tip Alerts.