|
SunlightLabsJavaAPI
Sunlight Labs Java APIA part of the Congress Explorer project consists of a Java Porting of the Sunlight Labs API, independent from Eclipse and thus reusable by any Java application willing to access the Congress data. InstallationTo install the Sunlight Labs Java API download the Library Archive and unzip it into an arbitrary location. UsageTo use the API locate and include in the classpath the following JARs, extracted from the abovementioned archive:
To perform a query by Last Name over Legislators start importing the following classes/interfaces: import com.abso.sunlight.api.Legislator; import com.abso.sunlight.api.LegislatorQuery; import com.abso.sunlight.api.SunlightException; import com.abso.sunlight.api.SunlightService; import java.util.List; Next, use the following code (click here to register for a Sunlight Labs API key): SunlightService service = new SunlightService("<Your Sunlight Labs API key here>");
LegislatorQuery query = new LegislatorQuery();
query.getLastNameList().add("McCain");
query.getLastNameList().add("Kerry");
List<Legislator> legislators = service.getLegislators(query);
for (Legislator legislator : legislators) {
System.out.println(legislator.getFirstName() + " " + legislator.getLastName());
}and look at the result in the console: John Kerry John McCain DocumentationThe Library Archive includes the Javadoc reference for all the classes/interfaces composing the API. Additional information can be obtained browsing the Source Code. Requirements
|