Novu Python SDK
raw JSON → 1.14.0 verified Mon Apr 27 auth: no python
A Python wrapper for the Novu API, enabling notification infrastructure management. Current version 1.14.0, requires Python >=3.8,<4.0. Release cadence is irregular.
pip install novu Common errors
error AttributeError: module 'novu' has no attribute 'Novu' ↓
cause Importing from wrong module (novu vs novu.api).
fix
Change to 'from novu.api import Novu'.
error TypeError: __init__() got an unexpected keyword argument 'id' ↓
cause Subscriber constructor expects 'subscriberId' not 'id'.
fix
Replace 'id' with 'subscriberId' in the Subscriber instantiation.
error novu.exceptions.UnauthorizedException: 401 - Unauthorized ↓
cause Invalid or missing API key.
fix
Set NOVU_API_KEY environment variable or pass it directly to Novu().
Warnings
breaking Import path changed in v1.0: Novu moved from novu import Novu to novu.api import Novu. ↓
fix Use 'from novu.api import Novu' for v1+.
gotcha Subscriber object creation requires 'subscriberId', not 'id'. ↓
fix Use keyword argument 'subscriberId' when creating a Subscriber instance.
gotcha API key must be passed as string, not via environment variable autodiscovery; there is no support for .env files natively. ↓
fix Explicitly pass api_key=os.environ.get('NOVU_API_KEY').
deprecated Client-less trigger method is deprecated; always use Novu().trigger() now. ↓
fix Create a Novu instance and call .trigger() on it.
Imports
- Novu wrong
from novu import Novucorrectfrom novu.api import Novu - EventTrigger wrong
from novu import EventTriggercorrectfrom novu.api import EventTrigger - Subscriber
from novu.api import Subscriber
Quickstart
import os
from novu.api import Novu, EventTrigger
novu = Novu(api_key=os.environ.get('NOVU_API_KEY', ''))
trigger = EventTrigger(
name='onboarding-welcome',
to={'subscriberId': 'subscriber-id', 'email': 'user@example.com'},
payload={'name': 'John'}
)
response = novu.trigger(trigger)
print(response.json())