This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Search within posts based on tags using the Biostars API

Dear All,

I would be interested in knowing whether it is possible to search for a specific tag on the Biostars API. The official documentation (https://www.biostars.org/info/api/) contains information about searching for a particular post. However this query based on a specific post ID so it supposes that you know the ID itself. I am looking for a solution to check all the posts related to a tag (especially tag=CRISPR). Any idea would be highly appreciated.

Thanks :)

api meta

1 answer

AFAIK there's a POST-based tag API but it has problems. I created an issue on GitHub a while ago on this topic: https://github.com/ialbert/biostar-central/issues/923

Yep; I know about this option. However the problem here is that it will return only with the tags used and not the posts that are associated with a particular tag.

Right, that's true. One way to do that would be to get the HTML output of https://www.biostars.org/tag/crispr/ and search it for the first 50 /p/[0-9]+/ patterns, like so:

% curl -s https://www.biostars.org/tag/crispr/ | grep -oE "/p/[0-9]+/" | head -n 50 | xargs -I _url_ echo "https://www.biostars.org_url_"

https://www.biostars.org/p/9593423/
https://www.biostars.org/p/9591328/
https://www.biostars.org/p/9589499/
https://www.biostars.org/p/9587713/
https://www.biostars.org/p/9572921/
https://www.biostars.org/p/9572920/
https://www.biostars.org/p/9572754/
https://www.biostars.org/p/9570564/
https://www.biostars.org/p/9569587/
https://www.biostars.org/p/9564040/
https://www.biostars.org/p/9563793/
https://www.biostars.org/p/9563080/
https://www.biostars.org/p/9561203/
https://www.biostars.org/p/9556255/
https://www.biostars.org/p/9555879/
https://www.biostars.org/p/9554298/
https://www.biostars.org/p/9553308/
https://www.biostars.org/p/9552908/
https://www.biostars.org/p/9552261/
https://www.biostars.org/p/9545567/
https://www.biostars.org/p/9543360/
https://www.biostars.org/p/9542707/
https://www.biostars.org/p/9542591/
https://www.biostars.org/p/9490823/
https://www.biostars.org/p/9529239/
https://www.biostars.org/p/9529235/
https://www.biostars.org/p/9526493/
https://www.biostars.org/p/9521633/
https://www.biostars.org/p/9516471/
https://www.biostars.org/p/9513794/
https://www.biostars.org/p/9513266/
https://www.biostars.org/p/9510944/
https://www.biostars.org/p/9507324/
https://www.biostars.org/p/9504710/
https://www.biostars.org/p/9493846/
https://www.biostars.org/p/9492102/
https://www.biostars.org/p/9481994/
https://www.biostars.org/p/9481515/
https://www.biostars.org/p/9480112/
https://www.biostars.org/p/9479441/
https://www.biostars.org/p/9477203/
https://www.biostars.org/p/9475019/
https://www.biostars.org/p/9472410/
https://www.biostars.org/p/9468941/
https://www.biostars.org/p/9465695/
https://www.biostars.org/p/9465590/
https://www.biostars.org/p/495527/
https://www.biostars.org/p/494348/
https://www.biostars.org/p/488143/
https://www.biostars.org/p/480034/

The "first 50" hack can be avoided if you can use JS on the browser or a more advanced command line JS parsing option (I'm not conversant with command line JS parsing).

For example, on Firefox, I can get the same output using:

Array.from($("div.ui.divided.items").children()).map(x => "https://www.biostars.org/" + x.dataset.value).join("\n")

"https://www.biostars.org/9593423
https://www.biostars.org/9591328
https://www.biostars.org/9589499
https://www.biostars.org/9587713
https://www.biostars.org/9572921
https://www.biostars.org/9572920
https://www.biostars.org/9572754
https://www.biostars.org/9570564
https://www.biostars.org/9569587
https://www.biostars.org/9564040
https://www.biostars.org/9563793
https://www.biostars.org/9563080
https://www.biostars.org/9561203
https://www.biostars.org/9556255
https://www.biostars.org/9555879
https://www.biostars.org/9554298
https://www.biostars.org/9553308
https://www.biostars.org/9552908
https://www.biostars.org/9552261
https://www.biostars.org/9545567
https://www.biostars.org/9543360
https://www.biostars.org/9542707
https://www.biostars.org/9542591
https://www.biostars.org/9490823
https://www.biostars.org/9529239
https://www.biostars.org/9529235
https://www.biostars.org/9526493
https://www.biostars.org/9521633
https://www.biostars.org/9516471
https://www.biostars.org/9513794
https://www.biostars.org/9513266
https://www.biostars.org/9510944
https://www.biostars.org/9507324
https://www.biostars.org/9504710
https://www.biostars.org/9493846
https://www.biostars.org/9492102
https://www.biostars.org/9481994
https://www.biostars.org/9481515
https://www.biostars.org/9480112
https://www.biostars.org/9479441
https://www.biostars.org/9477203
https://www.biostars.org/9475019
https://www.biostars.org/9472410
https://www.biostars.org/9468941
https://www.biostars.org/9465695
https://www.biostars.org/9465590
https://www.biostars.org/495527
https://www.biostars.org/494348
https://www.biostars.org/488143
https://www.biostars.org/480034"

That is a cool workaround and exactly what I was looking for! Thank you very much! :-)

No problem - happy to help!

Log in to answer this question.