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

# Harvard Dataverse

> Harvard's public Dataverse repository of research datasets (including collections such as the MIT Election Data and Science Lab's returns): search, dataset and file metadata, collection contents and file downloads.

![](https://mintcdn.com/webrouter/gPu3tCeozwRcDBjt/logo/data-apis/harvard-dataverse.svg?fit=max\&auto=format\&n=gPu3tCeozwRcDBjt\&q=85\&s=13075db8441c3badb258c3b90d8e3f77)

[Web Catalog · Science](https://docs.webrouter.net/data-apis.md?category=science)

Key optional

Endpoints

6

Auth

Key in header

[Vendor docs](https://guides.dataverse.org/en/latest/api/)

## Setup

| Variable | | What it is |
| - | - | - |
| `HARVARD_DATAVERSE_API_KEY` | some calls | Optional Dataverse API token (account menu > API Token on dataverse.harvard.edu); only needed for unpublished or restricted content. Sent in the X-Dataverse-key header. |

Put them in your environment or `.env`; [Data APIs](https://docs.webrouter.net/vendors.md) covers the other ways.

## Notes

* Published datasets and public files are readable without a token.
* Datasets are addressed by numeric database id or by DOI: put the literal ':persistentId' where the id goes and pass persistentId=doi:... as a query parameter (datasets.get does this).
* Collections are addressed by alias (e.g. medsl) or database id; :root is the top collection.
* Some files require a guestbook response before download; those return an error on a plain GET.

## Endpoints

GET

Search datasets, files and collections

Datasets, files or collections matching a query, with names, DOIs, descriptions and optional facets.

[Open](#harvard-dataverse-search)

GET

Get a dataset by DOI

A dataset's latest version with its citation metadata and file list, by persistent identifier.

[Open](#harvard-dataverse-datasets-get)

GET

List a dataset version's files

File metadata (ids, names, sizes, content types, access status) of one dataset version, paged and filterable.

[Open](#harvard-dataverse-datasets-files)

GET

Get a collection

A Dataverse collection's name, alias, description and contacts.

[Open](#harvard-dataverse-collections-get)

GET

List a collection's contents

The collections and datasets directly under one collection (not recursive).

[Open](#harvard-dataverse-collections-contents)

GET

Download a data file

The content of one file by numeric file id; tabular files come as tab-separated values by default.

[Open](#harvard-dataverse-files-download)

### Search datasets, files and collections

GET

`/api/search`

`harvard-dataverse.search`

Datasets, files or collections matching a query, with names, DOIs, descriptions and optional facets.

Input

<table>
  <thead>
    <tr>
      <th>
        Name
      </th>

      <th>
        Type
      </th>

      <th>
        In
      </th>

      <th>
        Notes
      </th>
    </tr>
  </thead>

  <tbody>
    <tr><td>`q` required</td><td>string</td><td>query</td><td>Search terms; field syntax like title:data and \* wildcards allowed. Example `election returns`</td></tr>
    <tr><td>`type`</td><td>array</td><td>query</td><td>dataverse, dataset and/or file; all when omitted. Example `["dataset"]`</td></tr>
    <tr><td>`subtree`</td><td>array</td><td>query</td><td>Collection alias(es) to search within, including sub-collections. Example `["medsl"]`</td></tr>
    <tr><td>`sort`</td><td>string</td><td>query</td><td>name, date or score (relevance, the default). One of `name`, `date`, `score`</td></tr>
    <tr><td>`order`</td><td>string</td><td>query</td><td>asc or desc. One of `asc`, `desc`</td></tr>
    <tr><td>`per_page`</td><td>integer</td><td>query</td><td>Results per page: default 10, max 1000. Example `10`</td></tr>
    <tr><td>`start`</td><td>integer</td><td>query</td><td>Offset cursor for paging. Example `0`</td></tr>

    <tr>
      <td>
        `fq`
      </td>

      <td>
        array
      </td>

      <td>
        query
      </td>

      <td>
        Filter queries on facet fields.
      </td>
    </tr>

    <tr>
      <td>
        `show_facets`
      </td>

      <td>
        boolean
      </td>

      <td>
        query
      </td>

      <td>
        Include facets usable with fq.
      </td>
    </tr>

    <tr><td>`metadata_fields`</td><td>array</td><td>query</td><td>Extra dataset metadata to include, as \{block}:\{field} or \{block}:\*. Example `["citation:*"]`</td></tr>
  </tbody>
</table>

[Vendor docs](https://guides.dataverse.org/en/latest/api/search.html) · Same job: [ArcGIS Online](https://docs.webrouter.net/data-apis/arcgis.md#arcgis-groups-search), [Attio](https://docs.webrouter.net/data-apis/attio.md#attio-objects-list), [Bank of Canada](https://docs.webrouter.net/data-apis/bankofcanada.md#bankofcanada-lists), [US Bureau of Economic Analysis](https://docs.webrouter.net/data-apis/bea.md#bea-datasets-list), [Bright Data](https://docs.webrouter.net/data-apis/brightdata.md#brightdata-datasets-list), [Clay](https://docs.webrouter.net/data-apis/clay.md#clay-tables-query)

```python Python theme={null}
router.call_data_api("harvard-dataverse.search", {'q': 'election returns', 'type': ['dataset'], 'subtree': ['medsl'], 'per_page': 10, 'start': 0, 'metadata_fields': ['citation:*']})
```

```text MCP theme={null}
call_data_api(endpoint="harvard-dataverse.search", params={"q": "election returns", "type": ["dataset"], "subtree": ["medsl"], "per_page": 10, "start": 0, "metadata_fields": ["citation:*"]})
```

### Get a dataset by DOI

GET

`/api/datasets/:persistentId/`

`harvard-dataverse.datasets.get`

A dataset's latest version with its citation metadata and file list, by persistent identifier.

Input

<table>
  <thead>
    <tr>
      <th>
        Name
      </th>

      <th>
        Type
      </th>

      <th>
        In
      </th>

      <th>
        Notes
      </th>
    </tr>
  </thead>

  <tbody>
    <tr><td>`persistentId` required</td><td>string</td><td>query</td><td>Persistent id with its scheme prefix. Example `doi:10.7910/DVN/WAWZWZ`</td></tr>

    <tr>
      <td>
        `returnOwners`
      </td>

      <td>
        boolean
      </td>

      <td>
        query
      </td>

      <td>
        Also list the collections the dataset belongs to.
      </td>
    </tr>
  </tbody>
</table>

[Vendor docs](https://guides.dataverse.org/en/latest/api/native-api.html#get-json-representation-of-a-dataset) · Same job: [Affinity](https://docs.webrouter.net/data-apis/affinity.md#affinity-companies-fields), [ArcGIS Online](https://docs.webrouter.net/data-apis/arcgis.md#arcgis-items-get), [Attio](https://docs.webrouter.net/data-apis/attio.md#attio-attributes-list), [Bank of Canada](https://docs.webrouter.net/data-apis/bankofcanada.md#bankofcanada-series-get), [US Bureau of Economic Analysis](https://docs.webrouter.net/data-apis/bea.md#bea-parameters-list), [Bright Data](https://docs.webrouter.net/data-apis/brightdata.md#brightdata-datasets-metadata)

```python Python theme={null}
router.call_data_api("harvard-dataverse.datasets.get", {'persistentId': 'doi:10.7910/DVN/WAWZWZ'})
```

```text MCP theme={null}
call_data_api(endpoint="harvard-dataverse.datasets.get", params={"persistentId": "doi:10.7910/DVN/WAWZWZ"})
```

> [!NOTE]
>
> * The response's id is the numeric dataset id that datasets.files takes.

### List a dataset version's files

GET

`/api/datasets/{id}/versions/{version}/files`

`harvard-dataverse.datasets.files`

File metadata (ids, names, sizes, content types, access status) of one dataset version, paged and filterable.

Input

<table>
  <thead>
    <tr>
      <th>
        Name
      </th>

      <th>
        Type
      </th>

      <th>
        In
      </th>

      <th>
        Notes
      </th>
    </tr>
  </thead>

  <tbody>
    <tr><td>`id` required</td><td>string</td><td>path</td><td>Numeric dataset id. Example `24`</td></tr>
    <tr><td>`version` required</td><td>string</td><td>path</td><td>Version number (e.g. 1.0) or :latest, :latest-published, :draft. Example `:latest-published`</td></tr>
    <tr><td>`limit`</td><td>integer</td><td>query</td><td>Page size; the response's totalCount gives the total. Example `50`</td></tr>
    <tr><td>`offset`</td><td>integer</td><td>query</td><td>Offset for paging. Example `0`</td></tr>
    <tr><td>`contentType`</td><td>string</td><td>query</td><td>Only files of this content type. Example `text/tab-separated-values`</td></tr>

    <tr>
      <td>
        `searchText`
      </td>

      <td>
        string
      </td>

      <td>
        query
      </td>

      <td>
        Only files whose label or description contains this text.
      </td>
    </tr>

    <tr><td>`accessStatus`</td><td>string</td><td>query</td><td>Only files with this access status. One of `Public`, `Restricted`, `EmbargoedThenRestricted`, `EmbargoedThenPublic`, `RetentionPeriodExpired`</td></tr>
    <tr><td>`orderCriteria`</td><td>string</td><td>query</td><td>Sort order. One of `NameAZ`, `NameZA`, `Newest`, `Oldest`, `Size`, `Type`</td></tr>
  </tbody>
</table>

[Vendor docs](https://guides.dataverse.org/en/latest/api/native-api.html#list-files-in-a-dataset)

```python Python theme={null}
router.call_data_api("harvard-dataverse.datasets.files", {'id': '24', 'version': ':latest-published', 'limit': 50, 'offset': 0, 'contentType': 'text/tab-separated-values'})
```

```text MCP theme={null}
call_data_api(endpoint="harvard-dataverse.datasets.files", params={"id": "24", "version": ":latest-published", "limit": 50, "offset": 0, "contentType": "text/tab-separated-values"})
```

### Get a collection

GET

`/api/dataverses/{id}`

`harvard-dataverse.collections.get`

A Dataverse collection's name, alias, description and contacts.

Input

<table>
  <thead>
    <tr>
      <th>
        Name
      </th>

      <th>
        Type
      </th>

      <th>
        In
      </th>

      <th>
        Notes
      </th>
    </tr>
  </thead>

  <tbody>
    <tr><td>`id` required</td><td>string</td><td>path</td><td>Collection alias, database id, or :root. Example `medsl`</td></tr>

    <tr>
      <td>
        `returnChildCount`
      </td>

      <td>
        boolean
      </td>

      <td>
        query
      </td>

      <td>
        Include the number of direct children.
      </td>
    </tr>
  </tbody>
</table>

[Vendor docs](https://guides.dataverse.org/en/latest/api/native-api.html#view-a-dataverse-collection)

```python Python theme={null}
router.call_data_api("harvard-dataverse.collections.get", {'id': 'medsl'})
```

```text MCP theme={null}
call_data_api(endpoint="harvard-dataverse.collections.get", params={"id": "medsl"})
```

### List a collection's contents

GET

`/api/dataverses/{id}/contents`

`harvard-dataverse.collections.contents`

The collections and datasets directly under one collection (not recursive).

Input

<table>
  <thead>
    <tr>
      <th>
        Name
      </th>

      <th>
        Type
      </th>

      <th>
        In
      </th>

      <th>
        Notes
      </th>
    </tr>
  </thead>

  <tbody>
    <tr><td>`id` required</td><td>string</td><td>path</td><td>Collection alias, database id, or :root. Example `medsl`</td></tr>
  </tbody>
</table>

[Vendor docs](https://guides.dataverse.org/en/latest/api/native-api.html#show-contents-of-a-dataverse-collection) · Same job: [ArcGIS Online](https://docs.webrouter.net/data-apis/arcgis.md#arcgis-groups-search), [Attio](https://docs.webrouter.net/data-apis/attio.md#attio-objects-list), [Bank of Canada](https://docs.webrouter.net/data-apis/bankofcanada.md#bankofcanada-lists), [US Bureau of Economic Analysis](https://docs.webrouter.net/data-apis/bea.md#bea-datasets-list), [Bright Data](https://docs.webrouter.net/data-apis/brightdata.md#brightdata-datasets-list), [Clay](https://docs.webrouter.net/data-apis/clay.md#clay-tables-query)

```python Python theme={null}
router.call_data_api("harvard-dataverse.collections.contents", {'id': 'medsl'})
```

```text MCP theme={null}
call_data_api(endpoint="harvard-dataverse.collections.contents", params={"id": "medsl"})
```

### Download a data file

GET

`/api/access/datafile/{id}`

`harvard-dataverse.files.download`

The content of one file by numeric file id; tabular files come as tab-separated values by default.

Input

<table>
  <thead>
    <tr>
      <th>
        Name
      </th>

      <th>
        Type
      </th>

      <th>
        In
      </th>

      <th>
        Notes
      </th>
    </tr>
  </thead>

  <tbody>
    <tr><td>`id` required</td><td>string</td><td>path</td><td>Numeric file id (from datasets.files or search). Example `6`</td></tr>
    <tr><td>`format`</td><td>string</td><td>query</td><td>Tabular files only: original (the uploaded SPSS/Stata/R file), RData, prep (JSON), or subset (with variables). One of `original`, `RData`, `prep`, `subset`</td></tr>
    <tr><td>`variables`</td><td>string</td><td>query</td><td>With format=subset: comma-separated data variable ids to keep. Example `123,127`</td></tr>

    <tr>
      <td>
        `noVarHeader`
      </td>

      <td>
        boolean
      </td>

      <td>
        query
      </td>

      <td>
        Tabular files only: omit the variable-name header row.
      </td>
    </tr>
  </tbody>
</table>

[Vendor docs](https://guides.dataverse.org/en/latest/api/dataaccess.html#basic-file-access)

```python Python theme={null}
router.call_data_api("harvard-dataverse.files.download", {'id': '6', 'variables': '123,127'})
```

```text MCP theme={null}
call_data_api(endpoint="harvard-dataverse.files.download", params={"id": "6", "variables": "123,127"})
```

> [!NOTE]
>
> * Returns the raw file, which may be large or binary.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.