See coggle-issue-importer or coggle-opml-importer for complete example applications, including authentication.
npm install cogglevar CoggleApi = require('coggle');
var coggle = new CoggleApi({
token:user_access_token
});
coggle.createDiagram(
"My New Coggle"
function(err, diagram){
if(err)
throw err;
console.log("created diagram!", diagram);
}
);The Coggle API client.
Create a new instance of the Coggle API client.
Example:
new CoggleApi({token:user_auth_token})Parameters:
optionstype:Object
Possible Options:token, required: API user authentication token
Lists diagrams accessible to the authorised user.
Parameters:
optionstype:Object
Possible Options:organisation: The organisation to fetch diagrams for. (If undefined, the authenticated user's personal Coggles will be retrieved)
callbacktype:Function
Callback accepting (Error, [Array of CoggleApiDiagram])
Create a new Coggle diagram.
Parameters:
titletype:String
Title for the created diagram.callbacktype:Function
Callback accepting (Error, CoggleApiDiagram)
Coggle API Diagram object.
Create a new instance of a Coggle API Diagram object.
Parameters:
coggle_apitype:CoggleApi
The API client used for accessing this diagram.diagram_resourcetype:Object
Diagram Resource object, with at least_idandtitlefields
Return the web URL for accessing this diagram.
Get all of the nodes (branch elements) in a Diagram.
Parameters:
callbacktype:Function
Callback accepting (Error, [Array of CoggleApiNode])
Rearrange the nodes in this diagram. Use with care!
This function performs a server-side re-arrangement of all of the items in the diagram. It will attempt to make sure no items overlap, and to space things out evenly, it is not guaranteed to produce the same result when called with the same parameters.
Use of this function is generally discouraged, for the same reason that an auto-arrange function isn't provided in the web interface to Coggle: the placement of items can convey meaning, and if your program understands relationships in the data (such as a natural ordering, or that some sibling branches are more closely associated than others), then you should make use of that information to perform a custom layout.
Parameters:
callbacktype:Function
Callback accepting (Error, [Array of CoggleApiNode])
Coggle API Node object, which represents individual parts("nodes") of the branches in a Coggle diagarm
Create a new instance of a Coggle API Node object.
Parameters:
coggle_api_diagramtype:CoggleApiDiagram
The Diagram in which this node belongs.node_resourcetype:Object
Node Resource object, with at least_id(String),text(String), andoffset({x:Number, y:Number}) fields.
Add a child to this item. The child is positioned relative to this item, and will move when you move this item.
Parameters:
textText to add for the item.offsettype:Object: {x:Number, y:Number}
Offset of the new item from this one. Thexcoordinate is along the branch direction, theycoordinate is vertically down from the top of the document.callbacktype:Function
Callback accepting (Error, CoggleApiNode)
Update the properties of this node
Parameters:
propertiestype:Object: {text:String, offset:{x:Number, y:Number}, parent:String}
Omitted properties are unmodified.callbacktype:Function
Callback accepting (Error, CoggleApiNode)
Set the text of this node.
Parameters:
texttype:String
New text to setcallbacktype:Function
Callback accepting (Error, CoggleApiNode)
Move this node to a new offset relative to its parent.
Parameters:
offsettype:Object {x:Number, y:Number}
New position to setcallbacktype:Function
Callback accepting (Error, CoggleApiNode)
Remove this node, and all nodes descended from it.
Parameters:
callbacktype:Function
Callback accepting (Error)