Confluence API wrapper for NodeJS
npm install @illia.kudria/confluence-api
$ 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:
`javascript
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}* Confluence
* REST API V2
* .getSpaces(callback)
* .getSpaceById(id, callback)
* .createPage(data, callback)
* .getPageById(id, callback)
* .updatePage(data, callback)
* .deletePage(id, callback)
* .getPageVersions(id, callback)
* REST API V1
* new Confluence(config)
* .getSpace(space, callback)
* .getSpaceHomePage(space, callback)
* .getContentById(id, callback)
* .getCustomContentById(options, callback)
* .getContentByPageTitle(space, title, callback)
* .postContent(space, title, content, parentId, callback, representation)
* .putContent(space, id, version, title, content, callback, minorEdit, representation)
* .deleteContent(id, callback)
* .getAttachments(space, id, callback)
* .createAttachment(space, id, filepath, callback)
* .updateAttachmentData(space, id, attachmentId, filepath, callback)
* .getLabels(id, callback)
* .postLabels(id, labels, callback)
* .deleteLabel(id, label, callback)
* .search(query, callback)
| Param | Type | Description |
|-----------------|----------------------|----------------------------------------------------------------------------------------------------------------------------------|
| config | Object | |
| config.username | string | |
| config.password | string | The password or REST API Token for the user (docs) |
| config.baseUrl | string | |
| config.useApiV2 | boolean | Default true, Optional |
| config.version | number | Optional |
Kind: instance method of Confluence
| Param | Type |
|----------|------------------------|
| callback | function |
Kind: instance method of Confluence
| Param | Type | Value |
|----------|------------------------|-----------------|
| id | string | ID of the space |
| callback | function | |
Kind: instance method of Confluence
| Param | Type | Value |
|--------------------------|-----------------------|--------------------------------------------------------------------------------------------------------|
| data | object | data of new page |
| data.spaceId | string | ID of the space |
| data.status | string | the status of the page, published or draft |
| data.title | string | title of the page, required if page status is not draft |
| data.parentId | string | the parent content ID of the page |
| data.body | object | |
| data.body.representation | string | type of content representation used for the value field. Valid values: storage, atlas_doc_format, wiki |
| data.body.value | string | body of the page, in the format found in the representation field |
| callback | function | |
Kind: instance method of Confluence
| Param | Type | Value |
|----------|------------------------|----------------|
| id | string | ID of the page |
| callback | function | |
Kind: instance method of Confluence
| Param | Type | Value |
|--------------------------|-----------------------|--------------------------------------------------------------------------------------------------------|
| data | object | page data |
| data.id | string | ID of the page |
| data.status | string | the updated status of the page. Valid values: current, draft |
| data.title | string | title of the page |
| data.body | object | |
| data.body.representation | string | type of content representation used for the value field. Valid values: storage, atlas_doc_format, wiki |
| data.body.value | string | body of the page, in the format found in the representation field |
| data.version | object | |
| data.version.number | number | the new version of the updated page |
| data.version.message | string | an optional message to be stored with the version |
| callback | function | |
Kind: instance method of Confluence
| Param | Type | Value |
|----------|------------------------|----------------|
| id | string | ID of the page |
| callback | function | |
Kind: instance method of Confluence
| Param | Type | Value |
|----------|------------------------|----------------|
| id | string | ID of the page |
| callback | function | |
Kind: instance method of Confluence
| Param | Type |
| --- | --- |
| space | string |
| callback | function |
Kind: instance method of Confluence
| Param | Type |
| --- | --- |
| space | string |
| callback | function |
Kind: instance method of Confluence
| Param | Type |
| --- | --- |
| id | string |
| callback | function |
Kind: instance method of Confluence
| Param | Type | Description |
| --- | --- | --- |
| options | object | for the custom content request |
| callback | function | |
Kind: instance method of Confluence
| Param | Type |
| --- | --- |
| space | string |
| title | string |
| callback | function |
Kind: instance method of Confluence
| Param | Type | Description |
| --- | --- | --- |
| space | string | |
| title | string | |
| content | string | |
| parentId | number | A null value will cause the page to be added under the space's home page |
| callback | function | |
| representation | string | Optional |
Kind: instance method of Confluence
| Param | Type | Description |
| --- | --- | --- |
| space | string | |
| id | string | |
| version | number | |
| title | string | |
| content | string | |
| callback | function | |
| minorEdit | boolean | Optional |
| representation | string | Optional |
Kind: instance method of Confluence
| Param | Type |
| --- | --- |
| id | string |
| callback | function |
Kind: instance method of Confluence
| Param | Type |
| --- | --- |
| space | string |
| id | string |
| callback | function |
Kind: instance method of Confluence
| Param | Type | Description |
| --- | --- | --- |
| space | string | |
| id | string | |
| filepath | string | absolute path of the file you are sending |
| callback | function | |
Kind: instance method of Confluence
| Param | Type |
| --- | --- |
| space | string |
| id | string |
| attachmentId | string |
| filepath | string |
| callback | function |
Kind: instance method of Confluence
| Param | Type |
| --- | --- |
| id | string |
| callback | function |
Kind: instance method of Confluence
| Param | Type |
| --- | --- |
| id | string |
| labels | Array.<{prefix:string, name:string}> |
| callback | function |
Kind: instance method of Confluence
| Param | Type |
| --- | --- |
| id | string |
| label | string |
| callback | function |
Kind: instance method of Confluence
| Param | Type |
| --- | --- |
| query | string |
| callback | function |
Copyright (c) 2015, John Duane
Released under the MIT License