confluence.js is a powerful Node.JS/Browser module that allows you to interact with the Confluence API very easily
npm install confluence.jsConfluence.js is a powerful Node.js and browser-compatible module that provides seamless interaction with:
- Confluence Cloud REST API
Designed for developer experience and performance, it offers full API coverage and stays updated with new Confluence features.
- Getting Started
- Installation
- Quick Example
- Documentation
- Usage
- Authentication
- Basic Auth
- OAuth 2.0
- JWT
- First Request
- API Structure
- Custom API Prefix
- Tree Shaking
- Other Products
- License
Requires Node.js 20.0.0 or newer
``bashnpm
npm install confluence.js
$3
Create a Confluence space in 3 steps:
`typescript
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
$3
#### Basic Authentication
1. Create an API token: Atlassian Account Settings
2. Configure the client:
`typescript
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:
`typescript
const client = new ConfluenceClient({
host: 'https://your-domain.atlassian.net',
authentication: {
oauth2: {
accessToken: 'YOUR_ACCESS_TOKEN',
},
},
});
`#### JWT
For server-to-server integration:
`typescript
const client = new ConfluenceClient({
host: 'https://your-domain.atlassian.net',
authentication: {
jwt: {
issuer: 'your-client-id',
secret: 'your-secret-key',
expiryTimeSeconds: 180,
},
},
});
`$3
Create a page in an existing space:
`typescript
const page = await client.content.createContent({
title: 'Project Overview',
type: 'page',
space: { key: 'GALAXY' },
body: {
storage: {
value: 'Welcome to our project documentation
',
representation: 'storage',
},
},
});console.log(
Page created: ${page.title});
`$3
Access endpoints using
client. pattern:`typescript
// 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
$3
For custom API endpoints:
`typescript
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:
`typescript
// 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:
- Jira.js - Jira API wrapper
- Trello.js - Trello API integration
MIT License © MrRefactoring
See LICENSE for details.