The Python Novu SDK and package provides a fluent and expressive interface for interacting with Novu's API and managing notifications.
To install this package
# Via pip
pip install novu
# Via poetry
poetry add novu
This package is a wrapper of all the resources offered by Novu, we will just start by triggering an event on Novu.
To do this, you will need to:
- Create your first notification workflow and keep in mind the identifier to trigger the workflow: https://docs.novu.co/overview/quickstart/general-quickstart#create-a-workflow
- Retrieve your API key from the Novu dashboard directly in the settings section: https://web.novu.co/settings
- Write code to trigger your first event:
from novu.api import EventApi
event_api = EventApi("https://api.novu.co", "<NOVU_API_TOKEN>")
event_api.trigger(
name="<YOUR_WORKFLOW_ID>", # The workflow ID is the slug of the workflow name. It can be found on the workflow page.
recipients="<YOUR_SUBSCRIBER_ID>",
payload={}, # Your Novu payload goes here
)
This will trigger a notification to the subscribers.
After a quick start with the SDK, you'll quickly get to grips with the advanced use of the SDK and the other APIs available.
For this purpose, documentation is available here: https://novu-python.readthedocs.io/
# install deps
poetry install
# pre-commit
poetry run pre-commit install --install-hook
poetry run pre-commit install --install-hooks --hook-type commit-msg