Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

MrRefactoring/confluence.js

Open more actions menu

Repository files navigation

Confluence.js logo

NPM version NPM downloads per month build status license

JavaScript/TypeScript library for Node.js and browsers to interact with Atlassian Confluence API

About

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.

Table of Contents

Getting Started

Installation

Requires Node.js 20.0.0 or newer

# npm
npm install confluence.js

# yarn
yarn add confluence.js

# pnpm
pnpm add confluence.js

Quick Example

Create 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();

Documentation

Full API reference and guides available at: https://mrrefactoring.github.io/confluence.js/

Usage

Authentication

Basic Authentication

  1. Create an API token: Atlassian Account Settings
  2. Configure the client:
const client = new ConfluenceClient({
  host: 'https://your-domain.atlassian.net',
  authentication: {
    basic: {
      email: 'YOUR@EMAIL.ORG',
      apiToken: 'YOUR_API_TOKEN',
    },
  },
});

OAuth 2.0

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',
    },
  },
});

JWT

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,
    },
  },
});

First Request

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}`);

API Structure

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

Custom API Prefix

For custom API endpoints:

const client = new ConfluenceClient({
  host: 'https://custom-domain.com',
  apiPrefix: '/confluence-api', // Default: '/wiki/rest/api'
});

Tree Shaking

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' });

Other Products

Explore our other Atlassian integration libraries:

License

MIT License © MrRefactoring See LICENSE for details.

About

confluence.js is a powerful Node.JS/Browser module that allows you to interact with the Confluence API very easily

Topics

Resources

License

Stars

Watchers

Forks

Contributors 10

Morty Proxy This is a proxified and sanitized view of the page, visit original site.