npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

legiscan

v1.0.3

Published

LegiScan API wrapper

Downloads

4

Readme

legiscan

Easily interact with the LegiScan API with javascript. Get an API Key and follow the instructions below. The legiscan package is a wrapper around the API functionality documented in this manual.

Installation

npm install legiscan

Quickstart

import { Legiscan } from 'legiscan'

const apiKey = 'your-api-key'
const legiscan = new Legiscan(apiKey)

const billId = 1447996

legiscan
  .getBill(billId)
  .then(res => console.log(res))
  .catch(error => console.error(error))

Overview

| Jump to: | | | -------------------------------------------------------------- | --- | | search | | | searchAllResults | | | searchRaw | | | getBill | | | getBills | | | getBillTextByBillId | | | getBillTextByDocId | | | getMasterListByState | | | getMasterListBySessionId | | | getMasterListByStateRaw | | | getMasterListBySessionIdRaw | | | getAmendmentById | | | getSessionListByState | | | getSupplementById | | | getRollCallById | | | getPersonById | | | getPeopleBySessionId | | | getPersonWithSponsoredBills | | | getDataset | | | getDatasetList | | | getMonitorList | | | getMonitorListRaw | | | setMonitor | |

Search

search

Full text search, returning 50 results per page.

search({
  query: string,
  page?: number,
  year?: number,
  state?: string,
  sessionId?: number
})
  • query required search query
  • page default: 1
  • year default: 2 -- 1=all, 2=current, 3=recent, 4=prior, >1900=exact
  • state default: 'ALL'
  • sessionId session number

searchAllResults

Full text search returning all pages. Caution: this can use a significant amount of queries if your search criteria is broad. It will perform a fetch for every page, consisting of 50 results each.

searchAllResults({
  query: string,
  year?: number,
  state?: string,
  sessionId?: number
})
  • query required search query
  • year number (optional) 1=all, 2=current, 3=recent, 4=prior, >1900=exact [Default: 2]
  • state string (optional) [Default: 'ALL']
  • sessionId number (optional)

searchRaw

Full text search returning 2000 bills per page. The objects returned do not include descriptions and titles like the full text search. Instead, they provide bill_id and change_hash along with a relevance score.

searchRaw({
  query: string,
  page?: number,
  year?: number,
  state?: string,
  id?: number
})
  • query required search query
  • page number (optional) [Default: 1]
  • year number (optional) 1=all, 2=current, 3=recent, 4=prior, >1900=exact [Default: 2]
  • state default: 'ALL'
  • id number (optional)

Bills

Fetch bills by their unique IDs. The LegiscanBill object:

{
  bill_id: number;
  change_hash: string;
  session_id: number;
  session: Session;
  url: string;
  state_link: string;
  completed: number;
  status: StatusKey;
  status_date: string;
  progress: ProgressEvent[];
  state: string;
  state_id: number;
  bill_number: string;
  bill_type: string;
  bill_type_id: string;
  body: string;
  body_id: number;
  current_body: string;
  current_body_id: number;
  title: string;
  description: string;
  pending_committee_id: number;
  committee: Committee;
  referrals: Referral[];
  history: HistoryAction[];
  sponsors: Sponsor[];
  sasts: [];
  subjects: Subject[];
  texts: Text[];
  votes: [];
  amendments: Amendment[];
  supplements: Supplement[];
  calendar: CalendarEvent[];
}

getBill

Get a single LegiScan bill.

getBill(billId)
  • billId: number

getBills

Get bills, providing an array of bill IDs.

getBills(billIds)
  • billIds: number[]

Bill Texts

getBillTextByBillId

Fetches the latest version of a bill's text, if available. This performs two API requests: one to fetch the bill and another to fetch the latest text. If you already know the doc_id, use getBillTextByDocId.

getBillTextByBillId(billId)

getBillTextByDocId

Get a bill text by its doc_id. The response includes the doc's date, draft revision information and MIME type. The bill text itself is base64 encoded to allow for binary PDF/Word transfers.

  • billId: number
getBillTextByDocId(docId)
  • docId: number

Materlists

Get get a list of bill summaries by state or session ID. The response is a MasterList object:

{
  "0": {
      bill_id: number;
      number: string;
      change_hash: string;
      url: string;
      status_date: string;
      status: string;
      last_action_date: string;
      last_action: string;
    }
  },
  "1": {
    ...
  },
  ...
}

getMasterListByState

Returns a list of summary bill data in the current state session.

getMasterListByState(state)
  • state string (ex: AL, OK, US, etc.) Default: 'ALL'

getMasterListBySessionId

Returns a list of summary bill data in a specific session.

getMasterListBySessionId(sessionId)
  • sessionId number

Materlists Raw

Get a list of bill change hash data by state or session ID. The response is a MasterListRaw object:

{
  "0": {
    bill_id: number;
    number: string;
    change_hash: string;
  },
  "1": {
    ...
  },
  ...
}

getMasterListByStateRaw

Returns a list of bill change_hash data in the current state session.

getMasterListByStateRaw(state)
  • state: string (ex: AL, OK, US, etc.) Default: 'ALL'

  • sessionId: number

getMasterListBySessionIdRaw

Returns a list of bill change_hash data in the specific session.

getMasterListBySessionIdRaw(sessionId)
  • sessionId: number

Amendments

Get an amendment by its ID. The amendment text itself is base64 encoded to allow for binary PDF/Word transfers. Returns an amendment object:

{
  amendment_id: number;
  chamber: string;
  chamber_id: number;
  bill_id: number;
  adopted: number;
  date: string;
  title: string;
  description: string;
  mime: string;
  mime_id: number;
  amendment_size: number;
  amendment_hash: string;
}

getAmendmentById

getAmendmentById(amendmentId)
  • amendmentId: number

Sessions

Get a list of sessions in a given state abbreviation. Returns an array of session objects:

[
  {
    session_id: number;
    state_id: number;
    year_start: number;
    year_end: number;
    prefile: number;
    sine_die: number;
    prior: number;
    special: number;
    session_tag: string;
    session_title: string;
    session_name: string;
  },
  ...
]

getSessionListByState

getSessionListByState(state)
  • state: string (ex: AL, OK, US, etc.) Default: 'ALL'

Supplements

Get a supplement text by ID. The supplement text itself is base64 encoded to allow for binary PDF/Word transfers. Returns a supplement object:

{
  supplement_id: number;
  bill_id: number;
  date: string;
  type_id: number;
  type: string;
  title: string;
  description: string;
  mime: string;
  mime_id: number;
  supplement_size: number;
  supplement_hash: string;
  doc: string;
}

getSupplementById

getSupplementById(supplementId)
  • supplementId number

Roll Calls

Get roll call details, including a summary and individual votes with people_id. Returns a RollCall object:

{
  roll_call_id: number;
  bill_id: number;
  date: string;
  desc: string;
  yea: number;
  nay: number;
  nv: number;
  absent: number;
  total: number;
  passed: number;
  chamber: string;
  chamber_id: number;
  votes: [{
    people_id: number;
    vote_id: number;
    vote_text: string;
  },
  ...
  ];
}

getRollCallById

getRollCallById(rollCallId)
  • rollCallId number

People

Get information about people related to bills. Returns a Person object:

{
  people_id: number;
  person_hash: string;
  state_id: number;
  party_id: string;
  party: string;
  role_id: number;
  role: string;
  name: string;
  first_name: string;
  middle_name: string;
  last_name: string;
  suffix: string;
  nickname: string;
  district: string;
  ftm_eid: number;
  votesmart_id: number;
  opensecrets_id: string;
  knowwho_pid: number;
  ballotpedia: string;
  committee_sponsor: number;
  committee_id: number;
}

getPersonById

getPersonById(peopleId)
  • peopleId number

getPeopleBySessionId

Get a list of individuals active in a given session.

getPeopleBySessionId(sessionId)
  • sessionId number

getPeopleBySessionId response includes session and people data:

  session: {
    session_id: number;
    state_id: number;
    year_start: number;
    year_end: number;
    special: number;
    prefile: number;
    prior: number;
    sine_die: number;
    session_name: string;
    name: string;
    dataset_hash: string;
  },
  people: Person[];

getPersonWithSponsoredBills

Get a list of bills sponsored by an individual legislator.

getPersonWithSponsoredBills(peopleId)
  • peopleId number

Returns details about a person, including their bills they've sponsored:

{
  sponsor: {
    people_id: number;
    person_hash: string;
    state_id: number;
    party_id: string;
    party: string;
    role_id: number;
    role: string;
    name: string;
    first_name: string;
    middle_name: string;
    last_name: string;
    suffix: string;
    nickname: string;
    district: string;
    ftm_eid: string;
    votesmart_id: number;
    opensecrets_id: string;
    knowwho_pid: number;
    ballotpedia: string;
    committee_sponsor: number;
    committee_id: number;
  };
  sessions: [{
    session_id: number;
    session_name: string;
  }],
  bills: [{
    session_id: number;
    bill_id: number;
    number: string;
  }]
}

Datasets

getDataset

Get a .zip archive for the requested dataset containing all bills, votes and people. Find the accessKey via getDatasetList.

getDataset(sessionId, accessKey)
  • sessionId number
  • accessKey string

getDatasetList

Get a list of available session datasets, with optional state and year filtering.

Response is an array of Dataset objects that include the session_id and access_key required to call getDataset.

[
  {
    state_id: number;
    session_id: number;
    session_name: string;
    dataset_hash: string;
    dataset_date: string;
    dataset_size: number;
    mime: string;
    zip: string;
  }
]
getDatasetList({
  state?: string;
  year?: number
})

Monitor

If you're tracking bills with your LegiScan account, you can get and set your list with the following.

getMonitorList

Returns the GAITS monitor list of summary bill data being tracked by the account associated with the API key.

getMonitorList(record)
  • record string (optional) current or archived, 2010 >= exact year [Default: current]

getMonitorListRaw

Returns the GAITS monitor list of bill change_hash data being tracked by the account associated with the API key.

getMonitorListRaw(record)
  • record string (optional) current or archived, 2010 >= exact year [Default: current]

setMonitor

Returns a master list of bill change_hash data in the provided session or current state session.

setMonitor(list, action, stance)
  • list comma separated string list of bill_id to operate on
  • action string monitor, remove, or set action
  • stance string (Optional) position on the bill watch, support, or oppose [Default: watch]