Open ryparker opened 6 months ago
Hi @ryparker - to get data on this law, you'd want to search by public law number, not bill number. So: https://api.congress.gov/v3/law/118/pub/50?api_key=API_KEY.
Public law numbers are assigned by NARA and are different from bill numbers. Hope this helps!
I see now, that worked.
This is a little confusing especially since the law list API returns two number
props and neither are the exact number needed for the details API.
e.g. The law list responds with:
{
bills: [
{
"congress": 118,
"latestAction": {
"actionDate": "2024-04-24",
"text": "Became Public Law No: 118-50."
},
"laws": [
{
"number": "118-50",
"type": "Public Law"
}
],
"number": "815",
"originChamber": "House",
"originChamberCode": "H",
"title": "Making emergency supplemental appropriations for the fiscal year ending September 30, 2024, and for other purposes.",
"type": "HR",
"updateDate": "2024-04-26",
"updateDateIncludingText": "2024-04-26T16:27:29Z",
"url": "https://api.congress.gov/v3/bill/118/hr/815?format=json"
},
...
],
...
}
The root "number": "815",
is actually the bill number and the laws array returns a "number": "118-50",
but it includes the congress number, so the actual law number must be extracted. It's not a big deal once you understand it but it's still a little odd.
Absolutely, @ryparker - thanks for the feedback. The documentation has been updated related to this so, hopefully, that helps a little bit. We state the following in the endpoint documentation now (see below). If you have any feedback on improving this for the users, please let us know. Thanks!
Users can now retrieve bill data by specifying one of the following options:
Laws by Congress Laws by Congress and Law type (public or private) Law by Congress, Law type, and Law number. These new endpoints will use the bill endpoint's elements so please refer to the "Elements and Descriptions" section for detailed information on possible values.
Please use the law number assigned by NARA when making a request by law number. Law numbers can be found for Public Laws and for Private Laws. You can use the dropdown menus on both pages to switch to different Congresses._
It might be worth mentioning how the number required by the law details API must be extracted from the bills[x].laws[y].number
. It might also be useful to add a url
for the law details to the bills[].laws[]
e.g.
{
bills: [
{
"congress": 118,
"latestAction": {
"actionDate": "2024-04-24",
"text": "Became Public Law No: 118-50."
},
"laws": [
{
"number": "118-50",
"type": "Public Law"
"url": "https://api.congress.gov/v3/law/118/pub/50?format=json"
}
],
"number": "815",
"originChamber": "House",
"originChamberCode": "H",
"title": "Making emergency supplemental appropriations for the fiscal year ending September 30, 2024, and for other purposes.",
"type": "HR",
"updateDate": "2024-04-26",
"updateDateIncludingText": "2024-04-26T16:27:29Z",
"url": "https://api.congress.gov/v3/bill/118/hr/815?format=json"
},
...
],
...
}
Thanks for the help @apreiter18, One last thing. It would be nice if the API returned 404 instead of 500 if the law number does not exist like the example in my OP.
Sure thing, @ryparker - we will investigate this!
@ryparker - quick update- I have a ticket in about the error message. Once scheduled, please refer to the change log for updates. Have a good day and thanks for reporting this!
When requesting the law details for a pub law in the 118th congress, the response is 500.
e.g. Request Law number
815
of congress118
and law typepub
Response: 500
I expected this to return data since it is listed in the law list response:
Response: