1.4.1 • Published 1 month ago

@illia.kudria/confluence-api v1.4.1

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

Confluence API

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

Getting Started

Install confluence-api via npm:

$ npm install @illia.kudria/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. REST API V2 is used by default. For instance:

var Confluence = require("confluence-api");
var config = {
    username: "testuser",
    password: "test-user-pw-or-rest-api-token",
    baseUrl:  "https://confluence-api-test.atlassian.net/wiki",
    useApiV1: true, // set to use REST API V1, optional
    version: 4 // Confluence major version, optional
};
var confluence = new Confluence(config);
confluence.getPageById("page-id", function(err, data) {
    // do something interesting with data; for instance,
    // data.body.storage.value contains the stored markup for the first
    console.log(data);
});

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.useApiV2booleanDefault true, Optional
config.versionnumberOptional

REST API V2 METHODS

confluence.getSpaces(callback)

Get spaces.

Kind: instance method of Confluence

ParamType
callbackfunction

confluence.getSpaceById(id, callback)

Get space by id.

Kind: instance method of Confluence

ParamTypeValue
idstringID of the space
callbackfunction

confluence.createPage(data, callback)

Creates a page in the space.

Kind: instance method of Confluence

ParamTypeValue
dataobjectdata of new page
data.spaceIdstringID of the space
data.statusstringthe status of the page, published or draft
data.titlestringtitle of the page, required if page status is not draft
data.parentIdstringthe parent content ID of the page
data.bodyobject
data.body.representationstringtype of content representation used for the value field. Valid values: storage, atlas_doc_format, wiki
data.body.valuestringbody of the page, in the format found in the representation field
callbackfunction

confluence.getPageById(id, callback)

Get page by id.

Kind: instance method of Confluence

ParamTypeValue
idstringID of the page
callbackfunction

confluence.updatePage(data, callback)

Update a page by id.

Kind: instance method of Confluence

ParamTypeValue
dataobjectpage data
data.idstringID of the page
data.statusstringthe updated status of the page. Valid values: current, draft
data.titlestringtitle of the page
data.bodyobject
data.body.representationstringtype of content representation used for the value field. Valid values: storage, atlas_doc_format, wiki
data.body.valuestringbody of the page, in the format found in the representation field
data.versionobject
data.version.numbernumberthe new version of the updated page
data.version.messagestringan optional message to be stored with the version
callbackfunction

confluence.deletePage(id, callback)

Delete a page by id.

Kind: instance method of Confluence

ParamTypeValue
idstringID of the page
callbackfunction

confluence.getPageVersions(id, callback)

Returns the versions of specific page.

Kind: instance method of Confluence

ParamTypeValue
idstringID of the page
callbackfunction

REST API V1 METHODS

confluence.getSpace(space, callback)

Get space information.

Kind: instance method of Confluence

ParamType
spacestring
callbackfunction

confluence.getSpaceHomePage(space, callback)

Get space home page.

Kind: instance method of Confluence

ParamType
spacestring
callbackfunction

confluence.getContentById(id, callback)

Get stored content for a specific space and page title.

Kind: instance method of Confluence

ParamType
idstring
callbackfunction

confluence.getCustomContentById(options, callback)

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

Kind: instance method of Confluence

ParamTypeDescription
optionsobjectfor the custom content request
callbackfunction

confluence.getContentByPageTitle(space, title, callback)

Get stored content for a specific space and page title.

Kind: instance method of Confluence

ParamType
spacestring
titlestring
callbackfunction

confluence.postContent(space, title, content, parentId, callback, 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
callbackfunction
representationstringOptional

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

Put/update stored content for a page.

Kind: instance method of Confluence

ParamTypeDescription
spacestring
idstring
versionnumber
titlestring
contentstring
callbackfunction
minorEditbooleanOptional
representationstringOptional

confluence.deleteContent(id, callback)

Delete a page.

Kind: instance method of Confluence

ParamType
idstring
callbackfunction

confluence.getAttachments(space, id, callback)

Get attachments

Kind: instance method of Confluence

ParamType
spacestring
idstring
callbackfunction

confluence.createAttachment(space, id, filepath, callback)

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
callbackfunction

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

This allows you to update posted attachments data

Kind: instance method of Confluence

ParamType
spacestring
idstring
attachmentIdstring
filepathstring
callbackfunction

confluence.getLabels(id, callback)

Get labels from content

Kind: instance method of Confluence

ParamType
idstring
callbackfunction

confluence.postLabels(id, labels, callback)

Post content labels to a existing page.

Kind: instance method of Confluence

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

confluence.deleteLabel(id, label, callback)

Delete a label from a page.

Kind: instance method of Confluence

ParamType
idstring
labelstring
callbackfunction

confluence.search(query, callback)

Search by query

Kind: instance method of Confluence

ParamType
querystring
callbackfunction

request

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

Copyright (c) 2015, John Duane Released under the MIT License

1.4.1

1 month ago

1.4.0

1 month ago