synthea-api

Generate synthetic patient healthcare records as FHIR bundles with Synthea. Apify-backed n8n community node, pay-per-result, and usable as an AI agent tool.

Package Information

Released: 4 mo ago
Downloads: 6 weekly / 298 monthly
Latest Version: 0.1.1
Author: John Cole

Documentation

n8n-nodes-synthea-api

An n8n community node that generates synthetic patient healthcare records as FHIR bundles using Synthea. It is backed by the Synthea Medical Record Generator API on Apify and bills per patient generated, so there are no subscriptions and no minimums.

Installation · Credentials · Operations · Output · Example workflows · Pricing · Resources

What it does

Set a population size and optional demographic and location filters, and the node generates realistic but entirely synthetic patient records. It returns one item per generated FHIR bundle, each with a Key-Value Store key you can use to retrieve the full bundle data. Because the data is synthetic, it carries no real-patient privacy risk, which makes it ideal for testing, demos, and training data. It also works as an AI Agent tool.

  • Generate 1 to 100 synthetic patients per run
  • Filter by gender, age range, US state, and city
  • Reproduce a run exactly with a random seed
  • Optionally apply the US Core R4 FHIR Implementation Guide
  • Choose how much data to return per bundle: Simplified, Raw, or Selected Fields

Installation

Follow the n8n community nodes installation guide:

  1. In n8n, open Settings > Community Nodes.
  2. Select Install.
  3. Enter n8n-nodes-synthea-api as the npm package name.
  4. Agree to the risks of using community nodes, then select Install.

After it installs, the Synthea Medical Records node appears in the nodes panel.

n8n Cloud only allows verified community nodes. Until this node is verified, install it on a self-hosted n8n instance.

Credentials

You need a free Apify account and an API token.

  1. Sign in to the Apify Console.
  2. Open Settings > Integrations and copy your Personal API token.
  3. In n8n, create a new Apify API credential and paste the token.
  4. Use the credential's Test button to confirm it works.

The node also supports Apify OAuth2 if you prefer to connect that way.

Operations

Patient > Generate generates synthetic patients and returns one item per FHIR bundle.

Parameter Description
Population Size How many patients to generate (1 to 100). Required.
Gender Restrict to Male or Female.
Age Range Restrict to an age band, as minAge-maxAge.
State / City Restrict patient location. City requires a State.
Reference Date Generation reference date in YYYYMMDD.
Random Seed Reproduce the same patients across runs.
Use US Core Implementation Guide Apply US Core R4 FHIR profiles.
Output How much data to return: Simplified, Raw, or Selected Fields.

Output

Each generated FHIR bundle is returned as its own n8n item. The full bundle data lives in the run's Apify Key-Value Store; each item carries the key_value_store_key you use to fetch it. The Output parameter lets you choose how much to return:

  • Simplified (default): a compact object with file, format, keyValueStoreKey, sizeMb, storedInKvStore, patientCount, and generationTimestamp. This mode is also used automatically when the node runs as an AI Agent tool, to keep responses small.
  • Raw: every field the API returns for each bundle, using the original field names below.
  • Selected Fields: pick exactly which fields to include.

Fields (Raw and Selected Fields)

Field Type Description
patient_count integer Number of patients in the generation run
generation_timestamp string ISO 8601 timestamp of the run
file string FHIR bundle file name
path string Full path to the bundle file
format string Bundle format, json or ndjson
key_value_store_key string Key-Value Store key holding the full bundle data
size_mb number Bundle size in megabytes
stored_in_kv_store boolean Whether the bundle was stored successfully
error string Error message if storage failed

To retrieve a full bundle, read the Key-Value Store record for key_value_store_key from the Actor run, for example with the Apify node or an HTTP Request to the Apify Key-Value Store API.

Example workflows

1. Seed a test database

  1. Synthea Medical Records: Population Size 50.
  2. HTTP Request: fetch each key_value_store_key from the Key-Value Store.
  3. Postgres: insert each FHIR bundle into your test schema.

2. Generate a reproducible demo cohort

  1. Synthea Medical Records: Population Size 10, State Massachusetts, Random Seed 42.
  2. Code: transform the bundles into your demo format.

3. Build an age-specific sample

  1. Synthea Medical Records: Age Range 65-90, Gender Female.
  2. Filter: keep bundles where stored_in_kv_store is true, then process.

Pricing

This node calls the Synthea Medical Record Generator API on Apify, which is billed pay-per-patient plus a one-time setup fee per run, with no subscription and no minimums. Apify also includes a free monthly usage tier that covers typical volumes. See the Actor page for current rates.

Resources

License

MIT

Discussion