{"id":48354,"library":"klaviyo-api-fetch","title":"klaviyo-api-fetch","description":"Klaviyo API client built on native fetch using hey-api codegen. Version 1.1.0 generates TypeScript types and SDK functions from Klaviyo's OpenAPI spec. It provides a lightweight, tree-shakable alternative to the official Klaviyo SDK, leveraging browser-native fetch for reduced bundle size and compatibility with modern JS environments. The package is auto-generated and released via npm with no standalone dependencies.","status":"active","version":"1.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/clgeoio/klaviyo-fetch","tags":["javascript","klaviyo","typescript"],"install":[{"cmd":"npm install klaviyo-api-fetch","lang":"bash","label":"npm"},{"cmd":"yarn add klaviyo-api-fetch","lang":"bash","label":"yarn"},{"cmd":"pnpm add klaviyo-api-fetch","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM-only package; CommonJS require will fail.","wrong":"const { getEvents } = require('klaviyo-api-fetch')","symbol":"getEvents","correct":"import { getEvents } from 'klaviyo-api-fetch'"},{"note":"All API functions follow this pattern; check OpenAPI spec for exact operation names.","symbol":"createOrder","correct":"import { createOrder } from 'klaviyo-api-fetch'"},{"note":"Client type is exported as a TypeScript type, not a runtime value.","wrong":"import { Client } from 'klaviyo-api-fetch'","symbol":"Client","correct":"import type { Client } from 'klaviyo-api-fetch'"}],"quickstart":{"code":"import { getEvents } from 'klaviyo-api-fetch';\n\nconst apiKey = process.env.KLAVIYO_API_KEY ?? '';\nconst eventsRes = await getEvents({\n  headers: {\n    Authorization: `Klaviyo-API-Key ${apiKey}`,\n    revision: '2025-01-15',\n  },\n  query: {\n    'page[cursor]': undefined,\n    sort: '-datetime',\n    filter: undefined,\n    include: ['metric', 'profile'],\n    'fields[metric]': ['name'],\n    'fields[event]': ['datetime', 'timestamp', 'event_properties'],\n    'fields[profile]': ['email', 'first_name', 'last_name', 'phone_number'],\n  },\n});\nif (eventsRes.error) {\n  console.error(eventsRes.error);\n} else {\n  console.log(eventsRes.data);\n}","lang":"typescript","description":"Fetch events from Klaviyo API using native fetch with required auth headers and pagination fields."},"warnings":[{"fix":"Set 'revision' header to the appropriate API version date as documented in Klaviyo API changelog.","message":"All operations require the 'revision' header with a specific date string (e.g., '2025-01-15'). Missing or incorrect revision header results in a 400 error.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use import syntax or dynamic import() instead.","message":"The package is ESM-only. Using require() will throw: ERR_REQUIRE_ESM.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Migrate from positional arguments to options object: e.g., client.getEvents({...}) instead of getEvents(headers, query, ...).","message":"In version 1.0.0, the function signatures used positional arguments. Version 1.1.0 changed to a single options object parameter.","severity":"breaking","affected_versions":"<1.1.0"},{"fix":"Use 'event_properties' only if necessary; prefer 'properties' field for future compatibility.","message":"The 'fields[event]' parameter uses event_properties field which is deprecated as of Klaviyo API revision 2025-01-15.","severity":"deprecated","affected_versions":">=1.1.0"}],"env_vars":null,"search_vec":"'1.1.0':18 'altern':37 'api':3,6,15 'auto':62 'auto-gener':61 'browser':45 'browser-n':44 'built':8 'bundl':50 'client':7 'codegen':16 'compat':53 'depend':71 'environ':57 'fetch':4,11,47 'function':24 'generat':19,63 'hey':14 'hey-api':13 'javascript':72 'js':56 'klaviyo':2,5,26,41,73 'klaviyo-api-fetch':1 'leverag':43 'lightweight':33 'modern':55 'nativ':10,46 'npm':67 'offici':40 'openapi':28 'packag':59 'provid':31 'reduc':49 'releas':65 'sdk':23,42 'shakabl':36 'size':51 'spec':29 'standalon':70 'tree':35 'tree-shak':34 'type':21 'typescript':20,74 'use':12 'version':17 'via':66","created_at":"2026-06-07T16:56:13.284115+00:00","updated_at":"2026-06-07T16:56:13.284115+00:00","problems":[{"fix":"Change const { getEvents } = require('klaviyo-api-fetch'); to import { getEvents } from 'klaviyo-api-fetch';","cause":"Using CommonJS require() on an ESM-only package.","error":"TypeError: Cannot destructure property 'getEvents' of 'klaviyo-api-fetch' as it is undefined."},{"fix":"Add 'revision' header with a valid Klaviyo API revision date (e.g., '2025-01-15').","cause":"The 'revision' header was not provided in the request options.","error":"Error: Missing required header: revision"},{"fix":"Check the Klaviyo API documentation for correct parameter names and formats. Ensure all required fields are included.","cause":"Common issue: missing or malformed query parameters, incorrect filter syntax, or wrong header values.","error":"Response status: 400 - Invalid request"},{"fix":"Use Node.js 18+ or install a fetch polyfill like 'node-fetch'.","cause":"The runtime environment does not support native fetch (e.g., older Node.js versions).","error":"TypeError: fetch is not defined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/clgeoio/klaviyo-fetch#readme","github":"https://github.com/clgeoio/klaviyo-fetch","docs":null,"changelog":null,"pypi":null,"npm":"klaviyo-api-fetch","openapi_spec":null,"status_page":null,"smithery":null,"categories":["communication"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}