propublica / congress-api-docs

Documentation for the ProPublica Congress API
https://projects.propublica.org/api-docs/congress-api/
53 stars 4 forks source link

Get recent bills does not include congressional session within each bill #241

Open ndawg opened 4 years ago

ndawg commented 4 years ago

Although the get recent bills endpoint requires a value for congress, it does not seem to include the value of the congressional session for each bill, like other similar endpoints do. For example, consider one of the returned bills:

{
  "bill_id": "s693-116",
  "bill_slug": "s693",
  "bill_type": "s",
  "number": "S.693",
  "bill_uri": "https://api.propublica.org/congress/v1/116/bills/s693.json",
  "title": "A bill to amend title 36, United States Code, to require that the POW/MIA flag be displayed on all days that the flag of the United States is displayed on certain Federal property.",
  "short_title": "National POW/MIA Flag Act",
  "sponsor_title": "Sen.",
  "sponsor": "Elizabeth Warren",
  "sponsor_id": "W000817",
  "sponsor_uri": "https://api.propublica.org/congress/v1/members/W000817.json",
  "sponsor_party": "D",
  "sponsor_state": "MA",
  "congressdotgov_url": "https://www.congress.gov/bill/116th-congress/senate-bill/693",
  "govtrack_url": "https://www.govtrack.us/congress/bills/116/s693",
  "introduced_date": "2019-03-07",
  "active": true,
  "house_passage": "2019-10-22",
  "senate_passage": "2019-05-02",
  "enacted": "2019-11-07",
  "cosponsors": 7,
  "cosponsors_by_party": {
    "R": 4,
    "D": 3,
    "I": 0
  },
  "withdrawn_cosponsors": 0,
  "primary_subject": "Government Operations and Politics",
  "committees": "House Judiciary Committee",
  "committee_codes": [
    "HSJU",
    "SSJU"
  ],
  "latest_major_action_date": "2019-11-07",
  "latest_major_action": "Signed by President.",
  "summary": "National POW/MIA Flag Act The bill changes the days on which the POW/MIA flag is required to be displayed at specified locations to all days on which the U.S. flag is displayed. (Current law requires the POW/MIA flag to be displayed only on Armed Forces Day, Memorial Day, Flag Day, Independence Day, National POW/MIA Recognition Day, and Veterans Day.) ",
  "summary_short": "National POW/MIA Flag Act The bill changes the days on which the POW/MIA flag is required to be displayed at specified locations to all days on which the U.S. flag is displayed. (Current law requires the POW/MIA flag to be displayed only on Armed Forces Day, Memorial Day, Flag Day, Independence Day, National POW/MIA Recognition Day, and Veterans Day.) "
}

As you can see there is no congress field in the returned JSON. Even though the request takes a congressional session ID itself, it would be really helpful for deserialization purposes to include this within the response.

dwillis commented 4 years ago

@ndawg We could add that. In the meantime, you can get the congress from the bill_id attribute by splitting on -. It's the second value in that.

ndawg commented 4 years ago

Yep, that's what I've done for now! I think it'd be good for consistency though 👍

ndawg commented 4 years ago

@dwillis Something else I've just noticed is that the recent bills endpoint requires the congressional session while the get recent votes endpoint doesn't. Any reason for that?

dwillis commented 4 years ago

@ndawg No, not a good reason, at least. We can see about deprecating that and adding an endpoint more like the recent votes one.

dwillis commented 4 years ago

@ndawg I'd like to amend my previous answers here:

  1. The JSON returned by "Get Recent Bills" does include congress, just not for each bill but at the top of the response object. Since the congress is required, that value extends to each bill in the response.
  2. This leads into your second point about requiring the congress. My recollection is that the reason we don't require congress for recent votes is because the first day of a new congress is also, technically, the last day of the previous congress. A previous user asked that we make recent votes based on date rather than congress because of this anomaly so that it wouldn't be necessary to make two calls to retrieve votes taken on the same literal day but different legislative days in two different congresses.

I can see the inconsistency here, but because we have scoped bills to a congress (with good reason), I'm not sure that making recent bills more like recent votes makes sense. Thoughts?

ndawg commented 4 years ago
  1. That's fair, although having one "unified" response object makes it much easier to properly parse values. Most endpoints have all their data in the results field, so I use something like this to represent all responses:

    data class PublicaAPIResponse<T>(
    val status: String,
    val copyright: String,
    val results: T?,
    val errors: String?)

    This allows top-level error handling for all endpoints, for example. You can imagine it would get quite tedious to have a custom response type for every endpoint, although it is do-able. To me, it makes more sense to return the same data for each bill no matter what the request context was.

  2. That's an interesting problem. In that case, it would certainly be a breaking change, so maybe it can be re-discussed in the context of a v2. I'll have to think about it some more.