My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
SunlightLabsJavaAPI  
Updated Mar 29, 2009 by aldo.bongio@gmail.com

Sunlight Labs Java API

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

Installation

To install the Sunlight Labs Java API download the Library Archive and unzip it into an arbitrary location.

Usage

To use the API locate and include in the classpath the following JARs, extracted from the abovementioned archive:

  • sunlight-labs-api.jar
  • lib/commons-codec.jar
  • lib/commons-httpclient.jar
  • lib/commons-io.jar
  • lib/commons-lang.jar
  • lib/commons-logging.jar
  • lib/dom4j.jar
  • lib/jaxen.jar

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

Documentation

The Library Archive includes the Javadoc reference for all the classes/interfaces composing the API.

Additional information can be obtained browsing the Source Code.

Requirements

  • Java 1.5 or higher
  • Sunlight Labs API key (click here to apply for a key)

Sign in to add a comment
Powered by Google Project Hosting