API Reference¶
Jurisdictions¶
get_metadata(state=None, include=None, fields=None)
¶
Returns a list of all states with data available, and basic metadata
about their status. Can also get detailed metadata for a particular
state.
Args: state: The abbreviation of state to get detailed metadata on, or leave as None to get high-level metadata on all states.
include: Additional includes.
fields: An optional list of fields to return; returns all fields by
default
Returns:
Dict: The requested :ref:Metadata
as a dictionary
search_districts(state, chamber)
¶
Search for districts
Args: state: The state to search in chamber: the upper or lower legislative chamber fields: Optionally specify a custom list of fields to return
Returns:
A list of matching :ref:District
dictionaries
People¶
get_legislator(leg_id)
¶
Gets a legislator's details
Args: leg_id: The Legislator's Open States ID fields: An optional custom list of fields to return
Returns:
The requested :ref:Legislator
details as a dictionary
locate_legislators(lat, lng, fields=None)
¶
Returns a list of legislators for the given latitude/longitude coordinates
Args: lat: Latitude long: Longitude fields: An optional custom list of fields to return
Returns:
A list of matching :ref:Legislator
dictionaries
search_legislators(jurisdiction=None, name=None, id_=None, org_classification=None, district=None, include=None)
¶
Search for legislators.
Returns:
A list of matching :ref:Legislator
dictionaries
Bills¶
get_bill(uid=None, state=None, session=None, bill_id=None, include=None)
¶
Returns details of a specific bill Can be identified by the Open States unique bill id (uid), or by specifying the state, session, and legislative bill ID
Args:
uid: The Open States unique bill ID
state: The postal code of the state
session: The legislative session (see state metadata)
bill_id: Yhe legislative bill ID (e.g. HR 42
)
**kwargs: Optional keyword argument options, such as fields
,
which specifies the fields to return
Returns:
The :ref:Bill
details as a dictionary
search_bills(jurisdiction=None, identifier=None, session=None, chamber=None, classification=None, subject=None, updated_since=None, created_since=None, action_since=None, sponsor=None, sponsor_classification=None, q=None, sort=None, include=None, page=1, per_page=10, all_pages=True, state=None)
¶
Find bills matching a given set of filters
For a list of each field, example values, etc. see https://v3.openstates.org/docs#/bills/bills_search_bills_get
Utilities¶
set_api_key(apikey)
¶
Sets API key. Can also be set as OPENSTATES_API_KEY environment variable.
set_user_agent(user_agent)
¶
Appends a custom string to the default User-Agent string
(e.g. pyopenstates/__version__ user_agent
)
Exceptions¶
APIError (RuntimeError)
¶
Raised when the Open States API returns an error