[PR #1593] Add optional limit parameter to JSON/SSE/raw/WS poll API #1653

Open
opened 2026-05-07 01:03:05 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/binwiederhier/ntfy/pull/1593
Author: @epifeny
Created: 2/5/2026
Status: 🔄 Open

Base: mainHead: feature/json-poll-limit


📝 Commits (1)

  • 5e1316a feat(server): optional limit for poll subscriptions (rebased on upstream)

📊 Changes

2 files changed (+45 additions, -8 deletions)

View changed files

📝 docs/subscribe/api.md (+14 -0)
📝 server/server.go (+31 -8)

📄 Description

Supports limit=1 (or any positive N) to return at most that many messages, the most recent ones. No limit or invalid value keeps existing behavior (return all). Useful for Uptime Kuma and similar monitors that expect a single JSON to parse.

This is an example that I used from building the image locally and testing it.

Request

http://192.168.1.72:8080/limit/json?poll=1&since=1h&limit=1&tags=backups

Response with limit=1

{"id":"XfRdb8pOALu3","time":1770322959,"expires":1770366159,"event":"message","topic":"limit","title":"vzbackup status","message":"vzbackup succeeded on 20250205 and it's size is xxGB","priority":3,"tags":["proxmox","success","backups"]}

Response with limit=2

{"id":"UI9UqYMVlTQA","time":1770322630,"expires":1770365830,"event":"message","topic":"limit","title":"vzbackup status","message":"vzbackup succeeded on 20250205 and it's size is xxGB","priority":3,"tags":["proxmox","success","backups"]}
{"id":"XfRdb8pOALu3","time":1770322959,"expires":1770366159,"event":"message","topic":"limit","title":"vzbackup status","message":"vzbackup succeeded on 20250205 and it's size is xxGB","priority":3,"tags":["proxmox","success","backups"]}

For backwards compatibility, without limit= at all, works as it does before this change

{"id":"9pv8pibVMGpA","time":1770322627,"expires":1770365827,"event":"message","topic":"limit","title":"vzbackup status","message":"vzbackup succeeded on 20250205 and it's size is xxGB","priority":3,"tags":["proxmox","success","backups"]}
{"id":"Nd79nMfLIp7n","time":1770322630,"expires":1770365830,"event":"message","topic":"limit","title":"vzbackup status","message":"vzbackup succeeded on 20250205 and it's size is xxGB","priority":3,"tags":["proxmox","success","backups"]}
{"id":"0V4tsYTy6nfa","time":1770322630,"expires":1770365830,"event":"message","topic":"limit","title":"vzbackup status","message":"vzbackup succeeded on 20250205 and it's size is xxGB","priority":3,"tags":["proxmox","success","backups"]}
{"id":"UI9UqYMVlTQA","time":1770322630,"expires":1770365830,"event":"message","topic":"limit","title":"vzbackup status","message":"vzbackup succeeded on 20250205 and it's size is xxGB","priority":3,"tags":["proxmox","success","backups"]}
{"id":"XfRdb8pOALu3","time":1770322959,"expires":1770366159,"event":"message","topic":"limit","title":"vzbackup status","message":"vzbackup succeeded on 20250205 and it's size is xxGB","priority":3,"tags":["proxmox","success","backups"]}

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/binwiederhier/ntfy/pull/1593 **Author:** [@epifeny](https://github.com/epifeny) **Created:** 2/5/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feature/json-poll-limit` --- ### 📝 Commits (1) - [`5e1316a`](https://github.com/binwiederhier/ntfy/commit/5e1316aff46ae082e7ed94d1754cdaa32d57cda5) feat(server): optional limit for poll subscriptions (rebased on upstream) ### 📊 Changes **2 files changed** (+45 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `docs/subscribe/api.md` (+14 -0) 📝 `server/server.go` (+31 -8) </details> ### 📄 Description Supports `limit=1` (or any positive N) to return at most that many messages, the most recent ones. No limit or invalid value keeps existing behavior (return all). Useful for Uptime Kuma and similar monitors that expect a single JSON to parse. This is an example that I used from building the image locally and testing it. Request ``` http://192.168.1.72:8080/limit/json?poll=1&since=1h&limit=1&tags=backups ``` Response with `limit=1` ``` {"id":"XfRdb8pOALu3","time":1770322959,"expires":1770366159,"event":"message","topic":"limit","title":"vzbackup status","message":"vzbackup succeeded on 20250205 and it's size is xxGB","priority":3,"tags":["proxmox","success","backups"]} ``` Response with `limit=2` ``` {"id":"UI9UqYMVlTQA","time":1770322630,"expires":1770365830,"event":"message","topic":"limit","title":"vzbackup status","message":"vzbackup succeeded on 20250205 and it's size is xxGB","priority":3,"tags":["proxmox","success","backups"]} {"id":"XfRdb8pOALu3","time":1770322959,"expires":1770366159,"event":"message","topic":"limit","title":"vzbackup status","message":"vzbackup succeeded on 20250205 and it's size is xxGB","priority":3,"tags":["proxmox","success","backups"]} ``` For backwards compatibility, without `limit=` at all, works as it does before this change ``` {"id":"9pv8pibVMGpA","time":1770322627,"expires":1770365827,"event":"message","topic":"limit","title":"vzbackup status","message":"vzbackup succeeded on 20250205 and it's size is xxGB","priority":3,"tags":["proxmox","success","backups"]} {"id":"Nd79nMfLIp7n","time":1770322630,"expires":1770365830,"event":"message","topic":"limit","title":"vzbackup status","message":"vzbackup succeeded on 20250205 and it's size is xxGB","priority":3,"tags":["proxmox","success","backups"]} {"id":"0V4tsYTy6nfa","time":1770322630,"expires":1770365830,"event":"message","topic":"limit","title":"vzbackup status","message":"vzbackup succeeded on 20250205 and it's size is xxGB","priority":3,"tags":["proxmox","success","backups"]} {"id":"UI9UqYMVlTQA","time":1770322630,"expires":1770365830,"event":"message","topic":"limit","title":"vzbackup status","message":"vzbackup succeeded on 20250205 and it's size is xxGB","priority":3,"tags":["proxmox","success","backups"]} {"id":"XfRdb8pOALu3","time":1770322959,"expires":1770366159,"event":"message","topic":"limit","title":"vzbackup status","message":"vzbackup succeeded on 20250205 and it's size is xxGB","priority":3,"tags":["proxmox","success","backups"]} ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ntfy#1653
No description provided.