6

I'm trying to get a list of questions from the SO API for a number of tags,

At the moment I am using the ; operator to separate the tags in the URL but the thing is this only brings up questions that have ALL the tags in them.

This is obviously no good, One option would be to get all new questions and then filter based on my tags but I wanted to know if there was an easier way (i.e does the API support and OR operator) or will I have to import all questions and then filter?

2
  • I misunderstood your question. The earlier commenter may have been right that you'll want to check out stackapps.
    – user2700
    Commented Mar 8, 2011 at 16:31
  • @patrickdw no problem :) I've asked for it to be moved again
    – mylesagray
    Commented Mar 8, 2011 at 16:35

2 Answers 2

1

Since OP has asked about fetching new questions, I can tell about that.

/search works fine if you have two or three tags. But if you have a dozen, you'll get recent questions with delay of 5-15 minutes (as OP noted in the comments). Also, min/max parameters become terribly imprecise: you can get a post 10 minutes before min or miss post 10 minutes after it.

In my experience, fetching latest entries with /questions and filtering them locally is the safest, easiest, sanest alternative. And I imagine it also reduces load on the server.

1
  • thanks! I started implementing a /questions parser anyway :)
    – mylesagray
    Commented Mar 10, 2011 at 20:24
1

/search has atagged parameter with OR semantics. The # of returns is capped, and the results are very heavily cached.

Things get tricky when somebody asks for everything tagged c# or java, and then the API is stuck trying to shove back 200k questions (optionally with answers and comments); thus the heavy constraints on OR'ing tags.

11
  • @KevinMontrose - It seems that my only option then is to use /questions get ALL questions in the last minute or so and then filter them as the caching is killing the updating of my results?
    – mylesagray
    Commented Mar 9, 2011 at 16:26
  • @Kevin and @Myles, why is this so difficult? just fetch the questions tagged with C# and the questions tagged java and then combine them, it could be done server side or client side (server side would be nicer because less bandwidth)
    – Jonathan.
    Commented Mar 9, 2011 at 21:27
  • 1
    @Jonathan - that is, literally, exactly what /search?tagged does. We just don't support paging over more than 2k or so questions with it, all the sorts still work with it though. Commented Mar 9, 2011 at 22:13
  • @Kevin, So then why the heavy caching?
    – Jonathan.
    Commented Mar 9, 2011 at 22:43
  • @Jonathan - because you're pulling millions of posts and searching them. Commented Mar 9, 2011 at 23:22
  • @Kevin, sorry i meant why the heavy caching on the /search route but not on the questions route.
    – Jonathan.
    Commented Mar 10, 2011 at 8:29
  • @KevinMontrose I would like to know that too, Why is /questions more "live" than the /search method?
    – mylesagray
    Commented Mar 10, 2011 at 18:10
  • @Myles - the /questions route is also cached, essentially as aggressively. /search also has an index associated with it, which is held more or less in sync with the site's search index; which lags slightly behind on question creation and updates w.r.t., say, one of the question tabs. Commented Mar 10, 2011 at 18:21
  • @KevinMontrose Then how come I get very different results with /search than /questions, Like on /search I get a range of delays from about 5-15minutes after a question is posted, where as on the /questions route, with an appropriately dated fromdate I can get questions seconds old, Where as on /search even with the fromdate calculated the same way - not the same results (please don't change this - it will break instant notifiers like Newt)
    – mylesagray
    Commented Mar 10, 2011 at 18:27
  • @Myles - like I said, the index lags slightly behind. The resolution of times on /search is reduced as well, to keep the indexes sane. Commented Mar 10, 2011 at 18:29
  • @KevinMontrose Oh I see, the index is linked to the /search? Where as /questions is linked to the actual questions posted before and after they are indexed? - I've been using the Last.fm API recently and as such I'm used to instantaneous polling from data submission to API serving.
    – mylesagray
    Commented Mar 10, 2011 at 18:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .