# @medplum/core

> Medplum TS/JS Library

Latest version **5.2.16** (published 2026-11-10) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @medplum/core
pnpm add @medplum/core
yarn add @medplum/core
bun add @medplum/core
```

## Health

**Score 55/100 (C)** — status: active.

Positive: no vulnerabilities; recently updated; high maintenance score.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 5.2.16 |
| Published | 2026-11-10 |
| First published | 2021-06-01 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2738 |
| Author | Medplum |
| Maintainers | codyebberson, reshmakh, mattlong |
| Keywords | medplum, fhir, healthcare, interoperability, json, serialization, hl7, standards, clinical, dstu2, stu3, r4, normative |

## Links

- npm: https://www.npmjs.com/package/@medplum/core
- Repository: https://github.com/medplum/medplum
- Homepage: https://www.medplum.com/
- Issues: https://github.com/medplum/medplum/issues
- npm.io page: https://npm.io/package/@medplum/core

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 5.2.16 (latest) — 2026-11-10
- 5.1.45 (backport) — 2026-10-31
- 5.2.15 — 2026-11-06
- 5.2.14 — 2026-11-03
- 5.2.13 — 2026-10-30
- 5.2.12 — 2026-10-29
- 5.2.11 — 2026-10-29
- 5.2.10 — 2026-10-28
- 5.2.9 — 2026-10-26
- 5.2.8 — 2026-10-24
- 5.2.7 — 2026-10-20
- 5.2.6 — 2026-10-17
- 5.2.5 — 2026-10-15
- 5.2.4 — 2026-10-14
- 5.2.3 — 2026-10-08
- … 319 more at https://npm.io/package/@medplum/core/versions

## README

# Medplum JS Client Library

The Medplum JS Client Library is a pure TypeScript library for calling a FHIR server from the browser.

## Key Features

- FHIR validation and operations
- FHIR client to create, read, update, delete, patch, and search
- WebSockets for realtime communication
- Evaluation of [FhirPath](https://hl7.org/fhirpath/N1/index.html)
- No external dependencies

## Installation

Add as a dependency:

```bash
npm install @medplum/core
```

## Basic Usage

Create a new `MedplumClient`:

```ts
import { MedplumClient } from '@medplum/core';

const medplum = new MedplumClient();
```

Create a `MedplumClient` with additional configuration options:

```ts
import { MedplumClient } from '@medplum/core';

const medplum = new MedplumClient({
  baseUrl: 'https://www.example.com/fhir/R4/',
  clientId: 'MY_CLIENT_ID',
});
```

## Authenticate with client credentials

```ts
const medplum = new MedplumClient();
await medplum.startClientLogin(MY_CLIENT_ID, MY_CLIENT_SECRET);
```

## Authenticating with Medplum

If you are using Medplum as your FHIR server, you can use a direct sign-in API to authenticate email and password.

Before you begin

1. Create a project in the [Medplum App](https://app.medplum.com/)
2. Enable Email/Password

After that, you can use the `startLogin()` method:

```ts
const loginResult = await medplum.startLogin({ email, password, remember });
const profile = await medplum.processCode(loginResult.code);
console.log(profile);
```

## Authenticating with OAuth

Authenticate with a FHIR server via OAuth2 redirect:

```ts
medplum.signInWithRedirect().then((user) => console.log(user));
```

## Search

Search for any resource using a [FHIR search](https://www.hl7.org/fhir/search.html) string:

```ts
search<K extends ResourceType>(
  resourceType: K,
  query?: URLSearchParams | string,
  options: RequestInit = {}
): ReadablePromise<Bundle<ExtractResource<K>>>
```

Example:

```ts
const bundle = await medplum.search('Patient', 'given=eve');
bundle.entry.forEach((entry) => console.log(entry.resource));
```

## Create

[Create resource](https://www.hl7.org/fhir/http.html#create):

```ts
createResource<T extends Resource>(resource: T): Promise<T>
```

Example:

```ts
medplum.createResource({
  resourceType: 'Observation',
  subject: {
    reference: 'Patient/123',
  },
  valueQuantity: {
    // ...
  },
  // ...
});
```

## Read a resource

[Read a resource by ID](https://www.hl7.org/fhir/http.html#read):

```ts
readResource<T extends Resource>(resourceType: string, id: string): Promise<T>
```

Example:

```ts
const patient = await medplum.readResource('Patient', '123');
```

## Read resource history

[Read resource history](https://www.hl7.org/fhir/http.html#history):

```ts
readHistory<T extends Resource>(resourceType: string, id: string): Promise<Bundle<T>>
```

Example:

```ts
const historyBundle = await medplum.readHistory('Patient', '123');
```

## Read resource version

[Read a specific version](https://www.hl7.org/fhir/http.html#vread):

```ts
readVersion<T extends Resource>(resourceType: string, id: string, vid: string): Promise<T>
```

Example:

```ts
const version = await medplum.readVersion('Patient', '123', '456');
```

## Update a resource

[Update a resource](https://www.hl7.org/fhir/http.html#update):

```ts
updateResource<T extends Resource>(resource: T): Promise<T>
```

Example:

```ts
const result = await medplum.updateResource({
  resourceType: 'Patient',
  id: '123',
  name: [
    {
      family: 'Smith',
      given: ['John'],
    },
  ],
});
console.log(result.meta.versionId);
```

## Delete a resource

[Delete a resource](https://www.hl7.org/fhir/http.html#delete):

```ts
deleteResource(resourceType: string, id: string): Promise<any>
```

Example:

```ts
await medplum.deleteResource('Patient', '123');
```

## Patch a resource

[Patch a resource](https://www.hl7.org/fhir/http.html#patch):

```ts
patchResource<T extends Resource>(resourceType: string, id: string, operations: Operation[]): Promise<T>
```

Example:

```ts
const result = await medplum.patchResource('Patient', '123', [
  { op: 'replace', path: '/name/0/family', value: 'Smith' },
]);
console.log(result.meta.versionId);
```

## GraphQL

[Execute a GraphQL query](https://www.hl7.org/fhir/graphql.html):

```ts
graphql(query: string, options?: RequestInit): Promise<any>
```

Example:

```ts
const result = await graphql(`
  {
    PatientList(name: "Alice") {
      name {
        given
        family
      }
    }
  }
`);
```

## About Medplum

Medplum is a healthcare platform that helps you quickly develop high-quality compliant applications. Medplum includes a FHIR server, React component library, and developer app.

## License

[Apache 2.0](../../LICENSE.txt)

---
_Source: https://npm.io/package/@medplum/core · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
