Skip to main content

    Get data out of Klaviyo with APIs

    Course overview
    Lesson
    2 min read

    Export data using APIs

    Export, manipulate, and analyze data from Klaviyo using our server-side APIs.

    Explore use cases for exporting data from Klaviyo

    For many businesses, Klaviyo is the central customer source-of-truth that holds a huge amount of valuable information. You can pull this data out of Klaviyo using the REST APIs available for each data object. Read through the dropdowns for some example use cases of exporting data from Klaviyo.

    Display dynamic content based on profile data

    Scenario: You’re building an app experience for a brand, and you want to display a certain set of content on the homepage to people who are members of the VIP program. To achieve this, you need to extract the VIP status from the user’s Klaviyo profile so you can determine which content to display. You can use the Get Profile API to pull the Klaviyo profile using the Klaviyo Person ID, and the JSON response will contain the necessary VIP status profile property that you’re looking for.

    See example code.

    Monitor email bounces

    Scenario: You want to monitor deliverability metrics, which requires monitoring of email bounces. You can use the Get Event API to pull all Bounced Email events using the Bounced Email metric ID.

    See example code.

    Integrate Klaviyo with a data warehouse

    Scenario: You want to extract data out of Klaviyo and pull it into a data warehouse or another internal system. For details on how to integrate with a data warehouse, follow the steps in this guide.

    Understand the structure of data returned from APIs

    Use a GET call to return a JSON object with all fields of that specified data set. Let’s look at an example cURL request to retrieve a list of each unique metric observed in the account via the Get Metrics endpoint:

    plaintext
    curl --request GET --url https://a.klaviyo.com/api/metrics/
    --header 'revision: {latest revision header}'
    --header 'Accept: application/vnd.api+json'
    --header 'Authorization: Klaviyo-API-Key {your private API Key}'

    The GET call returns all of the fields for each of the three unique metrics present in this account. The resulting JSON looks like this:

    javascript
    {
        "data": [
            {
                "type": "metric",
                "id": "KxhW33",
                "attributes": {
                    "name": "Clicked Email",
                    "created": "2020-01-28T13:33:15+00:00",
                    "updated": "2020-01-28T13:33:15+00:00",
                    "integration": {
                        "object": "integration",
                        "id": "0rG4eQ",
                        "name": "Klaviyo",
                        "category": "Internal"
                    }
                },
                "links": {
                    "self": "https://a.klaviyo.com/api/metrics/KxhW33/"
                }
            },
            {
                "type": "metric",
                "id": "JUzjai",
                "attributes": {
                    "name": "Added to Cart",
                    "created": "2020-01-29T13:19:30+00:00",
                    "updated": "2021-08-27T08:41:10+00:00",
                    "integration": {
                        "object": "integration",
                        "id": "7FtS4J",
                        "name": "API",
                        "category": "API"
                    }
                },
                "links": {
                    "self": "https://a.klaviyo.com/api/metrics/JUzjai/"
                }
            },
            {
                "type": "metric",
                "id": "XNJ6uB",
                "attributes": {
                    "name": "Placed Order",
                    "created": "2023-04-19T03:01:44+00:00",
                    "updated": "2023-04-19T03:01:44+00:00",
                    "integration": {
                        "object": "integration",
                        "id": "7FtS4J",
                        "name": "Shopify",
                        "category": "eCommerce"
                    }
                },
                "links": {
                    "self": "https://a.klaviyo.com/api/metrics/XNJ6uB/"
                }
            }
          ]
    }
    Export data using APIs