U.S. flag

An official website of the United States government

Skip Header
Search data, events, resources, and more

Core Concepts

Below are the terms you will need to be familiar with when running an API query, like this one for the dataset, Vintage 2014 Population Estimates: US, State, and PR Total Population and Components of Change (Use Firefox or Chrome):

https://api.census.gov/data/2014/pep/natstprc?get=STNAME,POP&DATE_=7&for=state:*

Tip We recommend that you use Chrome or Firefox when building and running API queries.

Variable

A variable is each unit of data you are searching for in a dataset.  Each variable that you can search for in a dataset has a name, which may be an acronym or meaningful on its own; e.g., STNAME, POP, DATE_.

In larger datasets, such as the American Community Survey, many of these names are based on an alphanumeric code; e.g., B01003_001E (Total Population).

You can find the list of variables in the dataset by visiting the variables page. For example, the variables page for the Vintage 2014 Population Estimates: US, State, and PR Total Population and Components of Change.

Figure 2: Variable Table for 2014 Population Estimates: US, State, and PR Total Population and Components of Change

You can include up to 50 variables in the same API call, separated by commas.

Required Variables

Most of the time, you have the option to choose the variables you want to include in your API call, but occasionally some datasets have required variables. Required variables are the parameters that you need to include in your search; otherwise, your search will produce no data and will return an error message. The variable table for each dataset lists which variables are required, as shown below in the variables page for the 2014 Population Estimates (Total and Components of Change) Dataset.

Figure 3: Variable Table for 2014 Population Estimates: US, State, and PR Total Population and Components of Change

Attributes

Attributes are additional variables you can include in your API call that give more information for the primary variable. For instance, they may provide labels, annotations, notes, margins of error, statistical significance, or flags that are related to your primary variable.

Attributes are available in many datasets and you can explore them in the discovery tool. For example, in the 2019 American Community Survey 1-Year dataset, you can see variables listed in the Attributes column of the discovery tool (shown below).

Figure 4: Attributes for 2019 ACS 1-Year Estimates

Variable Labels

Use the descriptive parameter to add variable labels to the second row of the API results.

  • &descriptive=true includes variable labels in the API output.

Example: https://api.census.gov/data/2014/pep/natstprc?get=STNAME,POP&DATE_=7&for=state:*&descriptive=true

  • &descriptive=false excludes variable labels in the API output.
    By default, API variable labels are also excluded in the API output when a descriptive parameter is not added to the API call.

Get Function

The get function (get=) specifies the required and selected variables you are requesting the API to give you. For example (use Chrome or Firefox):

https://api.census.gov/data/2014/pep/natstprc?get=STNAME,POP&DATE_=7&for=state:*

Predicate

The predicate specifies how variables should be filtered or limited, and you can create predicates of geography, string variables, numeric variables, and time (in time series datasets).

In this example, the predicate limits the search on the July 1, 2014 (&DATE_=7) population or housing unit estimate and for all states (&for=state:*):

https://api.census.gov/data/2014/pep/natstprc?get=STNAME,POP&DATE_=7&for=state:*

Please note:

  • Predicates always start with an ampersand (&).
  • A wildcard (:*) can be included to search for all the values of a variable. Wildcards work for geographies and string variables only.
  • A variable only needs to appear once in a query ̶ either in the get statement or as a predicate.  In the example above, DATE_ is a predicate (&DATE_=7), so you do not need to include it in the get statement (?get=STATENAME,POP). 

Below are some examples of predicates that you can use as a guide when building your queries.

Expand All

Collapse All

Response Formats: JSON and CSV

The results from your Census Data API data queries will return in JavaScript Object Notation (JSON) format, and you can easily plug those data into the formatting file or graphic of your choice. JSON is an easy format for exchanging data between platforms using human-readable language. The Census uses a nonstandard version of JSON that is streamlined:

  • Data are represented in a two-dimensional array
  • Square brackets [ ] hold arrays
  • Values are separated by a , (comma).

[["STNAME","POP","DATE_","state"],

["Alabama","4849377","7","01"],

["Alaska","736732","7","02"],

["Arizona","6731484","7","04"],

["Arkansas","2966369","7","05"],

["California","38802500","7","06"],

            ….. 

If you would like to get theAPI results in Comma Separated Values (CSV) format, use the outputFormat parameter:

  • &outputFormat=csv provides output in CSV format. When using this parameter in your web browser, it will create a CSV file that will appear in your downloaded files.

Example:

https://api.census.gov/data/2014/pep/natstprc?get=STNAME,POP&DATE_=7&for=state:*&outputFormat=csv

  • &outputFormat=json provides output in JSON format.

By default, API results are also provided in JSON format when an output parameter is not added to the API call.

Tip API calls are case sensitive. Be mindful of capitalization when using &outputFormat=csv and &outputFormat=json.

Group Function

The group function group([insert table ID]) allows you to get results for an entire table in one easy command; e.g. group(S0101). It provides results for all variables without having to individually include them in the API call. Even if the table has more than 50 variables, the group call will provide results for all variables in that table.

For example, this API query provides results for all 912 variables for table S0101 from the American Community Survey https://api.census.gov/data/2019/acs/acs1/subject?get=group(S0101)&for=state:*

Page Last Revised - March 20, 2025
Is this page helpful?
Thumbs Up Image Yes Thumbs Down Image No
NO THANKS
255 characters maximum 255 characters maximum reached
Thank you for your feedback.
Comments or suggestions?

Top

Back to Header
loading