Overview

The novem python api provides utility and convenience functions for using the novem api from python.

The primary use-case is creating charts based on pandas dataframes, but other relevant novem functionality is also exposed through the api.

This document explains the overall design of the library and how to use it, for examples of specific use-cases please see the relevant sections on plots and e-mails.

Installation

The novem python library requires python 3.8.5 or higher and is available from PyPI. The source code can also be found on our GitHub.

pip install novem

Once the novem library is installed you can run python -m novem --init (or just novem --init depending on your system setup) to generate a new token and create the default config file.

For more details, please see documentation for the novem cli.

username@computer:~/$ python -m novem --init
 • novem.io username: <your_username>
 • novem.io password: <your_password>
 ✓ authenticated
 ✓ token created
 ✓ new token "novem-python-computer-rj8chk2j" saved to ~/.config/novem/novem.conf
username@computer:~/$ _

Plot

The plot module exposes a novem plot class that maps to the /v1/vis/plots/ api end-point.

The class takes one positional parameter, the plot name, and several optional named parameters. All the named parameters in the constructor are also available as properties.

"""
Below we show the various ways you can set the options on your novem plot
"""

from novem import Plot

# everything in the constructor
barchart = Plot(<name>, \
  type='bar', \
  title='barchart title', \
  caption = 'caption'
)

# property approach
barchart = Plot('plot_name')
barchart.type = 'bar'
barchart.title = 'barchart title'
barchart.caption = 'caption'

Mail

The mail module exposes a novem plot class that maps to the /v1/vis/mails/ api end-point.

The class allows two primary way of constructing an e-mail. Either by supplying a novem markdown document as a content file or constructing the e-mail programmatically.

The markdown approach

from novem import Mail

mail = Mail('name')                     # create mail object

mail.to = "user@example.com"            # add recipient

with open('content.txt', 'r') as f:
    mail(f)                             # add content to mail

mail.send()

The pythonic approach

from novem import Mail,
from novem.mail.sections import \
  PreviewSummarySection,
  TextSection

mail = Mail('name')                     # create mail object

mail.to = "user@example.com"            # add recipient

mail.subject = "Test e-mail"

mail.add_section(PreviewSummarySection("""
Preview summary that is not visible in the main
body of the mail
"""))

mail.add_section(TextSection("""
Markdown text for text section
""", title="Section title"
))

mail.send()