Legislators.search
From Sunlabs wiki
legislators.search does a fuzzy-matching text search of the legislators. The results are legislator names associated with scores ranging from 0 to 1 with 1.0 being an assumed "perfect match." The search algorithm can handle a wide variety of inputs including different orders for the names (last, first or first last), nicknames, minor typos, and more.
Contents |
Parameters
- name
- name to search for
- threshold
- optional threshold parameter specifying minimum score to return (defaults to 0.8, lower values not recommended)
- all_legislators
- optional parameter to search all legislators in API, not just those currently in office (false by default)
Return Value
Legislators are returned in the same format described for [Sunlight_API_Documentation/legislators|legislators.get and legislators.getList].
Example Calls
legislators.search?name=Teddy Kennedey
{"response":
{"results": [
{"result":
{"score": 0.87827505827505825,
"legislator": {"district": "Senior Seat", "title": "Sen",
"eventful_id": "P0-001-000016085-1", "in_office": 1, "state": "MA",
"votesmart_id": "53305", "party": "D", "email": "",
"crp_id": "N00000308", "website": "http://kennedy.senate.gov/",
"fax": "202-224-2417", "govtrack_id": "300059", "firstname": "Edward",
"middlename": "M.", "lastname": "Kennedy",
"congress_office": "317 Russell Senate Office Building",
"bioguide_id": "K000105",
"webform": "http://kennedy.senate.gov/senator/contact.cfm",
"nickname": "Ted", "phone": "202-224-4543", "fec_id": "S6MA00015",
"gender": "M", "name_suffix": "Sr.", "twitter_id": "",
"sunlight_old_id": "fakeopenID487",
"congresspedia_url": "http://www.sourcewatch.org/index.php?title=Edward_Kennedy"
}}}]}}
legislators.search.xml?name=TESTER,%20JOHN
<response>
<results>
<result>
<score>0.929783549784</score>
<legislator>
<district>Senior Seat</district>
<title>Sen</title>
<eventful_id>P0-001-000016085-1</eventful_id>
<in_office>1</in_office>
<state>MA</state>
<votesmart_id>53305</votesmart_id>
<party>D</party>
<email/>
<crp_id>N00000308</crp_id>
<website>http://kennedy.senate.gov/</website>
<fax>202-224-2417</fax>
<govtrack_id>300059</govtrack_id>
<firstname>Edward</firstname>
<middlename>M.</middlename>
<lastname>Kennedy</lastname>
<congress_office>317 Russell Senate Office Building</congress_office>
<bioguide_id>K000105</bioguide_id>
<webform>http://kennedy.senate.gov/senator/contact.cfm</webform>
<nickname>Ted</nickname>
<phone>202-224-4543</phone>
<fec_id>S6MA00015</fec_id>
<gender>M</gender>
<name_suffix>Sr.</name_suffix>
<twitter_id/>
<sunlight_old_id>fakeopenID487</sunlight_old_id>
<congresspedia_url>
http://www.sourcewatch.org/index.php?title=Edward_Kennedy
</congresspedia_url>
</legislator>
</result>
<strong>...</strong>
</results>
</response>
