# marklogic

> The official MarkLogic Node.js client API.

Latest version **4.2.0** (published 2026-09-09) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install marklogic
pnpm add marklogic
yarn add marklogic
bun add marklogic
```

## Health

**Score 65/100 (B)** — status: active.

Positive: has types; no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 4.2.0 |
| Published | 2026-09-09 |
| First published | 2014-11-24 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=22.0.0 |
| Dependencies | 9 |
| Unpacked size | 1.6 MB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 53 |
| Author | MarkLogic |
| Maintainers | marklogic-owner, kkck027, wooldridge, ehennum, priyathamtadikonda, sverma |
| Keywords | marklogic, nosql, database, dbms, search, query, json, xml, http, xquery, xpath |

## Links

- npm: https://www.npmjs.com/package/marklogic
- Repository: https://github.com/marklogic/node-client-api
- Issues: https://github.com/marklogic/node-client-api/issues
- npm.io page: https://npm.io/package/marklogic

## Dependencies (9)

- [qs](https://npm.io/package/qs.md) 6.15.2
- [through2](https://npm.io/package/through2.md) 4.0.2
- [duplexify](https://npm.io/package/duplexify.md) 4.1.3
- [form-data](https://npm.io/package/form-data.md) 4.0.6
- [big-integer](https://npm.io/package/big-integer.md) 1.6.52
- [concat-stream](https://npm.io/package/concat-stream.md) 2.0.0
- [@fastify/busboy](https://npm.io/package/@fastify/busboy.md) 3.2.0
- [multipart-stream](https://npm.io/package/multipart-stream.md) 2.0.1
- [json-text-sequence](https://npm.io/package/json-text-sequence.md) 4.0.2

## 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

- 4.2.0 (latest) — 2026-09-09
- 2.0.0-ea4 (ea) — 2017-01-28
- 4.1.0 — 2026-02-23
- 4.0.0 — 2025-10-30
- 3.7.1 — 2025-09-25
- 3.7.0 — 2025-07-30
- 3.6.0 — 2025-02-05
- 3.5.0 — 2024-08-15
- 3.4.0 — 2024-04-26
- 3.3.1 — 2024-02-02
- 3.3.0 — 2024-01-04
- 3.2.0 — 2023-10-26
- 3.1.0 — 2023-06-12
- 3.0.0 — 2023-03-10
- 2.9.1 — 2022-10-14
- … 22 more at https://npm.io/package/marklogic/versions

## README

# Progress® MarkLogic® Node Client API

The Progress® MarkLogic® Node Client API provides access to the MarkLogic database from Node.js applications.

## Features

* Writing, reading, patching, and deleting documents in JSON, XML, text, or binary formats
* Querying over documents including parsing string queries, extracting properties, and calculating facets
* Projecting tuples (like table rows) out of documents
* Single transactions and multi-statement transactions for database changes
* Writing, reading, and deleting graphs and executing SPARQL queries over graphs
* Extending the built-in services or evaluating or invoking your own JavaScript or XQuery on the server
* Basic, digest, certificate, Kerberos, and SAML authentication
* Import libraries as JavaScript mjs modules
* Data Services First - MarkLogic's support for microservices
* Optic query DSL, document matching, relevance, multiple groups
* Generate query based views, redaction on rows
* Data Movement SDK - move large amounts of data into, out of, or within a MarkLogic cluster

## System Requirements

The Node Client 4.2.0 release requires Node.js 22 or higher. Testing has verified that the client will
run successfully on Node 20, but we recommend 22 or higher based on
[the Node.js release roadmap](https://nodejs.org/en/about/previous-releases), as Node 20 enters
end-of-life in April 2026 while Node 22 is supported through April 2027.

For Node Client 3.x releases, Node.js 16 or higher is required.

The Node Client depends on the [MarkLogic REST API](https://docs.progress.com/bundle/marklogic-server-develop-rest-api-12/page/topics/intro.html) 
for connecting to MarkLogic. The Node Client supports major versions 10, 11, and 12 of MarkLogic, though some features require 
a certain version of MarkLogic due to the underlying REST API support being added in that version of MarkLogic.

## Getting Started

You can install the marklogic package as a dependency for your Node.js project
using [npm](https://www.npmjs.com/package/marklogic):

```
npm install marklogic --save
```

For Windows OS please use the below for Node Client 2.9.1:
```
npm install marklogic --save --ignore-scripts
```

With the marklogic package installed, the following inserts two documents in a
collection into the Documents database using MarkLogic's built-in REST server
at port 8000:

```javascript
const marklogic = require('marklogic');

const db = marklogic.createDatabaseClient({
  host:     'localhost',
  port:     '8000',
  database: 'Documents',
  user:     'admin',
  password: 'admin',
  authType: 'DIGEST',
  // Set to true to suppress the ML-Agent-ID header in each request to MarkLogic.
  // See https://docs.progress.com/bundle/marklogic-server-monitor-12/page/topics/telemetry.html
  disableTelemetryHeader: false,
  // Optional; set to true to request compressed responses for improved performance. The client automatically decompresses returned values.
  enableGzippedResponses: true
});

// For Progress Data Cloud
const db = marklogic.createDatabaseClient({
    apiKey:   'changeme',
    host:     'example.dev.progress.cloud',
    authType: 'cloud',
    // basePath is optional.
    basePath: '/marklogic/test',
    // Optional (in seconds); customizes the expiration of the access token.
    accessTokenDuration: 10,
    // Set to true to request compressed responses for improved performance. The client automatically decompresses returned values.
    enableGzippedResponses: true
});

// For OAUTH
const db = marklogic.createDatabaseClient({
    host:     'localhost',
    port:     '8000',
    authType: 'oauth',
    oauthToken: '<OAUTH Token>'
});

db.createCollection(
  '/books',
  {author: 'Beryl Markham', ...},
  {author: 'WG Sebald',     ...}
  )
.result(function(response) {
    console.log(JSON.stringify(response, null, 2));
  }, function (error) {
    console.log(JSON.stringify(error, null, 2));
  });
```

### Resources

* [Node.js Client API Documentation](https://docs.marklogic.com/jsdoc/index.html)
* [Node.js Application Developer's Guide](https://docs.progress.com/bundle/marklogic-server-develop-with-node-js-11/page/topics/intro.html)
* [MarkLogic Overview](https://www.progress.com/marklogic)

### Code Examples

The Node.js Client API ships with code examples to supplement the examples
in the online resources. To run the examples, follow the instructions here:

    examples/1readme.txt

## Support

The Progress® MarkLogic® Node Client API is maintained by MarkLogic Engineering.
It is designed for use in production applications with MarkLogic Server.
Everyone is encouraged to file bug reports, feature requests, and pull
requests through GitHub. This input is critical and will be carefully
considered, but we can’t promise a specific resolution or timeframe for
any request. In addition, MarkLogic provides technical support
for [release tags](https://github.com/marklogic/node-client-api/releases)
of the Node.js Client API to licensed customers under the terms outlined
in the [Support Handbook](http://www.marklogic.com/files/Mark_Logic_Support_Handbook.pdf).
For more information or to sign up for support,
visit [help.marklogic.com](http://help.marklogic.com).

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