Overview
Kapiche provides an Export API that allows you to programmatically fetch enriched data directly from Kapiche for use in your own data warehouse and backend systems.
The API is provided over HTTPS endpoints and is available via an allow list per customer.
At the current time, there is one export data schema available: document-queries.
Requirements
To make use of the API, two steps are necessary:
An access token must be created.
The API must be enabled for a specific analysis within the Kapiche product. Each analysis will have a different base URL (explained further below).
With those two steps completed, an HTTPS API call can now be made to the Kapiche API server to obtain export data.
Optional: Specific IP Address prefixes can be added to an allow-list to improve security even further. If your API calls will always be made from a specific IP Address, that IP address, or a common prefix of a range of IP addresses, can be configured.
NOTE: Only an Admin user can complete the steps mentioned above.
In the sections that follow, each of these requirements will be described in more detail.
Quickstart - Code Example
Let’s assume that the site name of your site is acme. This can be found by looking at your URL in Kapiche once you have logged in to the product:
https://app.kapiche.com/acme/projects/7914/details
In the above URL, the site name is acme. Secondly, your Kapiche Admin must obtain a token. For this code example, assume for now that the token is xxx. Finally, when the Export API is enabled on a particular analysis, a base URL for that analysis will be created.
Given those 3 pieces of information, an API call can be made like this, for example using curl:
$ curl \
-H "Site-Name: acme" \
-H "Content-Type: application/json" \
-H "Authorization: Site xxx" \
-X GET \
https://api.kapiche.com/export/<uuid>/document-queries/?start_document_id=1&docs_count=1000&export_format=csv
In the call above,
the base URL for the target analysis is
https://api.kapiche.com/export/><uuid>/,the
document-queriesdata schema type was requested,with parameters
start_document_id=1,docs_count=1000andoutput_format=csv
This type of export is discussed further in the section Available Export Data Schemas.
In the following sections, each of the required components of the API will be explained.
Access Tokens
The Admin user for your site can add and delete API tokens on the screen shown below, under the Site Administration section:
When adding a token, the token is presented in a temporary dialog as shown below:
This token is a secret and must be safeguarded like a password. Keep it in your password manager, and only provide it to authorized persons, such as a developer who must write code to access the export API programmatically.
When the dialog is closed, the token will be copied to your clipboard to make it easy for you to paste into your password manager.
NOTE: Kapiche does not store these tokens: only salted, hashed values are stored. Kapiche will not be able to provide a lost token.
If you lose a token, or you need to replace a token that may have been compromised, simply delete tokens in this screen and create a new one. It is good practice to periodically replace tokens with new ones.
Analysis base URL
When the Export API is enabled for a particular analysis, a base URL will be created that is specific to that analysis:
In the image above, the analysis 18-44 age group in the project grocery has been enabled for the export API. In this image above, the base URL is given as:
https://api.kapiche.com/export/0bccbcba45224739b26c5e4b6ce60db9/
This URL must be used for all exports on this analysis. However, this is not the full URL for extracting data. Different kinds of exported data can be obtained by appending an extra component to the URL. For example, to export data in the form of row-based documents including all Saved Themes in that analysis, append document-queries/. The full URL to access that type of export (from this analysis) would be the following:
https://api.kapiche.com/export/0bccbcba45224739b26c5e4b6ce60db9/document-queries/
The different kinds of exports, as well as their configurable options, are described in more detail next.
Available Export Data Options
1. document-queries
This export data format contains the following fields (or columns):
The document_id as used internally by Kapiche. This field is added by Kapiche and is not part of the original source data. Note that the name of this field is given with two trailing underscores, for disambiguation:
document_id__.One field for every structured field in the analysis.
One field for every text field that is part of the analysis.
One field for every sentiment classification corresponding to each text field in the analysis.
One field for every Saved Theme in the analysis. Each such field contains “1” or “0” to indicate whether that document part of that Saved Theme.
document_id__ | City | Age | Response | Sentiment: Response | Sales // Discount | Sales // Return |
1 | Brisbane | 18-25 | The sales discount was great! | positive | 1 | 0 |
2 | Sydney | 26-35 | I returned the faulty item. | negative | 0 | 1 |
3 | Melbourne | 36-45 | Lovely discount but I returned it anyway. | mixed | 1 | 1 |
4 | Perth | 46-60 | No complaints. | neutral | 0 | 0 |
This endpoint provides these additional optional configuration parameters:
Parameter | Help |
| (int) The starting document_id value from where the exported data should begin. This must be used for correct pagination to export large datasets in batches. See the discussion on pagination further below for examples. Default: 1 |
| (int) The maximum number of documents to include in the export. There is a hard upper limit of 50 000. Default: 50 000 |
| (boolean) If true, the export data will be reshaped so that all theme names are vertically arranged. See the discussion further below on reshaping for examples. |
| (text) If vertical-themes is enabled, this string will be used to construct separate columns from each theme name, split by the given separator. See the discussion further below for examples. |
| (text) What output format the theme names should have. Options: theme-label: theme groups are included in theme labels column: theme groups get their own column omit: theme groups are not included in the export
Default: 'theme-label' |
| (boolean) If true, the export data will contain the text columns from Kapiche. |
| (text) What format to use when generating the export. Options: 'csv', 'parquet' Default: 'csv' |
These are discussed in more detail below.
Pagination
As more data is added to a project, the number of documents will grow. Large datasets must be exported in batches. By default, the batch size is 50 000 documents per call. Each document is identified a document_id integer key that is assigned internally by Kapiche. This key can be used to control the start point for each export API call.
For example, consider the following call:
$ curl \
-H "Site-Name: acme" \
-H "Content-Type: application/json" \
-H "Authorization: Site xxx" \
-X GET \
https://api.kapiche.com/export/<uuid>/document-queries/?start_document_id=1
This call will return a data export starting at document_id 1, and containing up to 50000 documents. The HTTP response of the above call will contain a header indicating the next document id that follows the resulting data.
Here is an example of the response headers:
Server: gunicorn Date: Tue, 06 Dec 2022 23:39:01 GMT
Connection: keep-alive
Transfer-Encoding: chunked
Content-Type: application/zip Content-Disposition: attachment; filename="c84ac7fa4e9c4d918ea5c15f3a99652b.zip"
Kapiche-Next-Document-Id: 507
Allow: GET, HEAD, OPTIONS
Cache-Control: no-cache, no-store, must-revalidate
Vary: Accept-Encoding, Cookie, Origin
Automation code can use this information to periodically fetch new data for export. The specific header to use is Kapiche-Next-Document-Id. The value given is what must be specified as the start document id for the next API call, to retrieve the next batch of data.
If there is no new data beyond the given start_document_id then the HTTP response status code will be 204. In an automation setup, that HTTP status code simply means the automation system must wait until new data has been added to the project. Typically an automation is set up to run weekly, or on some similar predictable cadence.
Reshaping
The same data can be provided in a reshaped format where the Saved Themes information is pivoted into a vertical structure. This format can be requested by adding a URL query parameter vertical-themes=true.
In this format, the data is restructured so that each document row is repeated for each Saved Theme that document appears in. In this reshaped format, it is sometimes also convenient to split up theme names into separate columns if a hierarchy has been created in the name.
For example, consider two Saved Themes called Sales // Discount and Sales // Returns. If the URL query parameter theme-level-separator=// is provided, these names will be split into separate columns for each level.
Consider the following example exported data. This is obtained by default from the document-queries export format with no extra parameters:
document_id__ | City | Age | Response | Sentiment: Response | Sales // Discount | Sales // Return |
1 | Brisbane | 18-25 | The sales discount was great! | positive | 1 | 0 |
2 | Sydney | 26-35 | I returned the faulty item. | negative | 0 | 1 |
3 | Melbourne | 36-45 | Lovely discount but I returned it anyway. | mixed | 1 | 1 |
4 | Perth | 46-60 | No complaints. | neutral | 0 | 0 |
If the parameter vertical-themes=true is provided in the Export API call, the following structure will be produced:
document_id__ | City | Age | Response | Sentiment: Response | Theme__ |
1 | Brisbane | 18-25 | The sales discount was great! | positive | Sales // Discount |
2 | Sydney | 26-35 | I returned the faulty item. | negative | Sales // Return |
3 | Melbourne | 36-45 | Lovely discount but I returned it anyway. | mixed | Sales // Discount |
3 | Melbourne | 36-45 | Lovely discount but I returned it anyway. | mixed | Sales // Return |
Note:
Documents that appear in multiple Saved Themes will appear in multiple rows, as with
document_id3 above.Documents that do not appear in a Saved Theme will be absent, as with
document_id4 above.
Finally, if the additional parameter theme-level-separator=// is provided, theme levels will be split:
document_id__ | City | Age | Response | Sentiment: Response | Theme__ Level 1 | Theme__ Level 2 |
1 | Brisbane | 18-25 | The sales discount was great! | positive | Sales | Discount |
2 | Sydney | 26-35 | I returned the faulty item. | negative | Sales | Return |
3 | Melbourne | 36-45 | Lovely discount but I returned it anyway. | mixed | Sales | Discount |
3 | Melbourne | 36-45 | Lovely discount but I returned it anyway. | mixed | Sales | Return |
The full URL for the above export data structure would look like this:
$ curl \
-H "Site-Name: acme" \
-H "Content-Type: application/json" \
-H "Authorization: Site xxx" \
-X GET \
"https://api.kapiche.com/export/<uuid>/document-queries/?start_document_id=1&vertical-themes=true&theme-level-separator=//"
Incremental & change-detection exports
By default, each document-queries call returns a full snapshot of the documents in the requested range. For integration customers who sync Kapiche data into a data warehouse on a regular cadence, the endpoint can instead return only what has changed since the last sync. There are two cursors, which can be used independently or together:
Document cursor — new documents added to the analysis, controlled by
start_document_id(described in the Pagination section above).Theme-change cursor — documents whose Saved Theme membership has changed, controlled by
check_theme_changesandsince_theme_modified.
The theme-change cursor supports these parameters:
Parameter | Help |
| (boolean) Enable theme-change tracking. Requires |
| (text) ISO 8601 timestamp (e.g. |
| (boolean) Include theme modification timestamps in the output. Default: false |
| (boolean) Requires |
Response headers
Kapiche-next-theme-modified— present whencheck_theme_changes=trueand themes were modified. An ISO 8601 timestamp; use it assince_theme_modifiedon the next call to advance the cursor.A 204 No Content response means no documents were affected by theme changes since
since_theme_modified. In an automation, wait and poll again on your normal cadence.
Example — fetch documents whose theme membership changed since a given time, including deletions:
$ curl \
-H "Site-Name: acme" \
-H "Content-Type: application/json" \
-H "Authorization: Site xxx" \
-X GET \
"https://api.kapiche.com/export/<uuid>/document-queries/?vertical-themes=true&check_theme_changes=true&since_theme_modified=2024-01-15T10:30:00Z&include_theme_modified_date=true&include_deletions=true"
Detecting engine-driven changes: mode=delta_cdc
The theme-change cursor described above detects membership changes caused by edits to a theme (someone changing a theme's definition). It does not detect membership changes caused by the engine itself — for example a model retrain, a query-semantics update, or a re-index/re-processing of the data. These can move which documents match a theme without anyone editing the theme. The delta_cdc mode additionally surfaces this engine-driven drift as incremental additions and removals.
💡 Talk to your Customer Success Manager before using delta_cdc. It is an advanced integration mode that changes how your data pipeline must consume the export: your warehouse load has to apply row-level additions and deletions idempotently rather than replacing a snapshot, and Kapiche coordinates enablement and the initial baseline with your integration. Please reach out to your CSM to have it set up rather than switching it on yourself. The reference below describes how it behaves once your integration is configured.
The mode parameter accepts:
Value | Help |
| (default) Detects membership changes from theme edits only. This is the behaviour of a standard theme-change export and needs no coordination. |
| Detects theme-edit changes and engine-driven drift, emitted as true deltas: |
Requirements. delta_cdc builds on the theme-change cursor, so the following must all be set or the call returns 400 Bad Request listing what is missing:
vertical-themes=truecheck_theme_changes=truesince_theme_modified=<ISO 8601 timestamp>include_theme_modified_date=true
How your integration consumes it.
Poll every sync. Engine-driven drift can affect any theme at any time, independent of edits, so your integration polls on its normal cadence rather than only when a theme is edited.
Apply rows idempotently.
is_removed=0is an upsert andis_removed=1is a delete of that(document, theme)pair. Re-applying the same batch must be safe — an undelivered batch is recomputed on the next poll.First call emits nothing. The very first
delta_cdcexport for an analysis establishes the baseline snapshot and returns no delta rows; subsequent calls return changes against it.
Response header. delta_cdc responses include Kapiche-matching-version — an opaque string identifying the matching semantics that produced the batch. It changes when the query engine, concept model, or index is rebuilt (which is what triggers an all-theme drift diff). Record it alongside each batch so a sudden change in volume can be correlated with an engine change.
Example — engine-drift-aware incremental export (once your integration is configured):
$ curl \
-H "Site-Name: acme" \
-H "Content-Type: application/json" \
-H "Authorization: Site xxx" \
-X GET \
"https://api.kapiche.com/export/<uuid>/document-queries/?mode=delta_cdc&vertical-themes=true&check_theme_changes=true&since_theme_modified=2024-01-15T10:30:00Z&include_theme_modified_date=true"


