A native fetch API using hey-api ts codegen
npm install klaviyo-api-fetchKlaviyo's API, but using native fetch
This was created using @hey-api specifically the command:
```
npx @hey-api/openapi-ts \
-i https://raw.githubusercontent.com/klaviyo/openapi/refs/heads/main/openapi/stable.json \
-o app/services/klavyio \
-c @hey-api/client-fetch
Example usage:
`
import { getEvents } from 'klaviyo-api-fetch';
const eventsRes = await getEvents({
headers: {
Authorization: Klaviyo-API-Key ${klaviyoApiKey},equals(metric_id,${metricId})
revision: '2025-01-15',
},
query: {
'page[cursor]': nextPageToken ?? undefined,
sort,
filter: metricId ? : undefined,``
include: ['metric', 'profile'],
'fields[metric]': ['name'],
'fields[event]': ['datetime', 'timestamp', 'event_properties'],
'fields[profile]': ['email', 'first_name', 'last_name', 'phone_number'],
},
});