A question came up on the US Census slack, leading to the recognition that the US Census Bureau API
doesn't support queries for data for "all ZCTAs in a state". Nothing about the Census Bureau's definition of
ZCTA requires that they be contained within a single state, which is probably why the API rejects the query with a message,
error: unknown/unsupported geography heirarchy
.
I've been looking for a general method to answer these kinds of questions for a long time. This Gist demonstrates a workable approach. It's based on data published by the Census LEHD LODES program, which provides, for every Census block in the US, a crosswalk indicating which geographies that block is in. (The set of geographies is limited but still very useful. See the technical doc PDF for more details.)
For any two geography types, one can simply select those two columns from the crosswalk and eliminate duplicate rows. This results in a crosswalk that can be used to answer the question "which {instances of geography type A} include(s) some or all of {instance of geography type b}". Or, put in plain language, "which state or states is a given ZIP code in?" The only shortcoming of the method is that it gives no information about how much of any given geography is contained in the other.
This gist includes the crosswalk created to answer the original question, since it seems like something many people might need. It also includes the code used to make that, and two variants for other geography types (but not the data files produced by those.)
You should be able to run these python programs readily in Google Colab, Azure Notebooks, or other public Jupyter Notebook server. In fact, here's an example, in Google Colab of a tract-to-place xref for the state of Massachusetts.