5

The Stack Exchange API supports /questions/{id}/tags/{tags} but it returns only a selection of questions available on Stack Overflow.

For a school project I need to find all questions containing the tag .

I know there is a has_more element but I have no idea on how to create the complete list of questions without getting duplicates.

Any suggestions on how I can do this? (I am using JavaScript.)

0

1 Answer 1

7

For tags such as which have more than 100 questions, there is no way to get all of the questions in a single request, because the SE API will return at most 100 questions per request. There shouldn't be such a way to get all the results in a single request, because returning huge numbers of questions from a single request (there are 305,000 questions) isn't reasonable for multiple design and resource allocation reasons.

However, you can get all of the results by making more requests. The API does support paging, by giving back a field called has_more in the response. If the value of that field is true, then there are more results than fit in the maximum number of results you specified in the pagesize parameter (max 100 for almost all SE API methods). If you want additional results, you should send another similar request, but specifying a different page. For example, to get the second page of results of questions tagged , send a GET request to https://api.stackexchange.com/2.2/search?order=desc&sort=activity&tagged=javascript&site=stackoverflow&pagesize=100&page=2.

Repeat this in a loop, incrementing page each time, until the has_more field in the response is false.

VERY IMPORTANT: Make sure to never go over your quota, and if the response contains backoff field, wait the given value, in seconds, before sending another request. Failing to honor any of these might get you IP banned from using the API.

0

You must log in to answer this question.

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