{"id":20508706,"url":"https://github.com/novuhq/novu-python-legacy","last_synced_at":"2025-04-05T15:04:48.614Z","repository":{"id":65830583,"uuid":"598119581","full_name":"novuhq/novu-python-legacy","owner":"novuhq","description":"Python SDK for Novu - The open-source notification infrastructure for engineers. 🚀","archived":false,"fork":false,"pushed_at":"2024-11-04T14:10:40.000Z","size":707,"stargazers_count":80,"open_issues_count":24,"forks_count":31,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-31T03:36:18.326Z","etag":null,"topics":["hacktoberfest","novu","novu-api","python","python3"],"latest_commit_sha":null,"homepage":"https://novu-python.readthedocs.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/novuhq.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.rst","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-06T12:50:30.000Z","updated_at":"2025-01-17T12:31:17.000Z","dependencies_parsed_at":"2023-12-24T01:38:23.491Z","dependency_job_id":"b71b641b-801d-404a-9014-ffd6a2bd9c71","html_url":"https://github.com/novuhq/novu-python-legacy","commit_stats":null,"previous_names":["spikeelabs/novu-python","novuhq/novu-python-legacy"],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/novuhq%2Fnovu-python-legacy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/novuhq%2Fnovu-python-legacy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/novuhq%2Fnovu-python-legacy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/novuhq%2Fnovu-python-legacy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/novuhq","download_url":"https://codeload.github.com/novuhq/novu-python-legacy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247353729,"owners_count":20925329,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest","novu","novu-api","python","python3"],"created_at":"2024-11-15T20:19:51.674Z","updated_at":"2025-04-05T15:04:48.594Z","avatar_url":"https://github.com/novuhq.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Python Novu SDK\n\n[![PyPI](https://img.shields.io/pypi/v/novu?color=blue)](https://pypi.org/project/novu/)\n![Tests Status](https://github.com/novuhq/novu-python/actions/workflows/.github/workflows/tests.yml/badge.svg)\n[![codecov](https://codecov.io/gh/novuhq/novu-python/branch/main/graph/badge.svg?token=RON7F8QTZX)](https://codecov.io/gh/novuhq/novu-python)\n[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit\u0026logoColor=white)](https://github.com/pre-commit/pre-commit)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/novu)\n![PyPI - License](https://img.shields.io/pypi/l/novu)\n[![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release)\n\n---\n\nThe [Python Novu](https://novu.co) SDK and package provides a fluent and expressive interface for interacting with [Novu's API](https://api.novu.co/api) and managing notifications.\n\n## Install\n\nTo install this package\n\n```shell\n# Via pip\npip install novu\n\n# Via poetry\npoetry add novu\n```\n\n## Contents\n\n- [Install](#install)\n- [Quick start](#quick-start)\n- [Code Snippet Examples](#code-snippet-examples)\n  - [Events](#events)\n  - [Subscribers](#subscribers)\n  - [Topics](#topics)\n  - [Feeds](#feeds)\n  - [Environments](#environments)\n- [Go further](#go-further)\n- [Development](#development)\n\n## Quick start\n\nThis package is a wrapper of all the resources offered by Novu, we will just start by triggering an event on Novu.\n\nTo do this, you will need to:\n\n1. 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\n2. Retrieve your API key from the Novu dashboard directly in the settings section: https://web.novu.co/settings\n3. Write code to trigger your first event:\n\n```python\nfrom novu.api import EventApi\n\nevent_api = EventApi(\"https://api.novu.co\", \"\u003cNOVU_API_KEY\u003e\")\nevent_api.trigger(\n    name=\"\u003cYOUR_WORKFLOW_ID\u003e\",  # The workflow ID is the slug of the workflow name. It can be found on the workflow page.\n    recipients=\"\u003cYOUR_SUBSCRIBER_ID\u003e\",\n    payload={},  # Your Novu payload goes here\n)\n```\n\nThis will trigger a notification to the subscribers.\n\n## Code Snippet Examples\n\n### Events\n\nFirstly, make imports and declare the needed variables this way:\n\n```python\nfrom novu.api import EventApi\n\nurl = \"https://api.novu.co\"\napi_key = \"\u003cNOVU_API_KEY\u003e\"\n\n# You can sign up on https://web.novu.co to get your API key from https://web.novu.co/settings\n```\n\n**Trigger an event** - Send notification to subscribers:\n\n```python\nfrom novu.api import EventApi\n\nnovu = EventApi(url, api_key).trigger(\n    name=\"digest-workflow-example\",  # This is the Workflow ID. It can be found on the workflow page.\n    recipients=\"\u003cSUBSCRIBER_IDENTIFIER\u003e\", # The subscriber ID can be gotten from the dashboard.\n    payload={},  # Your custom Novu payload goes here\n)\n```\n\n**Bulk Trigger events** - Trigger multiple events at once:\n\n```python\nfrom novu.dto.event import InputEventDto\nfrom novu.api import EventApi\n\nurl = \"https://api.novu.co\"\napi_key = \"\u003cNOVU_API_KEY\u003e\"\n\nevent_1 = InputEventDto(\n    name=\"digest-workflow-example\",  # The workflow ID is the slug of the workflow name. It can be found on the workflow page.\n    recipients=\"\u003cSUBSCRIBER_IDENTIFIER\u003e\",\n    payload={},  # Your custom Novu payload goes here\n)\nevent_2 = InputEventDto(\n    name=\"digest-workflow-example\",\n    recipients=\"\u003cSUBSCRIBER_IDENTIFIER\u003e\",\n    payload={},\n)\n\nnovu = EventApi(\"https://api.novu.co\", api_key).trigger_bulk(events=[event1, event2])\n```\n\n**Include actor field:**\n\n```python\nfrom novu.api import EventApi\n\nnovu = EventApi(url, api_key).trigger(\n    name=\"workflow_trigger_identifier\",\n    recipients=\"subscriber_id\",\n    actor={\n        \"subscriberId\": \"subscriber_id_actor\"\n    },\n    payload={\n        \"key\":\"value\"\n    },\n)\n```\n\n**Broadcast to all current subscribers:**\n\n```python\nnovu = EventApi(url, api_key).broadcast(\n    name=\"digest-workflow-example\",\n    payload={\"customVariable\": \"value\"},  # Optional\n)\n```\n\n### Subscribers\n\n```python\nfrom novu.dto.subscriber import SubscriberDto\nfrom novu.api.subscriber import SubscriberApi\n\nurl = \"https://api.novu.co\"\napi_key = \"\u003cNOVU_API_KEY\u003e\"\n\n# Define a subscriber instance\nsubscriber = SubscriberDto(\n    email=\"novu_user@mail.com\",\n    subscriber_id=\"82a48af6ac82b3cc2157b57f\", #This is what the subscriber_id looks like\n    first_name=\"\",  # Optional\n    last_name=\"\",  # Optional\n    phone=\"\",  # Optional\n    avatar=\"\",  # Optional\n)\n\n# Create a subscriber\nnovu = SubscriberApi(url, api_key).create(subscriber)\n\n# Get a subscriber\nnovu = SubscriberApi(url, api_key).get(subscriber_id)\n\n# Get list of subscribers\nnovu = SubscriberApi(url, api_key).list()\n```\n\n### Topics\n\n```python\nfrom novu.api import TopicApi\n\nurl = \"\u003cNOVU_URL\u003e\"\napi_key = \"\u003cNOVU_API_KEY\u003e\"\n\n# Create a topic\nnovu = TopicApi(url, api_key).create(\n    key=\"new-customers\", name=\"New business customers\"\n)\n\n# Get a topic\nnovu = TopicApi(url, api_key).get(key=\"new-customers\")\n\n# List topics\nnovu = TopicApi(url, api_key).list()\n\n# Rename a topic\nnovu = TopicApi(url, api_key).rename(key=\"new-customers\", name=\"New business customers\")\n\n# Subscribe a list of subscribers to a topic\nnovu = TopicApi(url, api_key).subscribe(key=\"old-customers\", subscribers=\"\u003cLIST_OF_SUBSCRIBER_IDs\u003e\")\n\n# Unsubscribe a list of subscribers from a topic\nnovu = TopicApi(url, api_key).unsubscribe(key=\"old-customers\", subscribers=\"\u003cLIST_OF_SUBSCRIBER_IDs\u003e\")\n\n```\n\n### Feeds\n\n```python\nfrom novu.api.feed import FeedApi\n\nurl = \"\u003cNOVU_URL\u003e\"\napi_key = \"\u003cNOVU_API_KEY\u003e\"\n\n# Create a Feed\nnovu = FeedApi(url, api_key).create(name=\"\u003cSUPPLY_NAME_FOR_FEED\u003e\")\n\n# Delete a Feed\nFeedApi(url, api_key).delete(feed_id=\"\u003cFEED_NOVU_INTERNAL_ID\u003e\")\n\n# List feeds\nnovu = FeedApi(url, api_key).list()\n```\n\n### Environments\n\n```python\nfrom novu.api.environment import EnvironmentApi\n\nurl = \"\u003cNOVU_URL\u003e\"\napi_key = \"\u003cNOVU_API_KEY\u003e\"\n\n# Create an Environment\nnovu = EnvironmentApi(url, api_key).create(\n    name=\"\u003cINSERT_NAME\u003e\",\n    parent_id=\"\u003cINSERT_PARENT_ID\u003e\" # Optional. Defaults to None\n)\n\n# # List existing environments\nnovu = EnvironmentApi(url, api_key).list()\n\n# # Get the current environment\nnovu = EnvironmentApi(url, api_key).current()\n\n# # Retrieve an environment's API_KEY\nnovu = EnvironmentApi(url, api_key).api_keys()\n\n```\n\n### Tenants\n\n```python\nfrom novu.api.tenant import TenantApi\n\nurl = \"\u003cNOVU_URL\u003e\"\napi_key = \"\u003cNOVU_API_KEY\u003e\"\n\n# Create an Environment\ntenant = TenantApi(url, api_key).create(\n    identifier=\"\u003cINSERT_UNIQUE_TENANT_ID\u003e\",\n    name=\"\u003cINSERT_NAME\u003e\",\n    data={} # Optional. Defaults to {}\n)\n\n# List existing tenants\ntenants = TenantApi(url, api_key).list()\ntenants = TenantApi(url, api_key).list(page=1, limit=10)\n\n# Get a tenant\ntenant = TenantApi(url, api_key).get(\"\u003cTENANT-IDENTIFIER\u003e\")\n\n# Patch some field of a tenant\ntenant = TenantApi(url, api_key).patch(\n    \"\u003cCURRENT-TENANT-IDENTIFIER\u003e\",\n    identifier=\"\u003cNEW-IDENTIFIER\u003e\",\n    name=\"\u003cNEW-NAME\u003e\",\n    data=\"\u003cNEW-DATA\u003e\"\n)\n\n# Delete a tenant\nTenantApi(url, api_key).delete(\"\u003cTENANT-IDENTIFIER\u003e\")\n```\n\n## Go further\n\nAfter a quick start with the SDK, you'll quickly get to grips with the advanced use of the SDK and the other APIs available.\n\nFor this purpose, documentation is available here: https://novu-python.readthedocs.io/\n\n## Development\n\n```bash\n# install deps\npoetry install\n\n# pre-commit\npoetry run pre-commit install --install-hook\npoetry run pre-commit install --install-hooks --hook-type commit-msg\n```\n\n## Contributing\n\nFeature requests, bug reports and pull requests are welcome. Please create an [issue](https://github.com/novuhq/novu-python/issues).\n\n## Support and Feedback\n\nBe sure to visit the Novu official [documentation website](https://docs.novu.co/docs) for additional information about our SDK.\nIf you need additional assistance, join our Discord server [here](https://discord.novu.co).\n\n## License\n\nNovu Python SDK is licensed under the MIT License - see the [LICENSE](https://github.com/novuhq/novu-python/blob/main/LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnovuhq%2Fnovu-python-legacy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnovuhq%2Fnovu-python-legacy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnovuhq%2Fnovu-python-legacy/lists"}