Getting Discourse topics older than a certain date with curl


#1

Hi,

I try to create a list of Discourse topics that are older than 5 days (created 5 days ago or before that) with “curl GET …” command.
Currently I apply the following command to get a list of topics:
topiclist=$(curl -k -X GET “https://mydiscoursesite.com/search.json?q=tags:mytag+status:open”)
…and then I parse the output (topiclist above) with jq for sorting out the old topics.

I wonder if it is possible to do this by adding the date info to the curl command and skip the parsing task (done with jq).


(Sam Saffron) #2

We have before and after to filter dates, use the advanced search UI to get the param names.


(Joffrey Jaffeux) #3

Inspecting XHR requests when using search UI will show this:

Request URL:https://meta.discourse.org/search?q=before%3A2017-06-06
Request Method:GET

The curl request to get json content will be as simple as:

curl "https://meta.discourse.org/search.json?q=before:2017-06-06"

#4

Thanks a lot! It worked and it worked well :slight_smile:


#5

By the way, where may I find a list of (all) advanced search UI parameters?
Are there usage examples too? Like the one that Joffrey wrote above?
I tried to google it but I found only info about the graphical web UI. I need to know the parameters for using with curl command.


(Joffrey Jaffeux) #6

Easiest way is probably to open network inspector and play with params in UI:


#7

Thank you Joffrey,
But for doing this I have to know that there are parameters like

  • in that may have value “private” and “seen”
  • status that could be “open” and “closed”
  • before that should have a parameter like “2017-06-14”.
    …and so on.
    Is this info (completely or partly) listed anywhere?

#8

Ok, you mean what is available is what is seen here in advanced search:
https://meta.discourse.org/search?expanded=true

I found these parameters
min_post_count
in
"#"
"@"
tags
in
before
after


(Mittineague) #9

You may find useful information by looking at this file


(Jay Pfaffman) #10

Perhaps I misunderstand, but It seems like you have missed that at least most of them are easily attainable on the advanced search page (and if not you, someone else stumbling here might have missed the most obvious solution). Just click “options” after you click the search icon.


(cpradio) #11

The screenshots in
https://meta.discourse.org/t/bring-back-power-user-shortcuts-for-search-options/61202?source_topic_id=64415

Should also be helpful