Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

this is not working ---- collections response is now sorting by lastModified date. #24

Closed
ganeshkharad2 opened this issue Jan 17, 2019 · 2 comments

Comments

@ganeshkharad2
Copy link

collections response is now sorting by lastModified date.

https://api.govinfo.gov/collections/CHRG/1990-01-01T00:00:00Z/?offset=10000&pageSize=100&api_key=DEMO_KEY

snippet:

{
"count": 27027,
"message": null,
"nextPage": "https://api.govinfo.gov/collections/CHRG/1990-01-01T00:00:00Z/?offset=100&pageSize=100",
"previousPage": null,
"packages": [
{
"packageId": "CHRG-103hhrg76069",
"lastModified": "2018-10-30T17:25:19Z",
"packageLink": "https://api.govinfo.gov/packages/CHRG-103hhrg76069/summary",
"docClass": "HHRG",
"title": "Bpa Competitiveness"
},
{
"packageId": "CHRG-103hhrg74075",
"lastModified": "2018-10-30T17:21:12Z",
"packageLink": "https://api.govinfo.gov/packages/CHRG-103hhrg74075/summary",
"docClass": "HHRG",
"title": "Bpa Proposed Flscal Year 1994 Budget"
},
{
"packageId": "CHRG-103hhrg69593",
"lastModified": "2018-10-30T17:17:43Z",
"packageLink": "https://api.govinfo.gov/packages/CHRG-103hhrg69593/summary",
"docClass": "HHRG",
"title": "Indian Tribal Justice Act"
},
{
"packageId": "CHRG-103hhrg74346",
"lastModified": "2018-10-30T13:44:22Z",
"packageLink": "https://api.govinfo.gov/packages/CHRG-103hhrg74346/summary",
"docClass": "HHRG",
"title": "Bpa Electric Power Resources Acquisition"
},
{
"packageId": "CHRG-113shrg28394",
"lastModified": "2018-10-30T13:41:19Z",
"packageLink": "https://api.govinfo.gov/packages/CHRG-113shrg28394/summary",
"docClass": "SHRG",
"title": "Reassessing Solitary Confinement II: The Human Rights, Fiscal, and Public Safety Consequences"
},
{
"packageId": "CHRG-115shrg27017",
"lastModified": "2018-10-30T13:41:16Z",
"packageLink": "https://api.govinfo.gov/packages/CHRG-115shrg27017/summary",
"docClass": "SHRG",
"title": "Nominations of Brock Long, Russell Vought and Neomi Rao"
},
...

Originally posted by @jonquandt in #19 (comment)

@ganeshkharad2
Copy link
Author

"message": "Error page size + offset must be less than maxoffset: 10000"

@jonquandt
Copy link
Member

@ganeshkharad2 - The API has a 10,000 item limit for the collections request, so if your count is higher than that, you should consider splitting your request range using both startDate and endDate.

https://github.com/usgpo/api#collection-update

The collections response is sorted by each package's lastModified value, starting with the newest first.

so, you could use:

https://api.govinfo.gov/collections/CHRG/1990-01-01T00:00:00Z/?offset=9899&pageSize=100&api_key=DEMO_KEY
to get the last value available there. The last item available for that request would be:

{
	"packageId": "CHRG-113hhrg86796",
	"lastModified": "2018-07-30T19:11:28Z",
	"packageLink": "https://api.govinfo.gov/packages/CHRG-113hhrg86796/summary",
	"docClass": "HHRG",
	"title": "Changes to the Height Act: Shaping Washington, D.c., for the Future, Part II",
	"congress": "113"
}

What I would recommend would be to construct the request to start with that one - you may need to slightly adjust to get only 10k results, as multiple packages may be published at the same time.

https://api.govinfo.gov/collections/CHRG/2018-07-30T19:12:28Z/?offset=0&pageSize=100&api_key=DEMO_KEY

which has 9831 results.

You could then use the startDate from the above as the endDate for a follow-on request.

https://api.govinfo.gov/collections/CHRG/2018-06-01T00:00:00Z/2018-07-30T19:12:28Z/?offset=0&pageSize=100&api_key=DEMO_KEY

Then you could do a further set of requests until you get to the total number of results. Based on the base collections request, there are 27858 total packages:

https://api.govinfo.gov/collections?api_key=DEMO_KEY

{
	"collectionCode": "CHRG",
	"collectionName": "Congressional Hearings",
	"packageCount": 27858,
	"granuleCount": 33
},

Alternatively, if you want to retrieve the full set of CHRG, you could use our sitemaps to identify all packages currently in the system, using the packageid as identified in the <loc> values.

https://www.govinfo.gov/sitemap/CHRG_sitemap_index.xml

https://www.govinfo.gov/sitemap/CHRG_2018_sitemap.xml

<url>
<loc>
https://www.govinfo.gov/app/details/CHRG-115jhrg28355
</loc>
<lastmod>2018-07-02T19:05:01.409Z</lastmod>
<changefreq>monthly</changefreq>
<priority>1.0</priority>
</url>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants