Make API Calls to Klaviyo
Once you've generated your API Key, you can start making programmatic calls to your account. Klaviyo provides a comprehensive API Reference guide and Open API spec to the available resources. The API guide outlines all of the available endpoints for access to Lists, Segments, Metrics and more. It all starts with the base API URL. We'll plug this into our ENV and then build calls from there. The base Klavyio API URL is:
https://a.klaviyo.com/api
The Klaviyo API uses a versioning system to ensure backward compatibility. The API versions are concatenated into the base API endpoints so a versioned URL would look like this:
https://a.klaviyo.com/api/v1
If you want to utilize the new version of the API, then simply change the version number like this:
https://a.klaviyo.com/api/v2
Using the developer guide, we can now utilize any of the available endpoints to query data. For example, if we want a listing of all our email lists in Klaviyo, we can perform a direct query to the List endpoint and receive the JSON results. Let's use Postman to demonstrate how this works: