Skip to content
Sara Cope edited this page May 14, 2021 · 10 revisions

Digital.gov uses https://api.data.gov/ to manage API key access.

Content APIs

HOME — https://digital.gov/index.json

Communities JSON — https://digital.gov/communities/index.json

Resources JSON — https://digital.gov/resources/index.json

Blog News Posts JSON — https://digital.gov/news/index.json

Events JSON — https://digital.gov/events/index.json

Services JSON - https://digital.gov/services/index.json

Sources JSON - https://digital.gov/sources/index.json

Single Community — https://digital.gov/communities/agile-lean/index.json

Single Resource — https://digital.gov/resources/omb-memos-circulars-executive-orders-and-other-policies/index.json

Single Blog Post — https://digital.gov/2018/07/17/experiments-in-tweaking-agile-for-ux/index.json

Single Event — https://digital.gov/event/2018/07/26/civic-service-design-tools-tactics/index.json

Taxonomy / Data APIs

All Images — https://digital.gov/images/v1/json/

All Topics — https://digital.gov/topics/v1/json/

All Authors — https://digital.gov/authors/v1/json/

API Templates

A bit about the how we built the terms APIs in HUGO https://discourse.gohugo.io/t/json-api-enpoints-for-taxonomy-terms/24592

Debugging APIs

If an API endpoint is not working, it usually means that data was passed into a page (via front matter) that is causing an issue in the API template.

To fix, you will either:

  • fix the specific content page that is causing the issue
  • fix the API template to no longer get triggered by this issue

How to identifying the where issue is

Before you start — Download the JSON View Chrome Extension. This will allow you to see the proper JSON formatting in the browser.

  1. Identify which API endpoint is not working — usually after someone "the list of authors on the workflow tool doesn't seem to be working anymore..."
  2. Check the console logs in the workflow tool to see if it's throwing CORS errors: Failed to load resource: net::ERR_BLOCKED_BY_CLIENT If so, ping the federalist team in #federalist-support chat on Slack. See this previous thread.
  3. Check to see that the JSON is rendering by opening the LIVE version of the API in the browser
  • If the JSON Viewer kicks in, and you see beautifully formatted JSON text, then the API is probably working
  • If the JSON Viewer doesn't kick in, and you see minified json data, then there is likely an issue with the API formatting.
  1. Copy the full text (view source) of the broken API into https://jsonlint.com/ and click "Validate JSON"
  2. The specific issue with the formatting should be visible.

Testing a fix

After a pull request is submitted to include the fix it can be tested by:

  • pulling the branch down locally either in the command line or GitHub Desktop tool
  • run the site locally in the branch
  • visit http://localhost:1313/authors/v1/json/
  • Select view source and copy the code
  • Paste the text into https://jsonlint.com/ and click "Validate JSON"
  • It shouldn't display any errors
Clone this wiki locally