> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mkk.celebi.me/llms.txt
> Use this file to discover all available pages before exploring further.

# Export Fund Data as CSV from the MKK API

> Download bulk CSV exports of portfolio entries, line item values, and data quality reports, with the same filters available on the JSON endpoints.

The MKK API provides three dedicated CSV export endpoints that let you download large datasets in a single request. Each export endpoint mirrors the filtering parameters of its JSON counterpart, so you can apply the same `fund_code`, `period`, and other filters you use during exploration — then switch to the export URL when you are ready to pull data into a spreadsheet, pipeline, or analysis tool.

## Export endpoints

| Endpoint                             | Description                                                         |
| ------------------------------------ | ------------------------------------------------------------------- |
| `GET /exports/portfolio-entries.csv` | Holdings data from portfolio tables across documents.               |
| `GET /exports/line-item-values.csv`  | Structured line item values with raw labels and mapping confidence. |
| `GET /exports/data-quality.csv`      | Data quality report for documents matching the given filters.       |

## Portfolio entries CSV

`GET /exports/portfolio-entries.csv` exports the same data you would retrieve from `/portfolio-entries`. Use it when you need a complete snapshot of a fund's holdings across one or more reporting periods.

**Typical columns:**

* `fund_code`, `fund_name`
* `document_id`, `period`
* `section`
* `stock_key`, `label`
* `value`, `unit`

```bash theme={null}
# Export all portfolio entries for OJB in 2023
curl "https://mkk-roan.vercel.app/api/exports/portfolio-entries.csv?fund_code=OJB&period=2023" \
  -o ojb-portfolio-2023.csv
```

**Supported filters:** `fund_id`, `fund_code`, `period`, `document_id`, `section`, `q`, `export_limit`, `offset`

## Line item values CSV

`GET /exports/line-item-values.csv` exports structured financial values extracted from documents. It includes the raw source label and a `mapping_confidence` score, which makes it useful for auditing extraction quality alongside the actual values.

**Typical columns:**

* `fund_code`, `fund_name`
* `document_id`, `period`
* `section_id`, `section_title`
* `line_item_slug`, `label`
* `raw_label`, `raw_value`
* `value`, `unit`
* `mapping_confidence`, `mapping_method`

```bash theme={null}
# Export net-asset-value for all funds, all periods
curl "https://mkk-roan.vercel.app/api/exports/line-item-values.csv?line_item_slug=net-asset-value" \
  -o nav-all-funds.csv
```

**Supported filters:** `fund_id`, `fund_code`, `period`, `document_id`, `section_id`, `line_item_slug`, `q`, `label`, `export_limit`, `offset`

## Data quality CSV

`GET /exports/data-quality.csv` exports the same quality report available at `GET /data-quality`. It is useful for running offline analysis, sharing quality metrics with data teams, or ingesting results into a monitoring dashboard.

```bash theme={null}
curl "https://mkk-roan.vercel.app/api/exports/data-quality.csv?fund_code=OJB" \
  -o ojb-data-quality.csv
```

**Supported filters:** `fund_id`, `fund_code`, `low_line_item_threshold`, `export_limit`

See the [data quality guide](/guides/data-quality) for a full description of the quality categories included in this export.

## The export\_limit parameter

All export endpoints accept `export_limit` in place of (or in addition to) the standard `limit` parameter.

| Setting | Value        |
| ------- | ------------ |
| Default | 50,000 rows  |
| Maximum | 100,000 rows |

```bash theme={null}
# Increase to 100,000 rows
curl "https://mkk-roan.vercel.app/api/exports/portfolio-entries.csv?fund_code=OJB&export_limit=100000" \
  -o ojb-portfolio-full.csv
```

<Tip>
  If your dataset is larger than 100,000 rows, use `offset` in combination with `export_limit` to paginate across multiple export requests and concatenate the files.
</Tip>

<Warning>
  The maximum `export_limit` is 100,000 rows per request. Requests that exceed this limit will be capped at 100,000. If the `total` field in the corresponding JSON endpoint shows more rows than this, you must use multiple export requests with incrementing `offset` values to retrieve the full dataset.
</Warning>

## Downloading with curl

Use the `-O` flag to save the file with its default filename (derived from the URL path), or use `-o filename.csv` to specify your own name.

<CodeGroup>
  ```bash Save with default name theme={null}
  curl -O "https://mkk-roan.vercel.app/api/exports/portfolio-entries.csv?fund_code=OJB&period=2023"
  # Saves as: portfolio-entries.csv
  ```

  ```bash Save with custom name theme={null}
  curl "https://mkk-roan.vercel.app/api/exports/portfolio-entries.csv?fund_code=OJB&period=2023" \
    -o ojb-portfolio-2023.csv
  ```

  ```bash Redirect output theme={null}
  curl "https://mkk-roan.vercel.app/api/exports/line-item-values.csv?fund_code=OJB" \
    > ojb-line-items.csv
  ```
</CodeGroup>

## Examples

<Steps>
  <Step title="Export portfolio entries for a fund and period">
    Download all holdings for fund OJB across the full 2023 year:

    ```bash theme={null}
    curl "https://mkk-roan.vercel.app/api/exports/portfolio-entries.csv?fund_code=OJB&period=2023" \
      -o ojb-portfolio-2023.csv
    ```
  </Step>

  <Step title="Export line item values for a specific line item">
    Download every recorded `net-asset-value` across all funds and periods:

    ```bash theme={null}
    curl "https://mkk-roan.vercel.app/api/exports/line-item-values.csv?line_item_slug=net-asset-value&export_limit=100000" \
      -o nav-all-funds.csv
    ```
  </Step>

  <Step title="Export data quality for a fund">
    Download the quality report for OJB to review extraction issues offline:

    ```bash theme={null}
    curl "https://mkk-roan.vercel.app/api/exports/data-quality.csv?fund_code=OJB" \
      -o ojb-quality-report.csv
    ```
  </Step>

  <Step title="Paginate a large export">
    If a dataset exceeds 100,000 rows, export in batches and combine:

    ```bash theme={null}
    curl "https://mkk-roan.vercel.app/api/exports/portfolio-entries.csv?fund_code=OJB&export_limit=100000&offset=0" \
      -o batch-1.csv

    curl "https://mkk-roan.vercel.app/api/exports/portfolio-entries.csv?fund_code=OJB&export_limit=100000&offset=100000" \
      -o batch-2.csv

    # Combine (skip header row of second file)
    head -1 batch-1.csv > ojb-full.csv
    tail -n +2 batch-1.csv >> ojb-full.csv
    tail -n +2 batch-2.csv >> ojb-full.csv
    ```
  </Step>
</Steps>
