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

  • Will this work with J2ME development? Just wonderin'... Commented May 25, 2010 at 5:46
  • It uses HttpUrlConnection to communicate with the API. HttpUrlConnection is available in J2ME CDC profiles, so theoretically it should work on those platforms, though I have not tried it. So not sure. Commented May 25, 2010 at 6:58
  • 2
    Might want to change the name... you're not supposed to use 'StackOverflow' in the name. Commented Jul 5, 2010 at 19:50
  • You are right. The names were old and have been updated. Commented Jul 7, 2010 at 8:54
  • @nabeelmukhtar any plans to support api 2.1?
    – Binoy Babu
    Commented Nov 10, 2012 at 5:09

3 Answers 3


This is a nice implementation, but it doesn't work on Java ME nor Android though. You seem to be experienced Java developer, because you are using the adapter pattern design and some introspection stuff.

The main problem here is that Java ME and Android don't provide the java.beans package which is needed in order to use introspection as you are using it... even worse, the Dalvik VM avoids compiling 'core' libraries so I was not able to adapt the java.beans implementation for Android.

There are other problems, which are easier to solve, like the way you are getting the application constants values (for instance, that won't work on Java ME unless you use microproperties).

I guess someone will have to implement a wrapper for Android that uses the JSON libraries provided by the Android API. Maybe I could give it a try in some days.

I also took a look of the Stack Exchange Java client library; it seems to be simpler, but it uses the Java Jersey API, and I haven't been able to make it run on Android...

  • 1
    Thanks for pointing this out. I will have to change the BaseJsonAdapter implementation to use reflection etc. for android. Let me try this. Will have to change a lot to support j2me though. Commented Jun 15, 2010 at 13:04
  • You could better start with Android since it has a richer SDK... the changes won't be dramatic. For j2me I guess it'd be better to create a miniwrapper version.
    – Cristian
    Commented Jun 15, 2010 at 13:12
  • 3
    @Christian: If you'd like, you can test out StackWrap4J. I tested it out on the Android emulator, but I don't have a physical device to test it on yet. I'd appreciate any feedback you can give us if you decide to use it. Thanks. Commented Jun 21, 2010 at 3:06
  • @Bill Thanks! I'll give it a try as soon as I can :D
    – Cristian
    Commented Jun 30, 2010 at 13:54
  • Try the latest version. It uses Google GSON for json parsing which works on Android as well. Commented Jul 5, 2010 at 12:52
  • Just an idea but what if the api could be changed so you have to pass in the Class<T> for the object that is handling the connection and let the api use it. This way this api could be used for android and desktop. Or maybe there is a better way. Commented Mar 4, 2015 at 17:33

This currently does not work with the v2.0 API.



Try below one, I have added support for Stack Exchange API V2.x


For more detail, follow docs https://github.com/sanjivsingh/stackoverflow-java-sdk/wiki

  • How do I perform authentication using the api?
    – aries
    Commented Aug 10, 2016 at 9:00

You must log in to answer this question.

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