API Technical Discussions

API extension for query across hierarchy

Hi All,

The API has incredible functionality for query/results within the nested US Census Bureau Geography (e.g. getting data for all the tracts in a county or all the block groups within a track).

However, it does not appear to support queries that run across the same geography very well.

For instance It does not appear to allow me to query the same parameter (e.g. race) in Tract A within County B and Tract C within County D.

In using the API, it does not appear to recognize two items in the "in" statement. So for instance in=state:04,05&for=county:* will only return AZ counties, not AZ & AR counties.


Submitted by

Stage: Active

Feedback Score

1 vote
1 up votes
0 down votes

Idea Details

Vote Activity

  1. Upvoted

Similar Ideas [ 4 ]


  1. The idea was posted


  1. Comment
    dgcatanzaro ( Idea Submitter )

    I forgot to mention *why* this is important. The key is that when I want to query two Tracts that are geographically next to each other but in different Counties.

    If I wanted to do that query via the API, I believe it is two queries, not one.

  2. Comment


    Hi. Thanks for your feedback. Your assessment is correct that one must currently submit two queries to get the value of a variable for tracts in two different counties. The ``in'' clause does not currently allow wildcards or multiple values for individual geography parts. One of our initial design goals for the API was to keep a simple URL grammar while providing very low per-query latency, which should limit the overhead of submitting two queries.

    We do plan to allow wildcards inside ``in'' clauses for certain geography hierarchies, however, allowing multiple values for individual geography parts is a bit tricky. Let's look at your tract example. Here are two queries for two tracts in separate counties:



    Notice that each query uses the ``in'' clause to fully qualify the specific tract from the ``for'' clause. Combining these into a single query is difficult because it would become ambiguous which county is used to fully qualify each tract. Now imagine that the states could also be different (different tracts from different counties in different states), and you'll see the problem becomes more difficult as the depth of the hierarchy increases.

    The best solution to this is to use fully qualified geography IDs. GNIS does exactly this, though only for a limited number of datasets and geography hierarchies.

    We have this feature request in our feature/bug tracking database. I suspect that we will add a query mechanism, at some later time, which will support multiple fully qualified FIPS codes. However, that is just speculation; I can't give you a timeframe. For now please just submit two separate queries.

  3. Comment
    dgcatanzaro ( Idea Submitter )

    Hi Dave,

    Thanks for confirming what I had thought.

    I personally think that your fully qualified geography IDs has the most merit. I had hoped to do that using GNIS but unfortunately the geography I am interested in (tract) is not supported in GNIS.

    I think one way of supporting this type of query is to concatenate the state/county FIPS codes with the tract to obtain that unique number so if you supported tract=06001400600 and tract=06007000103 then a query such as:


    would work !

Add your comment