# Export data from Klaviyo

Learn how to export data from Klaviyo, including how to integrate Klaviyo with a data warehouse.

\##Data objects

When understanding how to export data from Klaviyo and sync it into another system, it helps to first understand Klaviyo’s [data model](https://developers.klaviyo.com/en/v1-2/docs/introduction-to-klaviyos-data-model) (i.e., what data Klaviyo collects and how it’s organized). 

Metrics, as the key data object representing a given person’s activity and engagement with your brand and messaging, are the most commonly requested data objects to export from Klaviyo. Metrics are actions represented as timestamped records that include JSON-formatted payloads that can contain an unlimited quantity of key-value pairs, including arrays and further-nested JSON. Klaviyo automatically records Metrics for email, push, and SMS-related activity such as "Received Email", "Opened Email", "Clicked Email", and more. Some other common objects that may be exported include Profiles, Lists, and Unsubscribes.

\##Exporting data

You can find a complete list of our available APIs for exporting Klaviyo data on our API docs. Here are some of our more frequently used export APIs:

* [**Get Metrics Info**](https://developers.klaviyo.com/en/reference/get-metrics)
  Returns a list of all the metrics in your account.

* [**Get Events for All Metrics**](https://developers.klaviyo.com/en/reference/metrics-timeline)
  Returns a batched timeline of all events in your account.

* [**Get Events for a Specific Metric**](https://developers.klaviyo.com/en/reference/metric-timeline)
  Returns a batched timeline for one specific metric.

* [**Query Event Data**](https://developers.klaviyo.com/en/reference/metric-export)
  Exports aggregate counts of event data from Klaviyo, optionally filtering and segmenting on available event properties.

* [**Get Profile**](https://developers.klaviyo.com/en/reference/get-profile)
  Retrieves all the profile properties for a profile, using the Klaviyo Person ID.

* [**Get Profile’s Events for All Metrics**](https://developers.klaviyo.com/en/reference/profile-metrics-timeline)
  Returns a batched timeline of all events for a person.

* [**Get Profile’s Events for a Specific Metric**](https://developers.klaviyo.com/en/reference/profile-metric-timeline)
  Returns a batched timeline of all events for one specific Metric for a given person.

* [**Get Lists**](https://developers.klaviyo.com/en/reference/get-lists)
  Returns a listing of all of the lists in an account.

* [**Get List Info**](https://developers.klaviyo.com/en/reference/get-list-info)
  Returns information about a list.

* [**Get Global Exclusions and Unsubscribes**](https://developers.klaviyo.com/en/reference/get-global-exclusions)
  Returns global exclusions/unsubscribes.

* [**Get All Exclusions for a List**](https://developers.klaviyo.com/en/reference/get-list-exclusions)
  Gets all of the identifiers (eg. emails, and phone numbers) for profiles that have been excluded from a list.

* [**Get List and Segment Members**](https://developers.klaviyo.com/en/reference/get-members)
  Gets all of the identifiers (eg. emails, phone numbers), and push tokens for profiles in a given list or segment.

* [**Get Campaigns**](https://developers.klaviyo.com/en/reference/get-campaigns)
  Returns a list of all the campaigns you've created.

* [**Get Campaign Info**](https://developers.klaviyo.com/en/reference/get-campaign-info)
  Returns summary information for the campaign specified.

* [**Get Campaign Recipients**](https://developers.klaviyo.com/en/reference/get-campaign-recipients)
  Returns summary information about email recipients for the campaign specified.

* [**Get All Templates**](https://developers.klaviyo.com/en/reference/get-templates)
  Returns a list of all the email templates you've created.

\##Example: how to export data

Klaviyo exposes data for export through REST APIs associated with these data objects. You can use these to extract information, optionally using parameters to refine the information returned. As an example, a simple curl request to retrieve a list of each unique metric observed in the account via the Klaviyo Metrics API would look like this:

[block:code]
{
  "codes": [
    {
      "code": "curl https://a.klaviyo.com/api/v1/metrics -G \\\n  -d api_key=api_key",
      "language": "curl"
    }
  ]
}
[/block]

The GET call returns a JSON object with all the fields of the specified dataset as a reply. In this illustrative example, the account has two unique metrics. The resulting JSON might look like:

[block:code]
{
  "codes": [
    {
      "code": "{\n  \"end\": 2,\n  \"object\": \"$list\",\n  \"page_size\": 50,\n  \"start\": 0,\n  \"total\": 3,\n  \"data\": [\n    {\n      \"updated\": \"2019-02-05 17:31:37\",\n      \"name\": \"Active on Site\",\n      \"created\": \"2019-02-05 17:31:37\",\n      \"object\": \"metric\",\n      \"id\": \"H7wi5R\",\n      \"integration\": {\n        \"category\": \"API\",\n        \"object\": \"integration\",\n        \"id\": \"7FtS4J\",\n        \"name\": \"API\"\n      }\n    },\n    {\n      \"updated\": \"2019-02-05 17:31:37\",\n      \"name\": \"Viewed Product\",\n      \"created\": \"2019-02-05 17:31:37\",\n      \"object\": \"metric\",\n      \"id\": \"JgV8XH\",\n      \"integration\": {\n        \"category\": \"API\",\n        \"object\": \"integration\",\n        \"id\": \"7FtS4J\",\n        \"name\": \"API\"\n      }\n    },\n    {\n      \"updated\": \"2019-10-01 02:57:11\",\n      \"name\": \"Received Email\",\n      \"created\": \"2019-10-01 02:57:11\",\n      \"object\": \"metric\",\n      \"id\": \"QhG7U2\",\n      \"integration\": {\n        \"category\": \"Internal\",\n        \"object\": \"integration\",\n        \"id\": \"0rG4eQ\",\n        \"name\": \"Klaviyo\"\n      }\n    }\n  ]\n}",
      "language": "json"
    }
  ]
}
[/block]

\##Use case: integrating Klaviyo with a data warehouse

If you’d like to extract data from Klaviyo to a data warehouse or internal system, the general integration process is as follows:

[block:parameters]
{
  "data": {
    "h-0": "Step",
    "h-1": "Description",
    "0-0": "**Specify data to extract**",
    "0-1": "Document the data objects and any filtering criteria that you want to apply when extracting the data. For example, if you are interested in syncing Klaviyo-originated metrics into another system, it would look like:\n_Data objects_: Metrics\n_Filtering criteria_: All Metrics where “integration.name” equals “Klaviyo”",
    "1-0": "**Test and validate API requests**",
    "1-1": "After documenting the data to extract, we recommend identifying the Klaviyo API endpoints that return the desired data and using [Klaviyo’s sample API requests](https://developers.klaviyo.com/en/v1-2/docs/get-metrics) to fetch and validate the data, then define the logical steps for automation. Using the example above, it might look like this:\n_Step 1_: GET request to `https://a.klaviyo.com/api/v1/metrics` in order to get a list of all unique metrics.\n_Step 2_: GET request to `https://a.klaviyo.com/api/v1/metric/{metric\\_id}/export` for each metric\\_id of interest",
    "2-0": "**Map source data to destination**",
    "2-1": "Once you know the data that you want to extract and how to extract it, you must map Klaviyo’s data structure into your data warehouse or other internal system. Klaviyo’s APIs return JSON formatted data, so if your warehouse or other business system requires another format, you may need to manipulate the output to conform to destination expectations.",
    "3-0": "**Build ETL (or use a pre-built connector)**",
    "3-1": "Once you have the specifications for extracting data and mapping it to your target destination, the next step is to author the code that will automate the extract, transfer, and load (ETL) logic. You may benefit from using an open-source tool such as a <a href=\"https://github.com/singer-io/tap-klaviyo\" target=\"_blank\">Singer tap</a> to achieve this.\nIf you prefer to avoid this step, you may opt for a tool with a <a href=\"https://connect.klaviyo.com/integrations\" target=\"_blank\">pre-built Klaviyo integration</a> such as Segment.com, Stitch Data, or Fivetran.",
    "4-0": "**Perform QA**",
    "4-1": "After automating the ETL, you will want to validate that data flows through as expected."
  },
  "cols": 2,
  "rows": 5
}
[/block]

\##Additional resources

* [Use data in Klaviyo](https://developers.klaviyo.com/en/v1-2/docs/using-data-in-klaviyo)
* [Custom integration FAQs](https://developers.klaviyo.com/en/v1-2/docs/custom-integration-faqs)