Update (2010-12-30): I have updated the OData URI locations below, because of a recent move and re-architecture by the StackExchange team.
In case you haven’t read, Stack Overflow and the rest of the Stack Exchange sites are now able to be queried using OData. This is great because as Jeff points out in the blog post:
…if you just want to play with the data, it’s kind of tedious: you have to download the entire 700 plus megabyte archive, import it into some kind of database system — and only then can you even begin thinking about how to query out the results you’re looking for.
This hurdle has stopped me from performing some basic queries that I would like to know on the spot. But that is no longer the case, and I am going to show you how you can get started querying Stack Overflow from a tool called LINQPad.
First Things, First
You need to download LINQPad, which is a general learning and development tool for composing and executing LINQ queries. After you have downloaded and installed the application you will have a screen that looks like this:
Setting Up Stack Overflow OData
The next step is to add the OData endpoint for Stack Overflow, which is:
This is done by clicking on Add connection in the top left of LINQPad. Which will give you a screen that looks like this:
Select WCF Data Services and click Next. You will get a connection screen where you enter the endpoint for Stack Overflow that I described above:
After entered click OK, and you will be taken back to the LINQPad application with a new connection to the Stack Overflow data source that lists all the available tables and fields that you can query.
Lets Have Some Fun Querying
Lets start with an easy query that we all should know. Who is the number 1 Stack Overflow user?
What about which user has the highest number of votes?
What about down votes?
Show my insightful comments with a score of 5 or greater?
As you can see this is a very powerful way to get some quick answers out of Stack Overflow, and it is amazing that Microsoft, Azure, and Stack Overflow is able to bring all of this to us for free.
Also if interested they also offer OData endpoints for all of the other major Stack Exchange network of sites:
- Stack Overflow: http://data.stackexchange.com/stackoverflow/atom
- Server Fault: http://data.stackexchange.com/serverfault/atom
- Super User: http://data.stackexchange.com/stackoverflow/atom
- Meta Stack Overflow: http://data.stackexchange.com/meta/atom
- Ubuntu: http://data.stackexchange.com/ubuntu/atom
- Gaming: http://data.stackexchange.com/gaming/atom
- etc: http://data.stackexchange.com/<community>/atom
Post some of your interesting queries below.