I have released a beta snapshot version of a Java wrapper for the Stack Overflow API at http://code.google.com/p/stackoverflow-java-sdk/. Please try it and provide your feedback.
Screenshot / Code Snippet
There are two different interfaces to the API. One is the query API which has a Builder like syntax.
StackExchangeApiQueryFactory queryFactory = StackExchangeApiQueryFactory.newInstance("applicationKey"); QuestionApiQuery query = queryFactory.newQuestionApiQuery(); List<Question> questions = query.withSort(Question.SortOrder.HOT).withPaging(new Paging(1, 20)).withTimePeriod(new TimePeriod(new Date(), new Date())).withFetchOptions(EnumSet.of(FilterOption.INCLUDE_BODY, FilterOption.INCLUDE_COMMENTS)).list();
The other is a simple facade which exposes all the methods of the API.
StackExchangeApiClientFactory factory = StackExchangeApiClientFactory.newInstance("applicationKey"); StackExchangeApiClient client = factory.createStackOverflowApiClient(); List<Question> questions = client.getQuestions(Question.SortOrder.HOT, new Paging(1, 20), new TimePeriod(new Date(), new Date()), EnumSet.of(FilterOption.INCLUDE_BODY, FilterOption.INCLUDE_COMMENTS));
The lists returned by both the methods are instances of PagedList which provide methods to aid in pagination of the result.
Note that, by default, the library uses Stack Overflow as the API provider. You can change that to use any other by:
query.setApiProvider(new SuperUserApiProvider()); client.setApiProvider(new SuperUserApiProvider());
The method AND class names somewhat map with the names in the API. In case of confusion, look in the examples directory of the distribution for more examples. I will be updating the Javadoc soon.
stackoverflow-java-sdk is an open source library hosted at Google Code. I created this library to be used in an internal project. But it's comprehensive enough to be used by anyone looking to integrate with the API of Stack Overflow or partner sites.
stackoverflow-java-sdk is open source with an Apache License 2.0.
You can download the library from Google Code at http://code.google.com/p/stackoverflow-java-sdk/.
It's supported for any platform on which Java is supported which include Google App Engine and Android.
Any issues can be filed on the Google Code Issue tracking system.
The library is hosted at Google Code as a Mercurial repository. You can create a clone and get the code and make changes to it.
To contribute to the main repository you will have to create an issue with a pull request with details of your changes.
The library has one dependency on Google GSON which can be downloaded from http://code.google.com/p/google-gson/.