Permalink
Fetching contributors…
Cannot retrieve contributors at this time
121 lines (80 sloc) 3.32 KB

sunlight.openstates

This is a thin wrapper around the Open States API, which provides data on state legislators, bills, votes, committees, districts, events, and more!

Please consider contributing to the Open States project, it's all open-source, and community involvement is valued very much by the Open States crew.

Note

If you come across data quality issues, broken code, or missing data, please file a report on the GitHub issues page. Thanks!

Metadata

Methods for dealing with Open States Metadata.

.. automethod:: sunlight.services.openstates.Openstates.all_metadata
.. automethod:: sunlight.services.openstates.Openstates.state_metadata

Bills

Methods for dealing with Open States Bills.

.. automethod:: sunlight.services.openstates.Openstates.bills
.. automethod:: sunlight.services.openstates.Openstates.bill_detail

Legislators

Methods for dealing with Open States Legislators.

.. automethod:: sunlight.services.openstates.Openstates.legislators
.. automethod:: sunlight.services.openstates.Openstates.legislator_detail
.. automethod:: sunlight.services.openstates.Openstates.legislator_geo_search

Committees

Methods for dealing with Open States Committees.

.. automethod:: sunlight.services.openstates.Openstates.committees
.. automethod:: sunlight.services.openstates.Openstates.committee_detail

Districts

Methods for dealing with Open States Districts.

.. automethod:: sunlight.services.openstates.Openstates.districts
.. automethod:: sunlight.services.openstates.Openstates.district_boundary

Events

Methods for dealing with Open States Events.

.. automethod:: sunlight.services.openstates.Openstates.events
.. automethod:: sunlight.services.openstates.Openstates.event_detail


Examples

Bills:

from sunlight import openstates

vt_agro_bills = openstates.bills(
    q='agriculture',
    state='vt',
    chamber='upper'
)

for bill in vt_agro_bills:
    print bill['title']

Legislators:

from sunlight import openstates

ca_dems = openstates.legislators(
    state='ca',
    party='Democratic',
    first_name='Bob',
    active='true'
)

for dem in ca_dems:
    print "%s %s (%s)" % (
        dem['first_name'], dem['last_name'], dem['chamber'] )

Committees:

from sunlight import openstates

md_cttys = openstates.committees( state='md', chamber='upper' )
for ctty in md_cttys:
    print "%s (%s)" % ( ctty['committee'], ctty['chamber'] )

Events:

from sunlight import openstates

tx_events = openstates.events( state='tx', type='committee:meeting' )
for event in tx_events:
    print "Event @ %s" % event['when']
    for who in event['participants']:
        print "  %s (%s)" % ( who['participant'], who['chamber'] )