← All work

Open source · Python libraries

fred-loader and census-loader

Two Python libraries providing a readable naming layer over federal data APIs, so a request can name the concept rather than the API's series code.

Role
Author
Sources
Federal Reserve Economic Data, U.S. Census Bureau
Stack
Python, pandas, REST APIs
Status
Used daily, refactor in progress

Federal statistical agencies publish extraordinary amounts of data through APIs that were designed around internal identifiers. If you want real median household income, you need to know which series code carries it, which vintage you are getting, and how that code differs from the four similar ones. The knowledge required is specific to the API rather than to the subject matter.

That cost is paid by every analyst using the data, and paid again after time away from it, while the underlying request (median household income by state since 2010) is unambiguous.

A naming layer, plus the things that make a naming layer usable in practice. Both libraries share a deliberate house style, so knowing one means knowing the other:

  • Human-readable names over raw codes. You ask for the concept; the library owns the mapping to whatever the API calls it.
  • Discovery helpers built for interactive use. available(), search(), and info() mean you can find what exists from a Jupyter cell instead of alt-tabbing to API documentation.
  • Rate-limit-aware batching. Requests are batched explicitly rather than optimistically, because these APIs will throttle you and a library that pretends otherwise fails halfway through a long pull.
  • Guard patterns over silent failure. Explicit checks with an early exit and a clear message. An empty frame returned silently ends up in an analysis; an explicit failure does not.

The design goal was that the libraries could be used without learning either my abstractions or the API's.

Both are in regular personal use and feed otter, my modeling layer. fred-loader is mid-refactor as I bring it in line with the conventions census-loader settled on.

fred-loader · census-loader · Back to all work