confluence-data-center-client
v1.0.1
Published
TypeScript client library for Confluence Server/Data Center REST API
Maintainers
Readme
Confluence Data Center Client
TypeScript client for Confluence Server/Data Center REST API.
Installation
npm install confluence-data-center-clientUsage
import { ConfluenceClient } from 'confluence-data-center-client';
const client = new ConfluenceClient({
baseUrl: 'https://confluence.example.com',
token: 'your-personal-access-token',
});
// List spaces
const spaces = await client.spaces.list();
// Get a space
const space = await client.spaces.get({ spaceKey: 'DOCS' });
// Search with CQL
const results = await client.search.query({
cql: 'space = DOCS AND type = page AND text ~ "important"',
});
// Get a page
const page = await client.pages.get({ pageId: '12345', expand: 'body.storage,version' });
// Get a historical version of a page
const oldPage = await client.pages.get({ pageId: '12345', version: 3, status: 'historical' });
// Create a page
const created = await client.pages.create({
spaceKey: 'DOCS',
title: 'New Page',
body: '<p>Page content in storage format</p>',
});
// Update a page
await client.pages.update({
pageId: '12345',
title: 'Updated Title',
body: '<p>Updated content</p>',
version: 2,
});
// Delete a page
await client.pages.delete({ pageId: '12345' });
// Get child pages
const children = await client.pages.getChildren({ pageId: '12345' });
// Get page history
const history = await client.pages.getHistory({ pageId: '12345' });
// Get and add comments
const comments = await client.comments.get({ pageId: '12345' });
await client.comments.add({ pageId: '12345', body: 'A comment' });
// Get and add labels
const labels = await client.labels.get({ pageId: '12345' });
await client.labels.add({ pageId: '12345', labels: [{ name: 'important' }] });
// Upload and download attachments
await client.attachments.upload({ pageId: '12345', filePath: '/path/to/file.pdf' });
await client.attachments.download({ downloadUrl: '/download/attachments/12345/file.pdf', destinationPath: '/tmp/file.pdf' });
await client.attachments.delete({ attachmentId: '67890' });API Structure
| Domain | Methods |
|--------|---------|
| client.spaces | list, get |
| client.pages | get, create, update, delete, getChildren, getHistory |
| client.search | query |
| client.comments | get, add |
| client.labels | get, add |
| client.attachments | get, upload, download, delete |
Authentication
Generate a Personal Access Token in Confluence: Profile > Settings > Personal Access Tokens
export CONFLUENCE_URL=https://confluence.example.com
export CONFLUENCE_TOKEN=your-token-hereRequirements
- Node.js >= 22.0.0
- Confluence Server/Data Center 6.0+
API Endpoints
This client uses:
- Confluence REST API:
/rest/api
Authentication: Bearer token (Personal Access Token)
License
MIT
