Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get the lastest message of a topic in JSON format from api? #1185

Open
winteris opened this issue Sep 20, 2024 · 3 comments
Open

How to get the lastest message of a topic in JSON format from api? #1185

winteris opened this issue Sep 20, 2024 · 3 comments
Labels
question This is a question

Comments

@winteris
Copy link

winteris commented Sep 20, 2024

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?

@winteris winteris added the question This is a question label Sep 20, 2024
@winteris winteris changed the title How to get a lastest How to get the lastest message of a topic in JSON format from api? Sep 20, 2024
@wunter8
Copy link
Contributor

wunter8 commented 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

@winteris
Copy link
Author

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?

@winteris
Copy link
Author

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 up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question This is a question
Projects
None yet
Development

No branches or pull requests

2 participants