# python-sunlight

## Overview

python-sunlight provides a unified set of API clients for the various open government data APIs made available by Sunlight Foundation projects.

Currently this library supports the following APIs:

- Sunlight Congress API (via sunlight.congress)
- Open States API (via sunlight.openstates)
- Capitol Words API (via sunlight.capitolwords)

Support is pending for the Influence Explorer API and the Real Time Congress API, though these currently have their own Python wrappers.

## Installation

The simplest way to install python-sunlight is via pip:

    $ pip install sunlight

You may also wish to check the project out from GitHub:

    $ git clone git://github.com/sunlightlabs/python-sunlight.git

## Usage

Register for a Sunlight API Key if you haven’t already, then you’ll be ready to start using the library.

The recommended method of providing the library with your API key is by placing your key in a file at `~/.sunlight.key`. Alternatively you can use an environment variable named `SUNLIGHT_API_KEY` or set `sunlight.config.API_KEY` within your program.

After setting your API key simply `import sunlight` and start using the APIs:

    >>> import sunlight
    >>> nc_legs = sunlight.openstates.legislators(state='nc')

You can also import a specific API client:

    >>> from sunlight import congress
    >>> pelosi = congress.legislators(lastname='Pelosi')[0]

For details on how to use the various APIs check out the documentation for the individual clients:

- sunlight.congress
  - Legislators
  - Districts
  - Committees
- sunlight.openstates
  - Metadata
  - Bills
  - Legislators
  - Committees
  - Districts
  - Events
  - Examples
- sunlight.capitolwords

## Internals

Implementation details, for extending python-sunlight or more untraditional uses.

- sunlight.service – API superclass
  - Classes and Variables
- sunlight.config
  - Methods and Constants
- sunlight.errors – Exceptions and errors
  - Exceptions

## Indices and tables

- Index
- Module Index
- Search Page