Confluence.js is a powerful Node.js and browser-compatible module that provides seamless interaction with:
Designed for developer experience and performance, it offers full API coverage and stays updated with new Confluence features.
Requires Node.js 20.0.0 or newer
# npm
npm install confluence.js
# yarn
yarn add confluence.js
# pnpm
pnpm add confluence.jsCreate a Confluence space in 3 steps:
import { ConfluenceClient } from 'confluence.js';
const client = new ConfluenceClient({
  host: 'https://your-domain.atlassian.net',
  authentication: {
    basic: {
      email: 'your@email.com',
      apiToken: 'YOUR_API_TOKEN', // Create one: https://id.atlassian.com/manage-profile/security/api-tokens
    },
  },
});
async function createSpace() {
  const space = await client.space.createSpace({
    name: 'Project Galaxy',
    key: 'GALAXY',
  });
  console.log(`Space created: ${space.key}`);
}
createSpace();Full API reference and guides available at: https://mrrefactoring.github.io/confluence.js/
- Create an API token: Atlassian Account Settings
- Configure the client:
const client = new ConfluenceClient({
  host: 'https://your-domain.atlassian.net',
  authentication: {
    basic: {
      email: 'YOUR@EMAIL.ORG',
      apiToken: 'YOUR_API_TOKEN',
    },
  },
});Implement OAuth 2.0 flow using Atlassian's documentation:
const client = new ConfluenceClient({
  host: 'https://your-domain.atlassian.net',
  authentication: {
    oauth2: {
      accessToken: 'YOUR_ACCESS_TOKEN',
    },
  },
});For server-to-server integration:
const client = new ConfluenceClient({
  host: 'https://your-domain.atlassian.net',
  authentication: {
    jwt: {
      issuer: 'your-client-id',
      secret: 'your-secret-key',
      expiryTimeSeconds: 180,
    },
  },
});Create a page in an existing space:
const page = await client.content.createContent({
  title: 'Project Overview',
  type: 'page',
  space: { key: 'GALAXY' },
  body: {
    storage: {
      value: '<p>Welcome to our project documentation</p>',
      representation: 'storage',
    },
  },
});
console.log(`Page created: ${page.title}`);Access endpoints using client.<group>.<method> pattern:
// Get space details
const space = await client.space.getSpace({ spaceKey: 'GALAXY' });
// Search content
const results = await client.search.search({ cql: 'title~"Project"' });🔽 Available API Groups
- audit
- analytics
- content
- contentAttachments
- contentBody
- contentChildrenAndDescendants
- contentComments - was deprecated
- contentMacroBody
- contentLabels
- contentPermissions
- contentProperties - was deprecated
- contentRestrictions
- contentStates
- contentVersions
- contentWatches
- dynamicModules
- experimental
- group
- inlineTasks - was deprecated
- labelInfo
- longRunningTask
- relation
- search
- settings
- space
- spacePermissions
- spaceProperties - was deprecated
- spaceSettings
- template
- themes
- users
- userProperties
For custom API endpoints:
const client = new ConfluenceClient({
  host: 'https://custom-domain.com',
  apiPrefix: '/confluence-api', // Default: '/wiki/rest/api'
});Optimize bundle size by importing only needed modules:
// custom-client.ts
import { BaseClient } from 'confluence.js';
import { Content } from 'confluence.js/api/content';
import { Space } from 'confluence.js/api/space';
export class CustomClient extends BaseClient {
  content = new Content(this);
  space = new Space(this);
}
// Usage
const client = new CustomClient({ /* config */ });
await client.space.getSpace({ spaceKey: 'GALAXY' });Explore our other Atlassian integration libraries:
MIT License © MrRefactoring See LICENSE for details.