klaviyo-sdk-patterns

Featured

Apply production-ready Klaviyo SDK patterns for the klaviyo-api package. Use when implementing Klaviyo integrations, refactoring SDK usage, or establishing team coding standards for Klaviyo API calls. Trigger with phrases like "klaviyo SDK patterns", "klaviyo best practices", "klaviyo code patterns", "idiomatic klaviyo", "klaviyo wrapper".

AI & Automation 2,926 stars 433 forks Updated yesterday MIT

Install

View on GitHub

Quality Score: 99/100

Stars 20%
100
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Klaviyo SDK Patterns ## Overview Production-ready patterns for the `klaviyo-api` Node.js SDK: singleton sessions, type-safe wrappers, retry logic, pagination, and multi-tenant support. ## Prerequisites - `klaviyo-api` package installed - Completed `klaviyo-install-auth` setup - TypeScript project with strict mode ## Instructions ### Step 1: Singleton Session Pattern ```typescript // src/klaviyo/session.ts import { ApiKeySession } from 'klaviyo-api'; let _session: ApiKeySession | null = null; export function getSession(apiKey?: string): ApiKeySession { if (!_session) { const key = apiKey || process.env.KLAVIYO_PRIVATE_KEY; if (!key) throw new Error('KLAVIYO_PRIVATE_KEY is required'); _session = new ApiKeySession(key); } return _session; } // For testing: reset the singleton export function resetSession(): void { _session = null; } ``` ### Step 2: Type-Safe API Wrapper ```typescript // src/klaviyo/api.ts import { ApiKeySession, ProfilesApi, EventsApi, ListsApi, SegmentsApi, CampaignsApi, FlowsApi, MetricsApi, TemplatesApi, CatalogsApi, DataPrivacyApi, WebhooksApi, } from 'klaviyo-api'; import { getSession } from './session'; // Lazy-initialized API clients -- avoids creating unused clients const apis = { get profiles() { return new ProfilesApi(getSession()); }, get events() { return new EventsApi(getSession()); }, get lists() { return new ListsApi(getSession()); }, get segments() { return new SegmentsApi(getSess...

Details

Author
jeremylongshore
Repository
jeremylongshore/claude-code-plugins-plus-skills
Created
1 years ago
Last Updated
yesterday
Language
Python
License
MIT

Integrates with

Bundled in these plugins

Similar Skills

Semantically similar based on skill content — not just same category