Client libraries

Javascript

We currently support a client library for JavaScript: adf-builder

This package offers two ways of building documents:

  • A fluent document builder interface with support for all node types
  • A tag to be used with ES6 template literals for single-paragraph documents

How to import it:

1
npm install adf-builder

For more detailed documentation, see Atlassian Document Format Builder (JavaScript)

Example usage:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
var { Document } = require('adf-builder');
const doc = new Document();
doc.paragraph()
    .text('Here is some ')
    .strong('bold test')
    .text(' and ')
    .em('text in italics')
    .text(' as well as ')
    .link(' a link', 'https://www.atlassian.com')
    .text(' , emojis ')
    .emoji(':smile:')
    .emoji(':rofl:')
    .emoji(':nerd:')
    .text(' and some code: ')
    .code('var i = 0;')
    .text(' and a bullet list');
doc.bulletList()
    .textItem('With one bullet point')
    .textItem('And another');
doc.panel("info")
    .paragraph()
    .text("and an info panel with some text, with some more code below");
doc.codeBlock("javascript")
    .text('var i = 0;\nwhile(true) {\n  i++;\n}');
var reply = doc.toJSON();

Python

You can get the library using pip or any Python package manager that can use PyPi packages: pip install pyadf. The library currently only supports Python 3+.

You can construct your document nodes manually if you want, but the recommended way of constructing documents is to use the fluent API.

1
2
3
4
5
6
7
8
9
10
11
12
from pyadf.document import Document

doc = Document()                           \
    .paragraph()                           \
        .emoji("success")                  \
        .text(' This is my document, ')    \
        .text('this is a link')            \
            .link('https://atlassian.com') \
    .end()                                 \
    .paragraph()                           \
        .text('... and another paragraph') \
    .to_doc()