Skip to content

Lawmaker endpoints

Megan Riel-Mehan edited this page Nov 11, 2017 · 9 revisions

Abbreviations: MOC = Member of Congress.

Federal

/mocID/[lookup key]

  • Purpose: To go from an MOC name to the govtrack_id. Members are redundant to capture multiple spellings, ie "Chuck Grassley" and "Charles Grassley" will both give you the same id.
  • members are stored lastname_firstname.
  • To convert an entered name into a lookup key:
      let nameArray = member.replace(/\./g, '').split(' '); //can't store any endpoints with '.' in them.
      if (nameArray.length > 2) {
// can be in format Michael H Wray, Yvonne Lewis Holley, L. Louise Lucas, Lynwood W. Lewis, Jr.
        let firstname = nameArray[0].toLowerCase();
        let middlename = nameArray[1].toLowerCase();
        let lastname = nameArray[2].toLowerCase().replace(/\,/g, '');
        if (firstname.length === 1 || middlename.length === 1) {
          memberKey = lastname + '_' + firstname + '_' + middlename;
        } else {
//not ideal, but we had some members with two last names
          memberKey = middlename + lastname + '_' + firstname;
        }
      } else {
        memberKey = lastname + '_' + firstname;
      }

/mocData/[govtrack_id]

  • Purpose: To get all the data about an MOC.
  • Members are stored by govtrack_ids.
300019: {
address: "513 Hart Senate Office Building Washington DC 20510",
api_uri: "https://api.propublica.org/congress/v1/members/C000174.json",
ballotpedia_id: "Tom Carper",
bioguide_id: "C000174",
birthday: "1/23/1947",
contact_form: "http://www.carper.senate.gov/public/index.cfm/email-senator-carper",
crp_id: "N00012508",
cspan_id: "663",
date_of_birth: "1947-01-23",
displayName: "Tom Carper",                          //displayed on front-end
district: "",
domain: "www.carper.senate.gov",
dw_nominate: -0.174,
eventbrite_id: 8465725139,
facebook: "tomcarper",                               //original THP data
facebook_account: "tomcarper",                       //from proPublica API
facebook_campaign_account: "TomCarperforDE",         // THP research 
facebook_official_account: "tomcarper",              // THP research 
facebook_personal_account: "",                       // THP research 
fax: "202-228-2190",
first_name: "Thomas",
gender: "M",
google_entity_id: "/m/01xw7t",
govtrack_id: "300019",
icpsr_id: "15015",
id: 300019,
in_office: true,                               //required in order to be included on site
last_name: "Carper",
lis_id: "S277",
middle_name: "R.",
missed_votes: 5,
missed_votes_pct: 2.67,
missingMember: true,                          //THP research, displayed on front-end
next_election: "2018",                        //displayed on front-end
ocd_id: "ocd-division/country:us/state:de",
office: "513 Hart Senate Office Building",
opensecrets_id: "N00012508",
party: "Democratic",
personal_facebook_account: "",
phone: "202-224-2441",
propublica_id: "C000174",
rss_url: "https://www.carper.senate.gov/public/index.cfm/rss/feed",
senate_class: "1",
seniority: "17",
state: "DE",
stateName: "Delaware",        //For displaying on front-end
state_rank: "senior",
thomas_id: 179,
total_present: 1,
total_votes: 187,
twitter: "SenatorCarper",
twitter_account: "SenatorCarper",
type: "sen",
url: "https://www.carper.senate.gov/public",
votes_with_party_pct: 92.31,
votesmart_id: "22421",
washington_post_id: "",
wikipedia_id: "Tom Carper",
youtube: "senatorcarper",
youtube_account: "senatorcarper",
youtube_id: "UCgLnvbKwu4B3navofj6Qvvw"}

State Legislatures

/state_legislator_id/[state abbreviation]/[lastname_firstname]

  • Purpose: same as mocID; to go from a user entered name to the thp_id;
  • example:
allen_john_m: {
id: "AZ-HD-15-00",
nameEntered: "John M Allen"
},

/state_legislators_data/[state abbreviation]/[thp_id]

  • Purpose: same as mocData; to get member data using the thp_id;
  • thp_id format: [state abbreviation]-[chamber]-[district]-[index]
  • example:
{
chamber: "House",
displayName: "David Stringer",
district: "HD-01",
email: "DSTRINGER@azleg.gov",
in_office: true,
party: "Republican",
phone_capitol: "(602) 926-4838",
state: "AZ",
stateName: "Arizona",
thp_id: "AZ-HD-01-00",
url: ""
}