usgpo / link-service

The link service is used to create links to content and metadata on govinfo
Other
90 stars 40 forks source link

Cannot use link service when there are multiple results #41

Closed avalatea closed 3 weeks ago

avalatea commented 4 weeks ago

Hi! I am trying to grab the committee reports for some bills, but it looks like we cannot find the link when there are multiple reports. Can this be fixed somehow? Maybe if there's another field?

Example url: https://www.govinfo.gov/link/crpt/118/h.r.529

jonquandt commented 4 weeks ago

Hi -- you may want to look at our GovInfo API Related Service instead. For instance, for a given Congressional Bill package ID you can get a list of all relationships that we have currently identified, including Congressional Reports:

https://api.govinfo.gov/related/BILLS-118hr529eh?api_key=DEMO_KEY

{
    "relationships": [
        {
            "relationshipLink": "https://api.govinfo.gov/related/BILLS-118hr529eh/BILLSTATUS",
            "collection": "BILLSTATUS",
            "relationship": "Bill Status"
        },
        {
            "relationshipLink": "https://api.govinfo.gov/related/BILLS-118hr529eh/BILLS",
            "collection": "BILLS",
            "relationship": "Bill versions"
        },
        {
            "relationshipLink": "https://api.govinfo.gov/related/BILLS-118hr529eh/HOB",
            "collection": "HOB",
            "relationship": "Bill History"
        },
        {
            "relationshipLink": "https://api.govinfo.gov/related/BILLS-118hr529eh/CREC",
            "collection": "CREC",
            "relationship": "Congressional Record"
        },
        {
            "relationshipLink": "https://api.govinfo.gov/related/BILLS-118hr529eh/CRPT",
            "collection": "CRPT",
            "relationship": "Congressional Reports"
        }
    ],
    "relatedId": "BILLS-118hr529eh"
}

If you follow the CRPT collectionCode relationship, https://api.govinfo.gov/related/BILLS-118hr529eh/CRPT?api_key=DEMO_KEY, you will get access to multiple reports:

{
    "results": [
        {
            "dateIssued": "2024-04-02",
            "granuleId": "CRPT-118hrpt436",
            "citation": "118 H.Rept. 436",
            "congress": "118",
            "docType": "H.Rept.",
            "reportNumber": "436",
            "packageId": "CRPT-118hrpt436",
            "lastModified": "2024-07-08T15:20:43Z",
            "title": "EXTENDING LIMITS OF U.S. CUSTOMS WATERS ACT",
            "granuleLink": "https://api.govinfo.gov/packages/CRPT-118hrpt436/granules/CRPT-118hrpt436/summary"
        },
        {
            "dateIssued": "2024-04-02",
            "granuleId": "CRPT-118hrpt436-pt2",
            "citation": "118 H.Rept. 436",
            "congress": "118",
            "docType": "H.Rept.",
            "reportNumber": "436",
            "packageId": "CRPT-118hrpt436",
            "lastModified": "2024-07-08T15:20:43Z",
            "title": "EXTENDING LIMITS OF U.S. CUSTOMS WATERS ACT",
            "granuleLink": "https://api.govinfo.gov/packages/CRPT-118hrpt436/granules/CRPT-118hrpt436-pt2/summary"
        }
    ],
    "relatedId": "BILLS-118hr529eh"
}

Edited to add: if you look at the lastModified keys of each of the results, you could identify Reports that you haven't accessed since the last time you checked, assuming you're using this programmatically.

avalatea commented 4 weeks ago

@jonquandt How would I obtain the access code id, in this case: BILLS-118hr529eh. I can see where most of it comes from, but the eh at the end is...mysterious.

jonquandt commented 4 weeks ago

That's the Engrossed in House version of the bill. Each version of the bill text has its own packageId in GovInfo.

A potential alternative for the first request would be to use the BILLSTATUS packageId which is entirely predictable irrespective of the bill version

https://api.govinfo.gov/related/BILLSTATUS-118hr529?api_key=DEMO_KEY

This returns a number of the same relationships - including to the related reports as well as different versions of the bill text:


{
    "relationships": [
        {
            "relationshipLink": "https://api.govinfo.gov/related/BILLSTATUS-118hr529/BILLS",
            "collection": "BILLS",
            "relationship": "Bill versions"
        },
        {
            "relationshipLink": "https://api.govinfo.gov/related/BILLSTATUS-118hr529/HOB",
            "collection": "HOB",
            "relationship": "Bill History"
        },
        {
            "relationshipLink": "https://api.govinfo.gov/related/BILLSTATUS-118hr529/CRPT",
            "collection": "CRPT",
            "relationship": "Congressional Reports"
        }
    ],
    "relatedId": "BILLSTATUS-118hr529"
}

Are you interested in only a single bill or all bills for a given Congress?

Using the collections endpoint against the BILLSTATUS or BILLS collection could be useful as a useful jumping off point, or if you're interested in something more targeted, then the Search Service might be useful. See our api repo for more info.

Sample collections request for new and updated BILLSTATUS packages from the current month:

https://api.govinfo.gov/collections/BILLSTATUS/2024-08-01T00:00:00Z?offsetMark=*&pageSize=100&api_key=DEMO_KEY

avalatea commented 4 weeks ago

Hi! This information is good for now. Thank you so much for the help!

jonquandt commented 3 weeks ago

Closing this issue.