2.0.0 • Published 1 year ago

@hyperingenuity/confluence-api v2.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Confluence API

This project contains a Node.js module which wraps Atlassian's Confluence API.

Dependencies

node-fetch form-data @types/node

Getting Started

Install confluence-api via npm:

$ npm install confluence-api

Create an instance of Confluence by providing a username and password (or token) and a baseUrl used for all future requests. Confluence uses basic http authentication. For instance:

import Confluence from "confluence-api";
let config = {
    username: "testuser",
    password: "test-user-pw-or-rest-api-token",
    baseUrl:  "https://confluence-api-test.atlassian.net/wiki",
    version: 4 // Confluence major version, optional
};
const confluence = new Confluence(config);
let data = await confluence.getContentByPageTitle("space-name", "page-title");
    // do something interesting with data; for instance,
    // data.results[0].body.storage.value contains the stored markup for the first
    // page found in space 'space-name' matching page title 'page-title'

Confluence currently exposes the following API...

Confluence

Kind: global class this: {Confluence}

new Confluence(config)

Construct Confluence.

ParamTypeDescription
configObject
config.usernamestring
config.passwordstringThe password or REST API Token for the user (docs)
config.baseUrlstring
config.versionnumberOptional

confluence.getSpaces()

Get all spaces information, cycling through res.limit.

Kind: instance method of Confluence

confluence.getSpace(space)

Get space information.

Kind: instance method of Confluence

ParamType
spacestring

confluence.getSpaceHomePage(space)

Get space home page.

Kind: instance method of Confluence

ParamType
spacestring

confluence.getContentById(id)

Get stored content for a specific space and page title.

Kind: instance method of Confluence

ParamType
idstring

confluence.getCustomContentById(options)

Get stored content for a specific page id with optional custom expanders.

Kind: instance method of Confluence

ParamTypeDescription
optionsobjectfor the custom content request

confluence.getContentByPageTitle(space, title)

Get stored content for a specific space and page title.

Kind: instance method of Confluence

ParamType
spacestring
titlestring

confluence.postContent(space, title, content, parentId, representation)

Post content to a new page.

Kind: instance method of Confluence

ParamTypeDescription
spacestring
titlestring
contentstring
parentIdnumberA null value will cause the page to be added under the space's home page
representationstringOptional

confluence.putContent(space, id, version, title, content, minorEdit, representation)

Put/update stored content for a page.

Kind: instance method of Confluence

ParamTypeDescription
spacestring
idstring
versionnumber
titlestring
contentstring
minorEditbooleanOptional
representationstringOptional

confluence.deleteContent(id)

Delete a page.

Kind: instance method of Confluence

ParamType
idstring

confluence.getAttachments(space, id)

Get attachments

Kind: instance method of Confluence

ParamType
spacestring
idstring

confluence.createAttachment(space, id, filepath)

This allows you to post attachments to the pages you create.

Kind: instance method of Confluence

ParamTypeDescription
spacestring
idstring
filepathstringabsolute path of the file you are sending

confluence.updateAttachmentData(space, id, attachmentId, filepath)

This allows you to update posted attachments data

Kind: instance method of Confluence

ParamType
spacestring
idstring
attachmentIdstring
filepathstring

confluence.getLabels(id)

Get labels from content

Kind: instance method of Confluence

ParamType
idstring

confluence.postLabels(id, labels)

Post content labels to a existing page.

Kind: instance method of Confluence

ParamType
idstring
labelsArray.<{prefix:string, name:string}>

confluence.deleteLabel(id, label)

Delete a label from a page.

Kind: instance method of Confluence

ParamType
idstring
labelstring

confluence.search(query)

Search by query

Kind: instance method of Confluence

ParamType
querystring

confluence.getContentChildByContentId(id, child_type)

See doc Inspired from haalcala based on his PR

Kind: instance method of Confluence

ParamType
idstring
child_typestring

confluence.getContentDescendantByContentId(id, child_type)

See doc Inspired from haalcala based on his PR

Kind: instance method of Confluence

ParamType
idstring
child_typestring

confluence.getPageAsPdf(id)

Inspired from this

Returns pdf buffer that can be:

Kind: instance method of Confluence

ParamType
idstring

request

Node.js wrapper for Atlassian's Confluence API. See https://developer.atlassian.com/confdev/confluence-rest-api

Copyright (c) 2015, John Duane Newly features have been implemented by loopingz team freely inspired from haalcala work and atlassian-python-api contributors work

Released under the MIT License