Open ndawg opened 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.
Yep, that's what I've done for now! I think it'd be good for consistency though 👍
@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?
@ndawg No, not a good reason, at least. We can see about deprecating that and adding an endpoint more like the recent votes one.
@ndawg I'd like to amend my previous answers here:
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.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?
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.
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.
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:
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.