Reputation: 1875
As some of you know, Stack Overflow now has an API, which now makes these types of questions valid programming questions.
My question: I'm trying to write a small script to connect to the Stack Overflow API to get a list of all questions under a subject (such as oauth, Python, twitter-api, and so on).
Can someone advise how to do this? I have no experience using the API and would welcome code or a link to a tutorial. I'm working with PHP.
Upvotes: 6
Views: 1377
Reputation: 81410
For the people in the next 10 years, you can do this by calling the /questions
endpoint. The example below will get all of the questions with the tag python
/questions?site=stackoverflow&tagged=python
You can add multiple tags seperated by ;
, all specified tags have AND constraint and since Stackoverflow only allows you to add up to 5 tags per question, any more than that will return 0 results.
The example below will get all questions that has all of the following tags: python, pycharm and numpy
/questions?site=stackoverflow&tagged=python;pycharm;numpy
You can play around with other filter params in the link above or open the browser console and paste this code to get the hang of the filter and returned values
fetch('https://api.stackexchange.com/2.2/questions?site=stackoverflow&tagged=reactjs')
.then(d => d.json())
.then(d => console.log(d))
Upvotes: 5