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 Answers
2

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.

/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.

@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?
– Myles GrayMar 9 '11 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.Mar 9 '11 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.
– Kevin Montrose♦Mar 9 '11 at 22:13

@Kevin, sorry i meant why the heavy caching on the /search route but not on the questions route.
– Jonathan.Mar 10 '11 at 8:29

@KevinMontrose I would like to know that too, Why is /questions more "live" than the /search method?
– Myles GrayMar 10 '11 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.
– Kevin Montrose♦Mar 10 '11 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)
– Myles GrayMar 10 '11 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.
– Kevin Montrose♦Mar 10 '11 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.
– Myles GrayMar 10 '11 at 18:35