# ESGF Search Harvester — CMIP6 / CORDEX Climate Data (`datamule/esgf-search-harvester`) Actor

Point at ANY ESGF federation node (LLNL, DKRZ, IPSL...) and harvest climate-model dataset/file records via the Search API. Facet-filter by project, model, experiment, variable, frequency. Modes: search, facets, wget file listing.

- **URL**: https://apify.com/datamule/esgf-search-harvester.md
- **Developed by:** [Datamule](https://apify.com/datamule) (community)
- **Categories:** Developer tools, Other
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.35 / 1,000 record returneds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## ESGF Search Harvester — CMIP6 / CORDEX Climate Data

Point this Actor at **any node in the Earth System Grid Federation (ESGF)** and harvest
climate-model **dataset** and **file** records through the federation's uniform, Solr-backed
**Search API**. It's a generic runner: the same query grammar works across every ESGF index
node — LLNL, DKRZ, IPSL, CEDA, NCI and the rest — so you can target one node or the default
federation trio without changing anything but the `nodes` list.

Built for climate scientists, earth-system modellers and research-data engineers who need
programmatic, structured access to CMIP6 / CMIP5 / CORDEX / obs4MIPs / input4MIPs holdings
without hand-rolling the Solr query layer.

### What it does

Three modes, auto-selected from the `mode` input:

| Mode | What you get |
|------|--------------|
| **search** | One row per **dataset** (aggregate) or **file** (`.nc`, with `url` + `checksum`), facet-filtered and paginated to completion (or a `maxRecords` cap). |
| **facets** | The node's **controlled-vocabulary index** — every value of the facet fields you ask for (`experiment_id`, `source_id`, `variable`, …) with its hit count. The fastest way to discover what a node actually holds. |
| **wget** | The ESGF-generated **download script** parsed into one clean row per file (`filename`, `url`, `checksum_type`, `checksum`) — a ready-to-use download manifest. |

### Facet filters

Filter by the standard ESGF facets, exposed as first-class inputs (all optional, all
multi-value):

`project` · `experiment_id` · `variable` · `frequency` · `source_id` (model) ·
`institution_id` · `activity_id` · `variant_label` · `grid_label` · `realm` ·
`table_id` · `data_node` — plus a free-text `query` and an `extraFacets` object for anything
else the node indexes.

### Example input

```json
{
  "nodes": ["https://esgf-node.llnl.gov/esg-search"],
  "mode": "search",
  "type": "Dataset",
  "project": ["CMIP6"],
  "experiment_id": ["historical"],
  "variable": ["tas"],
  "frequency": ["mon"],
  "latestOnly": true,
  "maxRecords": 200
}
```

### Example output (search / Dataset)

```json
{
  "type": "Dataset",
  "id": "CMIP6.CMIP.EC-Earth-Consortium.EC-Earth3.historical.r23i1p1f1.Amon.tas.gr.v20210527|eagle.alcf.anl.gov",
  "title": "CMIP6.CMIP.EC-Earth-Consortium.EC-Earth3.historical.r23i1p1f1.Amon.tas.gr",
  "project": ["CMIP6"],
  "source_id": ["EC-Earth3"],
  "experiment_id": ["historical"],
  "variable": ["tas"],
  "frequency": ["mon"],
  "institution_id": ["EC-Earth-Consortium"],
  "variant_label": ["r23i1p1f1"],
  "data_node": "eagle.alcf.anl.gov",
  "size": 782045502
}
```

Multi-valued Solr fields (`variable`, `project`, `url`, `checksum`, …) are preserved as
arrays — never flattened to the first element. The complete raw Solr document is kept under
`raw` so nothing is lost.

### Notes on the federation

- **`format=application/solr+json`** is pinned for you — without it ESGF returns XML.
- **`distrib`** defaults to `false` (query only the target node). Set it `true` to fan the
  query out across the whole federation — more coverage, but slower and can partially fail.
- **`latestOnly`** (default `true`) restricts to the latest dataset version; `replica`
  controls whether replica copies are included.
- Pagination is automatic (`numFound` + `offset`/`limit`); set `maxRecords: 0` to harvest a
  result set to completion (can be very large — CMIP6 has tens of millions of records).

### Pricing

Pay-per-result: you're charged per record returned. Discovery runs (`facets` mode, or a
small `maxRecords`) are cheap; full harvests scale with what you pull.

### About the ESGF Search API

The ESGF Search API is a thin REST facade over a federated Apache Solr index. Every node
speaks the same grammar, which is exactly what makes one generic Actor work across the whole
federation. Reference:
[ESGF Search RESTful API](https://esgf.github.io/esg-search/ESGF_Search_RESTful_API.html).

# Actor input Schema

## `nodes` (type: `array`):

One or more ESGF index nodes to query. Accepts a bare host or a full base URL; the '/esg-search' mount is assumed if omitted. Leave empty to query the default federation trio (LLNL, DKRZ, IPSL).

## `mode` (type: `string`):

search = facet-filtered dataset/file query (paginated). facets = the controlled-vocabulary index (facet\_counts) for the node. wget = the ESGF download script parsed into one row per file.

## `type` (type: `string`):

Dataset = one row per dataset (aggregate). File = one row per .nc file (carries url + checksum). Any = do not constrain.

## `project` (type: `array`):

e.g. CMIP6, CMIP5, CORDEX, obs4MIPs, input4MIPs, PMIP4. Empty = all projects on the node.

## `experiment_id` (type: `array`):

e.g. historical, ssp585, piControl, amip. CMIP experiment identifier(s).

## `variable` (type: `array`):

CMOR variable short name(s), e.g. tas, pr, psl, tos, siconc.

## `frequency` (type: `array`):

e.g. mon, day, 6hr, yr, fx.

## `source_id` (type: `array`):

Climate model identifier(s), e.g. EC-Earth3, CESM2, GFDL-ESM4, MPI-ESM1-2-HR.

## `model` (type: `array`):

Legacy CMIP5 model facet (use source\_id for CMIP6).

## `institution_id` (type: `array`):

Modelling-centre identifier(s), e.g. NCAR, MPI-M, EC-Earth-Consortium.

## `activity_id` (type: `array`):

CMIP6 activity, e.g. CMIP, ScenarioMIP, DCPP, HighResMIP.

## `variant_label` (type: `array`):

Ensemble member, e.g. r1i1p1f1.

## `grid_label` (type: `array`):

e.g. gn, gr, gr1.

## `realm` (type: `array`):

e.g. atmos, ocean, land, seaIce.

## `table_id` (type: `array`):

CMOR table, e.g. Amon, day, Omon, fx.

## `data_node` (type: `array`):

Constrain to dataset(s) hosted on specific data node(s), e.g. esgf-data1.llnl.gov.

## `query` (type: `string`):

Optional Solr free-text query applied on top of the facet filters.

## `extraFacets` (type: `object`):

Any additional facet constraints as {facet: \[values]}, e.g. {"nominal\_resolution": \["100 km"]}. Merged with the dedicated facet inputs above.

## `facetFields` (type: `array`):

Which facet fields to index when mode=facets.

## `distrib` (type: `boolean`):

If true, the node fans the query out across the whole federation (slower, can partially fail). Default false = query only the target node.

## `latestOnly` (type: `boolean`):

Restrict to the latest dataset version (latest=true). Recommended.

## `replica` (type: `string`):

exclude = primary copies only (replica=false). include = both. only = replicas only.

## `maxRecords` (type: `integer`):

Cap on total records across all nodes. 0 = no cap (harvest to completion — can be very large).

## `pageSize` (type: `integer`):

Records per request page (1-1000).

## Actor input object example

```json
{
  "nodes": [
    "https://esgf-data.dkrz.de/esg-search"
  ],
  "mode": "search",
  "type": "Dataset",
  "project": [
    "CMIP6"
  ],
  "experiment_id": [],
  "variable": [],
  "frequency": [],
  "source_id": [],
  "model": [],
  "institution_id": [],
  "activity_id": [],
  "variant_label": [],
  "grid_label": [],
  "realm": [],
  "table_id": [],
  "data_node": [],
  "query": "",
  "extraFacets": {},
  "facetFields": [
    "project",
    "experiment_id",
    "source_id",
    "variable",
    "frequency"
  ],
  "distrib": false,
  "latestOnly": true,
  "replica": "exclude",
  "maxRecords": 200,
  "pageSize": 100
}
```

# Actor output Schema

## `results` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "nodes": [
        "https://esgf-node.llnl.gov/esg-search"
    ],
    "project": [
        "CMIP6"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("datamule/esgf-search-harvester").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "nodes": ["https://esgf-node.llnl.gov/esg-search"],
    "project": ["CMIP6"],
}

# Run the Actor and wait for it to finish
run = client.actor("datamule/esgf-search-harvester").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "nodes": [
    "https://esgf-node.llnl.gov/esg-search"
  ],
  "project": [
    "CMIP6"
  ]
}' |
apify call datamule/esgf-search-harvester --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=datamule/esgf-search-harvester",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/acts/BAZ75YUU9NqrC7jME/builds/v9OWA2frRuKHXV8MQ/openapi.json
