plsremind for Python
A client for the plsremind hub. It connects to the gateway, keeps the state it is sent in memory, hands every change to listeners as a typed event and offers each call of the REST API as a method.
If you have used hikari, most of it will feel
familiar: event classes, @client.listen(), client.rest and client.cache.
It needs Python 3.12 or newer and depends on msgspec, aiohttp and tzdata. It works
with plsremind 0.1 or newer.
uv add plsremind # or: pip install plsremind
import os
import plsremind
client = plsremind.Client(
"https://remind.example.com",
token=os.environ["PLSREMIND_TOKEN"],
intents=plsremind.Intents.ITEMS | plsremind.Intents.DELIVERIES,
)
@client.listen()
async def on_item(event: plsremind.ItemCreateEvent) -> None:
print("new item:", event.item.title)
@client.listen()
async def on_delivery(event: plsremind.DeliveryCreateEvent) -> None:
await remind(event.delivery)
await client.rest.acknowledge_delivery(event.delivery.id, status=plsremind.DeliveryStatus.DELIVERED)
client.run()
run() blocks until SIGINT or SIGTERM and then closes the client. Inside a program with
its own event loop use await client.start() and await client.close(), or
async with client:. start() returns once the state of every user the session covers
is in the cache. From then on the client reconnects and resumes on its own. If the first
attempt fails, or the hub refuses the token or the intents, start() raises a
GatewayError and the client does not try again.
The rules
- Nothing is acknowledged for you. A reminder counts as delivered only when you call
client.rest.acknowledge_delivery. Until then the hub sends it again after every reconnect, with a growingattempt, and the SDK hands you every one of them. If you must not remind twice, remember theidyourself, as the example adapter does. - Objects are frozen data. What you receive is a
msgspec.Structwithout methods that cannot be changed. To change something, callclient.rest. The cache replaces objects instead of editing them, sobefore is aftertells you whether something changed. - Every HTTP call goes through
client.rest, and its answers do not touch the cache. The cache changes only through the gateway events that follow. - A connection names the user. A personal token acts for its one user, so
usercan be left out with it. With the token of a connection, passuser=...to every call and cache read that is about a user; leaving it out raises aTypeErrorbefore anything is sent.
Names and types
The gateway and the API reference describe what travels over the wire. Fields keep their names, and values arrive as the types Python has for them:
| In the API | In the SDK |
|---|---|
| an ID | plsremind.ID, a str |
| a moment as RFC 3339 text | an aware datetime.datetime, exact to the microsecond |
a duration as text (1d12h) |
plsremind.Duration, a datetime.timedelta |
a whole day (due_date) |
datetime.date |
a time of day in quiet hours (22:00) |
plsremind.ClockTime, a datetime.time |
a time zone (Europe/Berlin) |
zoneinfo.ZoneInfo |
fixed values (status, priority, kind) |
an enum, for example ItemStatus.DONE |
| a list | a tuple |
preferences on the profile |
a read-only mapping |
- A field with fixed values is always the enum. A value this version of the SDK does not
know yet arrives as the member
UNKNOWNinstead of failing the event. - A time zone the system does not know becomes UTC, with one warning per name in the log
(logger
plsremind). In the same way a duration or a time of day in a form this version cannot read becomes zero or midnight, with a warning. preferencesis read-only at its top level only: lists and objects inside it can still be changed, which changes nothing at the hub. Before Python 3.15 it is atypes.MappingProxyType, so aUsercannot be pickled or deep-copied there.- Fields and events the SDK does not know are skipped, so an older SDK keeps working against a newer hub.
- Methods of
client.resttake the same types.before=andafter=take anytimedelta; inside aReminderOverrideorQuietHourswriteplsremind.Duration(hours=3)andplsremind.ClockTime(22, 0). Adatetimeneeds a time zone, and a duration is whole minutes, from one minute up; anything else raises aValueErrorbefore it is sent.format_durationandparse_durationconvert between atimedeltaand the hub's text.
To keep something the SDK handed out, plsremind.to_json(delivery) writes it as JSON in
the hub's form and plsremind.from_json(data, plsremind.Delivery) reads it back. msgspec's
own encoder does not know Duration and ClockTime.
Events
@client.listen() reads the event class from the annotation of the listener's parameter;
@client.listen(plsremind.ItemCreateEvent) names it. A listener is an async def with
one parameter. client.subscribe and client.unsubscribe do the same without a
decorator, and await client.wait_for(SomeEvent, timeout=10, predicate=...) waits for one
event.
| Gateway | Class | Carries |
|---|---|---|
item.created |
ItemCreateEvent |
item |
item.updated |
ItemUpdateEvent |
item, old_item |
item.deleted |
ItemDeleteEvent |
item_id, old_item |
list.created, list.updated, list.deleted |
ListCreateEvent, ListUpdateEvent, ListDeleteEvent |
list or list_id, old_list |
subitem.created, subitem.updated, subitem.deleted |
SubitemCreateEvent, SubitemUpdateEvent, SubitemDeleteEvent |
subitem or subitem_id and item_id, old_subitem |
reminder.created, reminder.deleted |
ReminderCreateEvent, ReminderDeleteEvent |
reminder or reminder_id and item_id, old_reminder |
plan.updated |
PlanUpdateEvent |
plan, old_plan |
user.updated |
UserUpdateEvent |
user, old_user |
connection.updated |
ConnectionUpdateEvent |
connection |
delivery.created |
DeliveryCreateEvent |
delivery |
delivery.closed |
DeliveryCloseEvent |
delivery_id, status |
delivery.test |
DeliveryTestEvent |
test; answer with client.rest.report_test |
user.sync |
UserSyncEvent |
one part of a user's state |
user.gone |
UserGoneEvent |
- Every event about a user has
user_id. Change events also haveactor(compareactor.idwithclient.principal.idto recognise your own changes) andnonce, thenonce=of the REST call that made the change.actorisNonefor what the hub does by itself, such as removing a manual reminder whose time has passed. old_*is the object the cache held before the change, orNoneif it held none.- Listening to a base class gets every event below it:
ItemEvent,ListEvent,DeliveryEvent,ChangeEvent,UserEvent, orEventfor everything. - The cache is already up to date when a listener runs. Each listener runs as a task of its own, started in the order of the events and not waited for, so a slow listener holds up neither the connection nor other listeners.
- An event nobody listens to, and the cache does not need, is never decoded.
- A
UserGoneEventalso comes for a user the cache held whom a new session no longer names, for example one who switched a connection off while it could not resume. - If a change arrives that this version cannot read, the client logs it and starts the
session over, so the cache cannot quietly differ from the hub. If it cannot read the
hub's login answer or a user's state at all, it gives up with a
ClosedEvent. wait_forraises aGatewayErrorif the client is closed, or turned away, meanwhile.
The client adds events of its own:
| Class | When |
|---|---|
ReadyEvent |
after every new login, once the state is complete |
UserReadyEvent |
one user's state is complete |
ResumedEvent |
a dropped connection was picked up again and missed nothing |
DisconnectedEvent |
the connection is gone and is being opened again; once per outage |
ClosedEvent |
the client gave up: the first connect failed, or the hub refuses the token or the intents |
ExceptionEvent |
a listener raised |
A listener that raises never ends the connection. Without a listener for
ExceptionEvent the exception goes to the log with its traceback.
client.status is a ClientStatus: IDLE, CONNECTING, CONNECTED, RECONNECTING or
CLOSED. close() ends the session and every retry, waits up to five seconds for
running listeners and cancels the rest. The cache stays readable, and start() works
again. After a ClosedEvent the client has let go of its connections by itself.
The cache
cache = client.cache
cache.get_profile()
cache.get_lists()
cache.get_items() # every open item, with subitems and manual reminders
cache.get_item(item_id) # an open item, or a completed one from the history
cache.get_history() # completed items, newest first; needs Intents.HISTORY
cache.get_plans()
cache.get_users() # for a connection: the IDs of everyone it may act for
cache.get_items(user_id)
-
What the cache holds follows from the intents:
USERSgives the profile,LISTS,ITEMSandPLANStheir parts,HISTORYthe completed items. A client withIntents.DELIVERIESalone keeps no state at all. -
Reading is synchronous and returns the objects the cache holds; nothing is copied. A tuple stays the very same tuple until something of its kind changes for that user.
-
get_history()starts with the 1000 most recently completed items and grows with every item completed while connected.get_history_cursor()continues it over REST:cursor = client.cache.get_history_cursor() if cursor is not None: async for item in plsremind.paginate( client.rest.list_items, status=plsremind.ItemStatus.DONE, sort=plsremind.ItemSort.COMPLETED, order=plsremind.SortOrder.DESCENDING, cursor=cursor, ): ...
-
The cache does not filter or sort beyond that. Build views like "overdue" on top.
REST
Every operation of the API reference that a token may call is a method of client.rest,
named after its operationId in snake_case: create_item, update_item,
list_lists, acknowledge_delivery. What only a browser session may do (administration,
managing tokens, passwords, signing in) is not part of the SDK.
item = await client.rest.create_item(title="Hand in the report", due_at=deadline)
await client.rest.update_item(item.id, status=plsremind.ItemStatus.DONE)
await client.rest.update_item(item.id, due_at=None) # None clears, leaving it out keeps
await client.rest.create_reminder(item.id, after=datetime.timedelta(hours=2))
-
IDs from the path come first, everything else is a keyword. Writes take
nonce=, which comes back in every event the call causes. -
Calls about the account itself (
update_user,list_identities, changing reminder plans,list_user_connections,set_connection_grant,list_reminder_log) take nouser: the hub opens them to the user alone, and with the token of a connection they raise aTypeError. -
Listings return a
Pagewithdataandnext_cursor.plsremind.paginatewalks a listing to its end. -
An ID that is empty,
.or..raises aValueErrorbefore anything is sent, so text a person typed can be passed on as an ID without reaching another call. -
client.restaccepts the ID of a personal token's own user asuser=. ARESTClienton its own does not know that ID, and the hub answers it with a 404: leaveuserout there. -
RESTClientalso works alone, for a script that needs no gateway:async with plsremind.RESTClient(url, token=token) as rest: for delivery in await rest.list_deliveries(): ...
-
A call the hub answers with an error raises an
APIErrorwithstatus,code,messageandfields. Its subclasses follow the status:BadRequestError,UnauthorizedError,ForbiddenError,NotFoundError,ConflictError,RateLimitedError,ServerError. No answer, or one that cannot be read, raises aNetworkError. All of them derive fromPlsremindError. -
A call turned away for the rate limit is tried again up to three times when the hub asks for a wait under 30 seconds;
rest_retry=Falseon the client switches that off. Nothing else is retried. A call may take 30 seconds (rest_timeout=). -
session=onClientandRESTClienttakes anaiohttp.ClientSessionof your own, for example to go through a proxy. -
The client asks the hub where its gateway listens, and the hub names its public address. A client that reaches the hub by another address, such as one inside a container network, passes
gateway_url="ws://hub:8080/api/v1/gateway".
A connection
client = plsremind.Client(url, token=connection_token, intents=plsremind.Intents.DELIVERIES)
@client.listen()
async def on_delivery(event: plsremind.DeliveryCreateEvent) -> None:
delivery = event.delivery
for account in delivery.user.external_ids: # the user's accounts at your provider
await send(account, delivery.item.title, language=delivery.user.locale)
await client.rest.acknowledge_delivery(delivery.id, status=plsremind.DeliveryStatus.DELIVERED)
async def add_item(account: str, title: str) -> None:
found = await client.rest.lookup_user(account)
await client.rest.create_item(title=title, user=found.id)
If a reminder cannot reach its user, say so with
status=plsremind.DeliveryStatus.FAILED, reason="direct messages are closed". The reason
is shown to the user, and the delivery is not tried again.
Working on the SDK
cd sdk/python
uv run --group nox nox # format, lint, type check, unit tests
uv run --group nox nox -s hub # needs Docker and Go, starts a real hub
Metadata
Release files for plsremind 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| plsremind-0.1.1.tar.gz | 36.1 kB | With provenance | Details for plsremind-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| plsremind-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for plsremind-0.1.1-py3-none-any.whl |
Total release size: 79.2 kB
Release files / plsremind-0.1.1.tar.gz
| Download URL | plsremind-0.1.1.tar.gz |
|---|---|
| Size | 36.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d5dd114cae915cf49542d45200f7d192869be61a35504c8b2e9d5dfbe0992f68
|
|
BLAKE2b-256 checksum How to use checksums |
fdf0b72283ee9d79fddd320a66e851ed276d9d5856564c292e8861794fdb11c3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Dec 2, 2026.
Transparency logRelease files / plsremind-0.1.1-py3-none-any.whl
| Download URL | plsremind-0.1.1-py3-none-any.whl |
|---|---|
| Size | 43.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9367a3c3b3817aca0a38a2811ff712083f3169f30dd25f7195ec8155088fc64a
|
|
BLAKE2b-256 checksum How to use checksums |
1fc3eb3c4d83d34b298b95f47b5fa529ae33b27a1e828d2342e8591df15b6eb0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Dec 2, 2026.
Transparency logSecurity for plsremind 0.1.1
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for plsremind-0.1.1.tar.gz
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 Dec 2, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.