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.

Openstates.all_metadata(**kwargs)[source]

Get an overview of all available states including each state’s name and abbreviation.

For details see Metadata Overview.

Openstates.state_metadata(state, **kwargs)[source]

Complete metadata for a given state, containing information on the particulars of this state’s chambers, sessions, and terms.

For details see State Metadata.

Bills

Methods for dealing with Open States Bills.

Openstates.bills(**kwargs)[source]

Search the entirety of bills available via the Open States API.

The fields and keyword arguments can be found on the Bill API docs.

Openstates.bill_detail(state, session, bill_id, chamber=None)[source]

Get full information on a single bill from the Open States API given a state, session, and bill_id (and optionally chamber if the request would be ambiguous without one).

The fields and keyword arguments can be found on the Open States Bill API docs.

Legislators

Methods for dealing with Open States Legislators.

Openstates.legislators(**kwargs)[source]

Search the entirety of legislators available via the Open States API.

The fields and keyword arguments can be found on the Legislator API docs.

Openstates.legislator_detail(leg_id, **kwargs)[source]

Get detailed information on a single legislator given their Open States Legislator ID.

The leg_id argument is a legislator ID code used throughout the Open States API, such as MDL000210.

For details on fields see the Legislator API Fields.

Given a latitude and longitude return all legislators that represent districts containing that point.

See the Open States documentation for examples of Legislator Geo Lookup.

Committees

Methods for dealing with Open States Committees.

Openstates.committees(**kwargs)[source]

Search against all committees available via the Open States API.

Committee fields and keyword arguments can be found on the Committee API docs.

Openstates.committee_detail(committee_id, **kwargs)[source]

Get detailed information on a single committee given its Open States Committee ID.

The committee_id argument is a committee ID code used throughout the Open States API, such as MDC000065.

For details on fields see the Committee API Fields.

Districts

Methods for dealing with Open States Districts.

Openstates.districts(state, chamber=None, **kwargs)[source]

Get a listing of districts for a state (optionally narrowed by chamber).

For a listing of fields see District Fields.

Openstates.district_boundary(boundary_id, **kwargs)[source]

Get a detailed GeoJSON-style boundary for a given district given a boundary_id (available via the :meth:districts.

boundary_id resembles sldl-tx-state-house-district-35.

For a listing of fields see District Fields.

For more information on this method and example output see District Boundary Lookup

Events

Methods for dealing with Open States Events.

Openstates.events(**kwargs)[source]

Query the Open States API for information regarding upcoming events taken from a state-level legislative calendar.

See the Open States’ site for details on the Event API.

Openstates.event_detail(event_id, **kwargs)[source]

Get detailed informaton regarding a single event.

event_id is an OpenStates event ID, such as TXE00000990.

See the Open States’ site for details on the Event API Fields.

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'] )