# OHDSI WebAPI Extractor (`datamule/ohdsi-webapi-extractor`) Actor

Point at ANY OHDSI WebAPI (the OMOP-CDM / ATLAS analytics REST API) and pull server info, data sources & daimons, saved cohort definitions, concept sets, and OMOP vocabulary concept search into clean flat rows. One generic runner for any observational-health host. Pay per record.

- **URL**: https://apify.com/datamule/ohdsi-webapi-extractor.md
- **Developed by:** [Datamule](https://apify.com/datamule) (community)
- **Categories:** Developer tools, Business
- **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 extracteds

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

## OHDSI WebAPI Extractor

Point at **any OHDSI WebAPI** — the open-standard REST backend behind **ATLAS**, the
observational-health / real-world-evidence platform built on the **OMOP Common Data
Model** — and pull its server info, data sources, saved cohort definitions, concept
sets, and OMOP vocabulary concept search into clean, flat, tabular rows.

One **generic runner** for every OHDSI network host — no per-site scraper. Give a base
URL and a mode; every conformant WebAPI answers the same uniform REST grammar, so the
same normalized row shape comes back regardless of which OMOP network operates it.

### Why this actor

The OHDSI (Observational Health Data Sciences and Informatics) community runs a global
federated network of OMOP-CDM databases queried through a common **WebAPI**. Researchers,
pharma real-world-evidence teams, and health-data engineers routinely need to inventory
what a given ATLAS/WebAPI instance exposes — which data sources are configured, what
saved phenotype cohorts and concept sets exist, and how OMOP standard concepts map for a
search term. This actor does exactly that against **any** WebAPI host, in one call.

### Modes

| Mode | What you get | Endpoint |
|---|---|---|
| **sources** | One row per configured OMOP **data source**, with its daimons (CDM / Vocabulary / Results / …) flattened + booleans for the common ones | `/source/sources` |
| **info** | The server's **version, build & configuration** (security enabled, Solr enabled, …) | `/info` |
| **cohortdefinitions** | One row per **saved cohort/phenotype definition** (id, name, description, timestamps, tags) | `/cohortdefinition` |
| **conceptsets** | One row per **saved concept set** (curated OMOP concept collections) | `/conceptset` |
| **vocabulary-search** | One row per matching **OMOP concept** for a search term (id, name, code, domain, vocabulary, standard flag, validity dates) | `/vocabulary/{sourceKey}/search` |

### Input

| Field | Required | Description |
|---|---|---|
| `baseUrl` | ✅ | One or more WebAPI **root** URLs (e.g. `https://atlas-demo.ohdsi.org/WebAPI`). The root path varies per host — some mount at `/WebAPI`, some behind a proxy at `/atlas/WebAPI` — so give the full base; the actor appends the endpoints. |
| `mode` | | One of the five modes above. Default `sources`. |
| `query` | | Search term for `vocabulary-search` (e.g. `aspirin`, `type 2 diabetes`). |
| `sourceKey` | | For `vocabulary-search`, the source whose vocabulary to search. Auto-discovered from `/source/sources` (first source with a Vocabulary daimon) if omitted. |
| `maxRecords` | | Total row cap across all hosts. Default `1000`. |
| `bearerToken` | | Optional OAuth2 bearer for a security-enabled host. Not needed for public reference servers. Never logged. |
| `extraHeaders` | | Optional extra request headers (JSON object). |

#### Example

```json
{
  "baseUrl": ["https://atlas-demo.ohdsi.org/WebAPI"],
  "mode": "vocabulary-search",
  "query": "aspirin",
  "maxRecords": 500
}
```

You can pass **several hosts** in `baseUrl` to build a cross-network census in one run —
a host that is unreachable is skipped with a warning and the run continues; a run where
no host produced any row fails fast so a broken configuration never looks successful.

### Output

Each result row is flat and tabular, with `_source` / `_mode` / `_webApiVersion`
provenance columns plus mode-specific fields, and a `_raw` column preserving the full
original object (capped for size). The dataset ships an **overview table view** so
results render cleanly in the Apify console and export to CSV/JSON/Excel.

### Pricing

**Pay per result** — you are charged one event per emitted row. No subscription; you pay
only for what you extract.

### Notes

- Works against public OHDSI reference servers out of the box; no credentials required.
- Vocabulary search can return tens of thousands of concepts — use `maxRecords` to bound
  a run.
- Timestamps from the WebAPI (epoch-millis) are normalized to ISO-8601 UTC strings.
- OHDSI, OMOP, ATLAS and WebAPI are projects/trademarks of the OHDSI community; this actor
  is an independent client of the public open-standard API and is not affiliated with OHDSI.

# Actor input Schema

## `baseUrl` (type: `array`):

One or more OHDSI WebAPI ROOT URLs. Examples: https://atlas-demo.ohdsi.org/WebAPI (OHDSI public reference) and https://atlas-covid19.ohdsi.org/WebAPI (COVID-19 network). Point at the WebAPI ROOT — the actor appends /info, /source/sources, /cohortdefinition, /conceptset, /vocabulary/... for you. The root path VARIES per host (some mount at /WebAPI, some behind a proxy at /atlas/WebAPI) so give the full base; do NOT append an endpoint.

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

Which part of the WebAPI to harvest. 'sources' lists the configured OMOP data sources with their daimons. 'info' returns the server version/build/config. 'cohortdefinitions' lists saved cohort (phenotype) definitions. 'conceptsets' lists saved concept sets. 'vocabulary-search' searches OMOP concepts for a term (needs a search term; a sourceKey with a Vocabulary daimon is auto-discovered if you don't supply one).

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

For 'vocabulary-search' mode: the OMOP concept search term, e.g. 'aspirin', 'type 2 diabetes', 'myocardial infarction'. Matched against concept names across the source's vocabulary. Required for vocabulary-search; ignored in other modes.

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

For 'vocabulary-search' mode: the WebAPI sourceKey whose Vocabulary daimon to search (e.g. SYNPUF5PCT on the OHDSI demo). Leave empty and the actor auto-discovers the first source that owns a Vocabulary daimon from /source/sources. Use 'sources' mode first to see the available keys.

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

Maximum total rows to emit across all hosts. Vocabulary search can return tens of thousands of concepts, so this caps the run. Each emitted row is one billable event. Default 1000.

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

Optional OAuth2 bearer token for a WebAPI host that has security enabled. Sent as Authorization: Bearer \*\*\*. NOT required for the public OHDSI reference servers — leave empty. Never logged.

## `extraHeaders` (type: `object`):

Optional extra HTTP headers to send with every request, as a JSON object (e.g. an API-key header a specific deployment requires). Leave empty for the public reference servers.

## Actor input object example

```json
{
  "baseUrl": [
    "https://atlas-demo.ohdsi.org/WebAPI"
  ],
  "mode": "sources",
  "query": "aspirin",
  "maxRecords": 1000
}
```

# 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 = {
    "baseUrl": [
        "https://atlas-demo.ohdsi.org/WebAPI"
    ],
    "query": "aspirin",
    "maxRecords": 1000
};

// Run the Actor and wait for it to finish
const run = await client.actor("datamule/ohdsi-webapi-extractor").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 = {
    "baseUrl": ["https://atlas-demo.ohdsi.org/WebAPI"],
    "query": "aspirin",
    "maxRecords": 1000,
}

# Run the Actor and wait for it to finish
run = client.actor("datamule/ohdsi-webapi-extractor").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 '{
  "baseUrl": [
    "https://atlas-demo.ohdsi.org/WebAPI"
  ],
  "query": "aspirin",
  "maxRecords": 1000
}' |
apify call datamule/ohdsi-webapi-extractor --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

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