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:

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(last_name='Pelosi')[0]

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

Extras

Useful utilities for working with the services.

Internals

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

Indices and tables