Skip to main content

PushNow Python SDK

中文说明

Python 3.10+ and Node.js 22+ are required. This is a subprocess binding to the bundled, pinned HPKE runtime, not native Python cryptography. No Python runtime dependencies are needed. Read CONTRACT.md for the complete API, trust model, attachment limits, errors, scheduling and retry semantics.

Local Setup

Run from this folder:

npm --prefix runtime ci --ignore-scripts
python3 -m unittest discover -s tests -p 'test_*.py'
npm --prefix runtime test

Install from PyPI after publication:

pip install pushnow

For local development, pip install . installs the Python package and bundled runtime bridge. Run npm --prefix pushnow/runtime ci --ignore-scripts after installation or source checkout to install the pinned HPKE dependency beside the bridge runtime.

Authorize With an Account Token

import os
from pushnow import Client

client = Client()
pending = client.begin_account_authorization(
    'https://api.pushnow.dev',
    os.environ['PUSHNOW_ACCESS_TOKEN'],
    'Python automation',
)
print(pending['authorization']['user_code'])  # Public approval code only.
print(pending['fingerprint'])                 # Sender fingerprint.
config = client.authorize_account(pending)    # Waits for approval; do not print.

Use an access token from a signed-in PushNow app or trusted dashboard session. The token only creates an account-bound authorization; it cannot encrypt messages by itself. Store the returned config securely for reuse. examples/authorize.py creates a new mode-0600 config file without overwriting an existing one.

Send and Retry

client = Client(config, runtime='/absolute/path/to/runtime/main.js')
devices = client.recipients()['devices']
outbox = client.prepare(
    title='Build finished', body='The artifact is ready.', sound='chime',
    deviceIds=[devices[0]['id']],
    links=['https://example.com/build/123'],
    files=[{'path': '/tmp/report.pdf', 'mime': 'application/pdf'}],
    images=[{'path': '/tmp/preview.png', 'mime': 'image/png'}],
    icon={'path': '/tmp/icon.png', 'mime': 'image/png'},
)
# Persist outbox securely before attempting submission.
result = client.retry(outbox)

Omit deviceIds for all eligible devices. pushEnabled=False or deviceIds=[] saves inbox-only. scheduledAt and expiresAt accept future timezone-qualified ISO strings within 30 days. Option names are camelCase, matching the JSON wire terminology. sound='default', sound='silent' and sound='chime' are supported public routing options. Omit sound to use the default behavior. sound=None and unknown values fail with INVALID_SOUND before uploads. Silent keeps the visible alert; chime maps to the app's pushnow-chime.wav. Neither changes inbox-only settings.

client.send(title='Ready', body='Done') is the one-call convenience API and returns {'envelope': ..., 'result': ...}. Use prepare/persist/retry for durable recovery from an uncertain response. Request logs are available in client.request_logs. Catch PushNowError for redacted codes; do not log config or pending objects.

node= selects a Node executable and timeout= overrides the 660-second process deadline. A timeout does not prove that the server rejected a message. Retry the saved envelope to resolve an uncertain outcome.

Example Commands

export PUSHNOW_ACCESS_TOKEN='your signed-in account access token'
python3 examples/authorize.py
python3 examples/send.py

The send example reads private-config.json, saves a private encrypted outbox, then submits it. Source upload should exclude both files and node_modules.

Metadata

Release files for pushnow 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pushnow 0.1.1
File Size Uploaded
pushnow-0.1.1.tar.gz 15.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pushnow 0.1.1
File Interpreter ABI Platform
pushnow-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 33.3 kB

Release files / pushnow-0.1.1.tar.gz

Download URL pushnow-0.1.1.tar.gz
Size 15.6 kB
Tags Source
SHA-256 checksum
How to use checksums
3997ee28dbcb316ee338764d9740f3e93d1e9ff1daf8460b7cd0be1681675965
BLAKE2b-256 checksum
How to use checksums
ee8a84a8e457f60c00c42408c2fe63929de9c6da03d83255e02f9c710a733afc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 14, 2026.

Transparency log

Release files / pushnow-0.1.1-py3-none-any.whl

Download URL pushnow-0.1.1-py3-none-any.whl
Size 17.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9ca30d2149d4fa4db2a73c6f89c843acfcacc412878f4296d6b0a28dc5c43008
BLAKE2b-256 checksum
How to use checksums
c4191423323cb3bcd370da4fb0a6286a53ff8157bcccf320ca0b01a4da97f6e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 14, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page