6

This project aims to provide a Java wrapper to the Stack Exchange API.

  • SDK supports Stack Exchange API V2.2

Getting Started

There are two interfaces to the library.

  • Query Interface
  • Facade Interface

Feature

  • Asynchronous API Examples of using the API asynchronously are described in Asynchronous API.

  • Advanced Usage Advanced usage like changing API providers or paging through the results are described in Advanced Usage.

  • Spring Configuration If you plan to use the library in conjunction with Spring framework, this brief tutorial will guide you. Spring Configuration

  • Query API Query API provides a Builder like syntax to the StackOverflow? API.There are similar Query interfaces for Answers, Comments, Timelines, Badges etc.

  • Switch Site Fetching records from different site are described here.

  • Advance Search Advance search feature available in SDK.

Code Snippet

StackExchangeApiQueryFactory queryFactory = StackExchangeApiQueryFactory
        .newInstance("applicationKey", 
        StackExchangeSite.STACK_OVERFLOW);


// Get all questions.
String filter = "default";
Paging paging = new Paging(1, 100);
PagedList<Question> questions = queryFactory.newQuestionApiQuery()
     .withPaging(paging).withFilter(filter)
     .withSort(Question.SortOrder.MOST_HOT)
     .withTags(tag).list();

//Get questions by answer ids. 
long answerId = 21859130; 
PagedList<Question> question3s =
     queryFactory.newQuestionApiQuery()
     .withPaging(paging).withFilter(filter)
     .withSort(Question.SortOrder.MOST_RECENTLY_CREATED)
     .withTags(tag).withAnswerIds(answerId).listQuestionsByAnswer();

Code

Source code is available under my sanjivsingh/stackoverflow-java-sdk repository.

Issues

Please feel free to raise bugs/issues at GitHub issues

Or You can contact me here sanjiv.singh

2 Answers 2

3

stackoverflow-java-sdk artifacts have been upload to Maven Central.

Now, You simply add maven dependency in your project POM

Dependency

  <dependency>   
   <groupId>com.googlecode.stackexchange</groupId>   
   <artifactId>stackoverflow-java-sdk-release</artifactId>   
   <version>2.2.0</version>   
  </dependency>   

Repository

  <repository>            
   <id>oss.sonatype</id>            
   <url>https://oss.sonatype.org/content/repositories/releases/<url>     
   <releases>                 
     <enabled>true</enabled>              
   </releases>              
  </repository>  

and start experimenting with SDK.

1

In this case the right repository config would be like:

<repository>
    <id>oss.sonatype</id>
    <url>http://repo1.maven.org/maven2</url>
    <releases>
        <enabled>true</enabled>
    </releases>
</repository>

You must log in to answer this question.

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