### Navigation

- index
- modules |
- next |
- previous |
- python-sunlight 1.1.5 documentation »

# 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)

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

  For details see Metadata Overview.

`openstates.``state_metadata`(state, **kwargs)

  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)

  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)

  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)

  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)

  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.

`openstates.``legislator_geo_search`(latitude, longitude, **kwargs)

  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)

  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)

  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)

  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)

  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)

  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)

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

### Navigation

- index
- modules |
- next |
- previous |
- python-sunlight 1.1.5 documentation »