{"id":50722295,"url":"https://github.com/pushpad/pushpad-python","last_synced_at":"2026-06-10T01:02:58.663Z","repository":{"id":68258840,"uuid":"54883660","full_name":"pushpad/pushpad-python","owner":"pushpad","description":"Python library for sending push notifications from websites and web apps.","archived":false,"fork":false,"pushed_at":"2025-11-18T12:43:00.000Z","size":80,"stargazers_count":23,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-11-18T15:29:51.328Z","etag":null,"topics":["notifications","web-push"],"latest_commit_sha":null,"homepage":"https://pushpad.xyz","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/pushpad.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2016-03-28T10:06:03.000Z","updated_at":"2025-10-01T14:36:31.000Z","dependencies_parsed_at":"2024-01-22T15:53:35.624Z","dependency_job_id":null,"html_url":"https://github.com/pushpad/pushpad-python","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pushpad/pushpad-python","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pushpad%2Fpushpad-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pushpad%2Fpushpad-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pushpad%2Fpushpad-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pushpad%2Fpushpad-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pushpad","download_url":"https://codeload.github.com/pushpad/pushpad-python/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pushpad%2Fpushpad-python/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34132031,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-09T02:00:06.510Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["notifications","web-push"],"created_at":"2026-06-10T01:02:55.907Z","updated_at":"2026-06-10T01:02:58.651Z","avatar_url":"https://github.com/pushpad.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pushpad - Web Push Notifications\n\n[![pypi](https://img.shields.io/pypi/v/pushpad.svg)](https://pypi.python.org/pypi/pushpad)\n![Build Status](https://github.com/pushpad/pushpad-python/workflows/CI/badge.svg)\n \n[Pushpad](https://pushpad.xyz) is a service for sending push notifications from websites and web apps. It uses the **Push API**, which is a standard supported by all major browsers (Chrome, Firefox, Opera, Edge, Safari).\n\nThe notifications are delivered in real time even when the users are not on your website and you can target specific users or send bulk notifications.\n\n## Installation\n\nUse [pip](http://pip-installer.org/):\n\n```bash\npip install pushpad\n```\n\n## Getting started\n\nFirst you need to sign up to Pushpad and create a project there.\n\nThen set your authentication credentials and project:\n\n```python\nfrom pushpad import Pushpad\n\nclient = Pushpad(auth_token='token', project_id=123)\n```\n\n- `auth_token` can be found in the user account settings. \n- `project_id` can be found in the project settings.\n\nIf your application uses multiple projects, instead of setting a `project_id` on client, you can pass the `project_id` as a param to methods:\n\n```python\nclient.notifications.create(body=\"Your message\", project_id=123)\n\nclient.notifications.all(page=1, project_id=123)\n\nclient.subscriptions.count(project_id=123)\n\n# ...\n```\n\n## Collecting user subscriptions to push notifications\n\nYou can subscribe the users to your notifications using the Javascript SDK, as described in the [getting started guide](https://pushpad.xyz/docs/pushpad_pro_getting_started).\n\nIf you need to generate the HMAC signature for the `uid` you can use this helper:\n\n```python\nclient.signature_for(current_user_id)\n```\n\n## Sending push notifications\n\nUse `client.notifications.create()` (or the `send()` alias) to create and send a notification:\n\n```python\n# send a simple notification\nclient.notifications.send(body=\"Your message\")\n\n# a more complex notification with all the optional fields\nclient.notifications.create(\n    # required, the main content of the notification\n    body=\"Hello world!\",\n\n    # optional, the title of the notification (defaults to your project name)\n    title=\"Website Name\",\n\n    # optional, open this link on notification click (defaults to your project website)\n    target_url=\"https://example.com\",\n\n    # optional, the icon of the notification (defaults to the project icon)\n    icon_url=\"https://example.com/assets/icon.png\",\n\n    # optional, the small icon displayed in the status bar (defaults to the project badge)\n    badge_url=\"https://example.com/assets/badge.png\",\n\n    # optional, an image to display in the notification content\n    # see https://pushpad.xyz/docs/sending_images\n    image_url=\"https://example.com/assets/image.png\",\n\n    # optional, drop the notification after this number of seconds if a device is offline\n    ttl=604800,\n\n    # optional, prevent Chrome on desktop from automatically closing the notification after a few seconds\n    require_interaction=True,\n\n    # optional, enable this option if you want a mute notification without any sound\n    silent=False,\n\n    # optional, enable this option only for time-sensitive alerts (e.g. incoming phone call)\n    urgent=False,\n\n    # optional, a string that is passed as an argument to action button callbacks\n    custom_data=\"123\",\n\n    # optional, add some action buttons to the notification\n    # see https://pushpad.xyz/docs/action_buttons\n    actions=[\n        {\n            \"title\": \"My Button 1\",\n            \"target_url\": \"https://example.com/button-link\", # optional\n            \"icon\": \"https://example.com/assets/button-icon.png\", # optional\n            \"action\": \"myActionName\" # optional\n        }\n    ],\n\n    # optional, bookmark the notification in the Pushpad dashboard (e.g. to highlight manual notifications)\n    starred=True,\n\n    # optional, use this option only if you need to create scheduled notifications (max 5 days)\n    # see https://pushpad.xyz/docs/schedule_notifications\n    send_at=\"2025-11-20T10:09:00Z\",\n\n    # optional, add the notification to custom categories for stats aggregation\n    # see https://pushpad.xyz/docs/monitoring\n    custom_metrics=[\"examples\", \"another_metric\"], # up to 3 metrics per notification\n)\n\n# deliver to a group of users\nclient.notifications.create(body=\"Hello world!\", uids=[\"user1\", \"user2\"])\n\n# deliver to some users only if they have a given preference\n# e.g. only \"users\" who have a interested in \"events\" will be reached\nclient.notifications.create(body=\"Hello world!\", uids=[\"user1\", \"user2\"], tags=[\"events\"])\n\n# deliver to segments\n# e.g. any subscriber that has the tag \"segment1\" OR \"segment2\"\nclient.notifications.create(body=\"Hello world!\", tags=[\"segment1\", \"segment2\"])\n\n# you can use boolean expressions \n# they can include parentheses and the operators !, \u0026\u0026, || (from highest to lowest precedence)\n# https://pushpad.xyz/docs/tags\nclient.notifications.create(body=\"Hello world!\", tags=[\"zip_code:28865 \u0026\u0026 !optout:local_events || friend_of:Organizer123\"])\nclient.notifications.create(body=\"Hello world!\", tags=[\"tag1 \u0026\u0026 tag2\", \"tag3\"]) # equal to 'tag1 \u0026\u0026 tag2 || tag3'\n\n# deliver to everyone\nclient.notifications.create(body=\"Hello world!\")\n```\n\nYou can set the default values for most fields in the project settings. See also [the docs](https://pushpad.xyz/docs/rest_api#notifications_api_docs) for more information about notification fields.\n\nIf you try to send a notification to a user ID, but that user is not subscribed, that ID is simply ignored.\n\nThese fields are returned by the API:\n\n```python\nresult = client.notifications.create(**payload)\n\n# Notification ID\nprint(result.id) # =\u003e 1000\n\n# Estimated number of devices that will receive the notification\n# Not available for notifications that use send_at\nprint(result.scheduled) # =\u003e 5\n\n# Available only if you specify some user IDs (uids) in the request:\n# it indicates which of those users are subscribed to notifications.\n# Not available for notifications that use send_at\nprint(result.uids) # =\u003e [\"user1\", \"user2\"]\n\n# The time when the notification will be sent.\n# Available for notifications that use send_at\nprint(result.send_at) # =\u003e \"2025-10-30T10:09:00.000Z\"\n```\n\n## Getting push notification data\n\nYou can retrieve data for past notifications:\n\n```python\nnotification = client.notifications.get(42)\n\n# get basic attributes\nnotification.id # =\u003e 42\nnotification.title # =\u003e 'Foo Bar'\nnotification.body # =\u003e 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.'\nnotification.target_url # =\u003e 'https://example.com'\nnotification.ttl # =\u003e 604800\nnotification.require_interaction # =\u003e False\nnotification.silent # =\u003e False\nnotification.urgent # =\u003e False\nnotification.icon_url # =\u003e 'https://example.com/assets/icon.png'\nnotification.badge_url # =\u003e 'https://example.com/assets/badge.png'\nnotification.created_at # =\u003e '2025-07-06T10:09:14.000Z'\n\n# get statistics\nnotification.scheduled_count # =\u003e 1\nnotification.successfully_sent_count # =\u003e 4\nnotification.opened_count # =\u003e 2\n```\n\nOr for multiple notifications of a project at once:\n\n```python\nnotifications = client.notifications.all(page=1)\n\n# same attributes as for single notification in example above\nnotifications[0].id # =\u003e 42\nnotifications[0].title # =\u003e 'Foo Bar'\n```\n\nThe REST API paginates the result set. You can pass a `page` parameter to get the full list in multiple requests.\n\n```python\nnotifications = client.notifications.all(page=2)\n```\n\n## Scheduled notifications\n\nYou can create scheduled notifications that will be sent in the future:\n\n```python\nimport datetime\n\nscheduled = client.notifications.create(\n  body=\"This notification will be sent after 60 seconds\",\n  send_at=(datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(seconds=60)).isoformat()\n)\n```\n\nYou can also cancel a scheduled notification:\n\n```python\nclient.notifications.cancel(scheduled.id)\n```\n\n## Getting subscription count\n\nYou can retrieve the number of subscriptions for a given project, optionally filtered by `tags` or `uids`:\n\n```python\nclient.subscriptions.count() # =\u003e 100\nclient.subscriptions.count(uids=[\"user1\"]) # =\u003e 2\nclient.subscriptions.count(tags=[\"sports\"]) # =\u003e 10\nclient.subscriptions.count(tags=[\"sports \u0026\u0026 travel\"]) # =\u003e 5\nclient.subscriptions.count(uids=[\"user1\"], tags=[\"sports \u0026\u0026 travel\"]) # =\u003e 1\n```\n\n## Getting push subscription data\n\nYou can retrieve the subscriptions for a given project, optionally filtered by `tags` or `uids`:\n\n```python\nclient.subscriptions.all()\nclient.subscriptions.all(uids=[\"user1\"])\nclient.subscriptions.all(tags=[\"sports\"])\nclient.subscriptions.all(tags=[\"sports \u0026\u0026 travel\"])\nclient.subscriptions.all(uids=[\"user1\"], tags=[\"sports \u0026\u0026 travel\"])\n```\n\nThe REST API paginates the result set. You can pass `page` and `per_page` parameters to get the full list in multiple requests.\n\n```python\nsubscriptions = client.subscriptions.all(page=2)\n```\n\nYou can also retrieve the data of a specific subscription if you already know its id:\n\n```python\nclient.subscriptions.get(123)\n```\n\n## Updating push subscription data\n\nUsually you add data, like user IDs and tags, to the push subscriptions using the [JavaScript SDK](https://pushpad.xyz/docs/javascript_sdk_reference) in the frontend.\n\nHowever you can also update the subscription data from your server:\n\n```python\nsubscriptions = client.subscriptions.all(uids=[\"user1\"])\n\nfor subscription in subscriptions:\n  # update the user ID associated to the push subscription\n  client.subscriptions.update(subscription.id, uid=\"myuser1\")\n  \n  # update the tags associated to the push subscription\n  tags = list(subscription.tags or [])\n  tags.append(\"another_tag\")\n  client.subscriptions.update(subscription.id, tags=tags)\n```\n\n## Importing push subscriptions\n\nIf you need to [import](https://pushpad.xyz/docs/import) some existing push subscriptions (from another service to Pushpad, or from your backups) or if you simply need to create some test data, you can use this method:\n\n```python\nattributes = {\n  \"endpoint\": \"https://example.com/push/f7Q1Eyf7EyfAb1\", \n  \"p256dh\": \"BCQVDTlYWdl05lal3lG5SKr3VxTrEWpZErbkxWrzknHrIKFwihDoZpc_2sH6Sh08h-CacUYI-H8gW4jH-uMYZQ4=\",\n  \"auth\": \"cdKMlhgVeSPzCXZ3V7FtgQ==\",\n  \"uid\": \"exampleUid\", \n  \"tags\": [\"exampleTag1\", \"exampleTag2\"]\n}\n\nsubscription = client.subscriptions.create(**attributes)\n```\n\nPlease note that this is not the standard way to collect subscriptions on Pushpad: usually you subscribe the users to the notifications using the [JavaScript SDK](https://pushpad.xyz/docs/javascript_sdk_reference) in the frontend.\n\n## Deleting push subscriptions\n\nUsually you unsubscribe a user from push notifications using the [JavaScript SDK](https://pushpad.xyz/docs/javascript_sdk_reference) in the frontend (recommended).\n\nHowever you can also delete the subscriptions using this library. Be careful, the subscriptions are permanently deleted!\n\n```python\nclient.subscriptions.delete(id)\n```\n\n## Managing projects\n\nProjects are usually created manually from the Pushpad dashboard. However you can also create projects from code if you need advanced automation or if you manage [many different domains](https://pushpad.xyz/docs/multiple_domains).\n\n```python\nattributes = {\n  # required attributes\n  \"sender_id\": 123,\n  \"name\": \"My project\",\n  \"website\": \"https://example.com\",\n  \n  # optional configurations\n  \"icon_url\": \"https://example.com/icon.png\",\n  \"badge_url\": \"https://example.com/badge.png\",\n  \"notifications_ttl\": 604800,\n  \"notifications_require_interaction\": False,\n  \"notifications_silent\": False\n}\n\nproject = client.projects.create(**attributes)\n```\n\nYou can also find, update and delete projects:\n\n```python\nprojects = client.projects.all()\nfor p in projects:\n  print(f\"Project {p.id}: {p.name}\")\n\nexisting_project = client.projects.get(123)\n\nclient.projects.update(existing_project.id, name=\"The New Project Name\")\n\nclient.projects.delete(existing_project.id)\n```\n\n## Managing senders\n\nSenders are usually created manually from the Pushpad dashboard. However you can also create senders from code.\n\n```python\nattributes = {\n  # required attributes\n  \"name\": \"My sender\",\n  \n  # optional configurations\n  # do not include these fields if you want to generate them automatically\n  \"vapid_private_key\": \"-----BEGIN EC PRIVATE KEY----- ...\",\n  \"vapid_public_key\": \"-----BEGIN PUBLIC KEY----- ...\"\n}\n\nsender = client.senders.create(**attributes)\n```\n\nYou can also find, update and delete senders:\n\n```python\nsenders = client.senders.all()\nfor s in senders:\n  print(f\"Sender {s.id}: {s.name}\")\n\nexisting_sender = client.senders.get(987)\n\nclient.senders.update(existing_sender.id, name=\"The New Sender Name\")\n\nclient.senders.delete(existing_sender.id)\n```\n\n## Error handling\n\nAPI requests can raise errors, described by a `PushpadAPIError` that exposes the HTTP status code, reason, and response body. Network issues and other errors raise a `PushpadClientError`.\n\n```python\nfrom pushpad import Pushpad, PushpadAPIError, PushpadClientError\n\nclient = Pushpad(auth_token=\"token\", project_id=123)\n\ntry:\n  client.notifications.create(body=\"Hello\")\nexcept PushpadAPIError as error:  # HTTP error from the API\n  print(error.status_code, error.reason, error.response_body)\nexcept PushpadClientError as error:  # network error or other errors\n  print(error)\n```\n\n## Type hints\n\nThis library includes types for request parameters and responses to improve the developer experience. We recommend enabling Pylance, Pyright, or Python IntelliSense in your code editor for the best experience.\n\n```python\nfrom pushpad import Pushpad\n\nclient = Pushpad(auth_token=\"token\", project_id=123)\n\n# parameters, like body, have a specific type\n# you can immediately see if a parameter is wrong\nresult = client.notifications.create(body=\"Hello\")\n\n# the result is a structured object\n# it is always clear what attributes can be accessed on the resource\nprint(result.id)\n```\n\n## Documentation\n\n- Pushpad REST API reference: https://pushpad.xyz/docs/rest_api\n- Getting started guide (for collecting subscriptions): https://pushpad.xyz/docs/pushpad_pro_getting_started\n- JavaScript SDK reference (frontend): https://pushpad.xyz/docs/javascript_sdk_reference\n\n## License\n\nThe library is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpushpad%2Fpushpad-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpushpad%2Fpushpad-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpushpad%2Fpushpad-python/lists"}