[GH-ISSUE #1185] How to get the lastest message of a topic in JSON format from api? #835

Closed
opened 2026-05-07 00:27:54 +02:00 by BreizhHardware · 3 comments

Originally created by @winteris on GitHub (Sep 20, 2024).
Original GitHub issue: https://github.com/binwiederhier/ntfy/issues/1185

Question

I just got a file named json.ndjson when I start a http request in safari and other internet explorer whit this URL:
ntfy.sh/stats/json?poll=1
Exactly, I just want to get the lastest json string using a get http request in iOS shortcuts, but I can’t parse out the message.
Can I get a JSON string directly with the api?
https://docs.ntfy.sh/examples/
Examples in docs all are send and there is no a get example , can someone give me some help?

Originally created by @winteris on GitHub (Sep 20, 2024). Original GitHub issue: https://github.com/binwiederhier/ntfy/issues/1185 <!-- Before you submit, consider asking on Discord/Matrix instead. You'll usually get an answer sooner, and there are more people there to help! - Discord: https://discord.gg/cT7ECsZj9w - Matrix: https://matrix.to/#/#ntfy:matrix.org / https://matrix.to/#/#ntfy-space:matrix.org --> :question: **Question** <!-- Go ahead and ask your question here :) --> I just got a file named `json.ndjson` when I start a http request in safari and other internet explorer whit this URL: `ntfy.sh/stats/json?poll=1` Exactly, I just want to get the lastest json string using a get http request in iOS shortcuts, but I can’t parse out the message. Can I get a JSON string directly with the api? https://docs.ntfy.sh/examples/ Examples in docs all are `send` and there is no a `get` example , can someone give me some help?
BreizhHardware 2026-05-07 00:27:54 +02:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@wunter8 commented on GitHub (Sep 20, 2024):

You can't get only the latest message using the API right now if you haven't been listening to the topic and tracking message IDs. /json?poll=1 is going to be your best option. Then just truncate the response/only look at the last line of the response

<!-- gh-comment-id:2363490488 --> @wunter8 commented on GitHub (Sep 20, 2024): You can't get _only_ the latest message using the API right now if you haven't been listening to the topic and tracking message IDs. `/json?poll=1` is going to be your best option. Then just truncate the response/only look at the last line of the response
Author
Owner

@winteris commented on GitHub (Sep 20, 2024):

Thank you for your reply.
I think I’ve followed the route you point out, but when I use /json?poll=1 to get all available messages, I got a json.ndjson file instead of a json string or text as the reponse., and then, I can’t parse out the message from the .ndjson file, in iOS shortcuts APP.
I think It will more useul if I got a text type of reponse instead of a file one. Could it possible? Or need a feature request to move it on?

<!-- gh-comment-id:2363547273 --> @winteris commented on GitHub (Sep 20, 2024): Thank you for your reply. I think I’ve followed the route you point out, but when I use `/json?poll=1` to get all available messages, I got a `json.ndjson` file instead of a json string or text as the reponse., and then, I can’t parse out the message from the `.ndjson` file, in iOS shortcuts APP. I think It will more useul if I got a `text` type of reponse instead of a `file` one. Could it possible? Or need a feature request to move it on?
Author
Owner

@winteris commented on GitHub (Sep 20, 2024):

Got it finally!
If I use ntfy.sh/topic/raw?poll=1, I’ll get a response in a text type.
But I still wish the /json?poll=1 could support text response if it is possible.

<!-- gh-comment-id:2364274834 --> @winteris commented on GitHub (Sep 20, 2024): Got it finally! If I use `ntfy.sh/topic/raw?poll=1`, I’ll get a response in a `text` type. But I still wish the `/json?poll=1` could support text response if it is possible.
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#835
No description provided.