Giter Club home page Giter Club logo

Comments (1)

jonquandt avatar jonquandt commented on July 30, 2024

@cnizzardini - the first request is failing because CREC packages (and granules) do not have an XML representation of the content. The API is handling your request for an XML of the content and the server is returning our standard 404 for content that doesn't exist. You may want to add the -L switch to your curl request so that your request follows internal server redirects:

$ curl -L -X GET "https://api.govinfo.gov/packages/CREC-2018-01-04/granules/CREC-2018-01-04-pt1-PgD7-3/xml?api_key=DEMO_KEY" -H "accept: /"

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   235  100   235    0     0    203      0  0:00:01  0:00:01 --:--:--   209
100   182  100   182    0     0    147      0  0:00:01  0:00:01 --:--:--   147
100   123    0   123    0     0     89      0 --:--:--  0:00:01 --:--:--    89
{"timestamp":1542519554946,"status":404,"error":"Not Found","message":"No message available","path":"/govinfoapi/content/"}

Your options for content download for the granule you're looking for is available via the summary endpoint. e.g.:

curl -X GET "https://api.govinfo.gov/packages/CREC-2018-01-04/granules/CREC-2018-01-04-pt1-PgD7-3/summary?api_key=DEMO_KEY" -H "accept: /"

{"title":"Daily Digest/House of Representatives","collectionCode":"CREC","collectionName":"Congressional Record","category":"Proceedings of Congress and General Congressional Publications","dateIssued":"2018-01-04","detailsLink":"https://www.govinfo.gov/app/details/CREC-2018-01-04/CREC-2018-01-04-pt1-PgD7-3","granulesLink":"https://api.govinfo.gov/packages/CREC-2018-01-04/granules?offset=0&pageSize=100","packageId":"CREC-2018-01-04","packageLink":"https://api.govinfo.gov/packages/CREC-2018-01-04/summary","granuleId":"CREC-2018-01-04-pt1-PgD7-3","download":{"txtLink":"https://api.govinfo.gov/packages/CREC-2018-01-04/granules/CREC-2018-01-04-pt1-PgD7-3/htm","pdfLink":"https://api.govinfo.gov/packages/CREC-2018-01-04/granules/CREC-2018-01-04-pt1-PgD7-3/pdf","modsLink":"https://api.govinfo.gov/packages/CREC-2018-01-04/granules/CREC-2018-01-04-pt1-PgD7-3/mods","premisLink":"https://api.govinfo.gov/packages/CREC-2018-01-04/premis","zipLink":"https://api.govinfo.gov/packages/CREC-2018-01-04/zip"},"bookNumber":"1","granuleClass":"DAILYDIGEST","subGranuleClass":"DDHCHAMBER","granuleDate":"2018-01-04","pagePrefix":"D","lastModified":"2018-07-31T12:43:00Z"}

The download section in the summary shows:

"download": {
		"txtLink": "https://api.govinfo.gov/packages/CREC-2018-01-04/granules/CREC-2018-01-04-pt1-PgD7-3/htm",
		"pdfLink": "https://api.govinfo.gov/packages/CREC-2018-01-04/granules/CREC-2018-01-04-pt1-PgD7-3/pdf",
		"modsLink": "https://api.govinfo.gov/packages/CREC-2018-01-04/granules/CREC-2018-01-04-pt1-PgD7-3/mods",
		"premisLink": "https://api.govinfo.gov/packages/CREC-2018-01-04/premis",
		"zipLink": "https://api.govinfo.gov/packages/CREC-2018-01-04/zip"
	}

MODS and PREMIS present descriptive and preservation metadata about the content in xml format.

You'll see that performing a request for the htm rendition does return content as expected in curl:

$ curl -X GET "https://api.govinfo.gov/packages/CREC-2018-01-04/granules/CREC-2018-01-04-pt1-PgD7-3/htm?api_key=DEMO_KEY" -H "accept: /"

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   566  100   566    0     0    412      0  0:00:01  0:00:01 --:--:--   483
<html>
<head>
<title>Congressional Record, Volume 164 Issue 2 (Thursday, January 4, 2018)</title>
</head>
<body><pre>
[Congressional Record Volume 164, Number 2 (Thursday, January 4, 2018)]
[Daily Digest]
[Page D7]
From the Congressional Record Online through the Government Publishing Office [<a href="http://www.gpo.gov">www.gpo.gov</a>]





                        House of Representatives


Chamber Action
  The House was not in session today. The House is scheduled to meet in
a Pro Forma session at 12 noon on Friday, January 5, 2018.


</pre></body>
</html>

The API documentation page isn't really intended for curling in that manner -- since that /docs is a page that then fires off several requests to serve the swagger.json file in a (human) user-friendly manner

You could also just request the swagger.json directly via https://api.govinfo.gov/swagger.json

I hope that helps.

from api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.