Skip to content

Instantly share code, notes, and snippets.

@Keareys
Last active November 8, 2020 17:08
Show Gist options
  • Save Keareys/75a4e7a4e1b7260b3099563378424684 to your computer and use it in GitHub Desktop.
Save Keareys/75a4e7a4e1b7260b3099563378424684 to your computer and use it in GitHub Desktop.
Census API Example Calls for Key Demographic Attributes used in Environmental Justice Work at MTC
Primary Census API Documentation Page:
http://www.census.gov/data/developers/data-sets.html
ACS Summary File Documentation
Other Useful Documentation Examples:
http://www.opengeocode.org/tutorials/USCensusAPI.php
https://www.socialexplorer.com/data/ACS2010/documentation/781dcba1-deed-47f9-a223-0cbc4e2b65b6
Example GEO Calls: http://api.census.gov/data/2010/sf1/geo.html
API Key(s):
key=5fbaa5725148859f644e88cd2c738b394616a684
key=5d7f6b7062b041cc7fd06969339282a5c30a5300
Datasets
Decennial Census (2010, 2000, 1990)
http://www.census.gov/data/developers/data-sets/decennial-census-data.html
1990
http://api.census.gov/data/2010/sf1/variables.html
2000
http://api.census.gov/data/2000/sf1/variables.html
http://api.census.gov/data/2000/sf3/variables.html
2010
http://api.census.gov/data/2010/sf1/variables.html
2000 Census API Call: Get Tracts within the 9 County Bay Region from SF3 Data
http://api.census.gov/data/2000/sf3?key=5fbaa5725148859f644e88cd2c738b394616a684&NAME&for=tract:*&in=state:06+county:001,013,041,055,075,081,085,095,097&get=P001001,P011001,P011002,P039001,P039002,P039013,P040001,P041001,P042002,P042026,P008035,P008036,P008037,P008038,P008039,P008040,P008074,P008075,P008076,P008077,P008078,P008079,P088001,P088002,P088003,P088004,P088005,P088006,P088007,P088008,P088009,P088010
Variables Needed:
- Civilian veterans 18 years and over: http://api.census.gov/data/2000/sf3/variables/P040001.json
- Seniors (over 65 years old):Sex By Age- For Male Population P008035...P008040 For Female Population: P008074...P008079
and from Household Universe:P011001 (http://api.census.gov/data/2000/sf3/variables/P011001.json)
- Low Income Households: http://api.census.gov/data/2000/sf3/variables/P088001.json
P088002...P0880010
sum(P088002 thru P088009)
- People w/ disabilities:P041001 (Don't compare disability)
http://api.census.gov/data/2000/sf3/variables/P041001.json
- Total Population: P007001
http://api.census.gov/data/2000/sf3/variables/P007001.json
Example API Call for State, County, Tracts (Bay Area)
http://api.census.gov/data/2000/sf3?key=5fbaa5725148859f644e88cd2c738b394616a684&get=P040001,NAME&for=tract:*&in=state:06+county:001,013,041,055,075,081,085,095,097
Example API Call: Get Tracts within the 9 County Bay Region from SF1 Data
http://api.census.gov/data/2010/sf1?key=5fbaa5725148859f644e88cd2c738b394616a684&NAME&for=tract:*&in=state:06+county:001,013,041,055,075,081,085,095,097&get=H0030001
American Community Survey 5-Year Data (2005-2009)
Variable Description:
http://api.census.gov/data/2009/acs5/variables.html
Table Shells: http://www2.census.gov/programs-surveys/acs/summary_file/2009/documentation/5_year/ACS_2005-2009_SF_Tech_Doc.pdf (See Appendix E)
2009 ACS API Call
http://api.census.gov/data/2009/acs5?get=NAME,B01003_001E,B09017_001E,B09017_002E,B11007_002E,B17026_001E,B17026_002E,B17026_003E,B17026_004E,B17026_005E,B17026_006E,B17026_007E,B17026_008E,B17026_009E,B21001_001E,B21001_002E,B21001_018E&for=tract:*&in=state:06+county:001,013,041,055,075,081,085,095,097&key=5fbaa5725148859f644e88cd2c738b394616a684
American Community Survey 5-Year Data (2010)
Variable Description:
http://api.census.gov/data/2010/acs5/variables.html
2010 ACS API Call
http://api.census.gov/data/2010/acs5?get=NAME,B01003_001E,B09017_001E,B09017_002E,B11007_002E,B17026_001E,B17026_002E,B17026_003E,B17026_004E,B17026_005E,B17026_006E,B17026_007E,B17026_008E,B17026_009E,B21001_001E,B21001_002E,B21001_018E&for=tract:*&in=state:06+county:001,013,041,055,075,081,085,095,097&key=5fbaa5725148859f644e88cd2c738b394616a684
Total Population
Poplation Age 65 Plus (Use Census 2010 SF1)
Population Age 65 Plus in Households
Households with one or more persons age 65 and over
B17026.Ratio of Income to Poverty Level of Families in the Past 12 Months
Under .50
.50 to .74
.75 to .99
1.00 to 1.24
1.25 to 1.49
1.50 to 1.74
1.75 to 1.84
1.85 to 1.99
B21001_001E.B21001_002E.Total Veterans
Male Veterans
Female Veterans
American Community Survey 5-Year Data (2010-2014):
http://www.census.gov/data/developers/data-sets/acs-survey-5-year-data.html
Table Shells: http://www2.census.gov/programs-surveys/acs/summary_file/2014/documentation/user_tools/ACS2014_Table_Shells.xlsx
Variable Description:
http://api.census.gov/data/2014/acs5/variables.html
2014 ACS API Call
http://api.census.gov/data/2014/acs5?get=NAME,B00001_001E,B09020_001E,B09020_002E,C17002_001E,C17002_002E,C17002_003E,C17002_004E,C17002_005E,C17002_006E,C17002_007E,C18108_001E,B21001_001E,B21001_002E,B21001_003E,B21001_004E,B21001_022E&for=tract:*&in=state:06+county:001,013,041,055,075,081,085,095,097&key=5fbaa5725148859f644e88cd2c738b394616a684
B00001_001E.Total Population
B09020_001E.Poplation Age 65 Plus
B09020_002E.Population Age 65 and over in households, Households with one or more persons age 65 and over
C17002_001E. Ratio of Income to Poverty Level of Families in the Past 12 Months
C17002_002E.Under .50
C17002_003E.50 to .99
C17002_004E.1.00 to 1.24
C17002_005E.1.25 to 1.49
C17002_006E.1.50 to 1.84
C17002_007E.1.85 to 1.99
C18108_001E.Total Population with a Disability
B21001_001E.B21001_002E.Total Veterans
B21001_003E.Total Non Veterans
B21001_004E.Male Veterans
B21001_022E.Female Veterans
http://api.census.gov/data/2014/acs5?get=NAME,B00001_001E,B09020_001E,B09020_002E,C17002_001E,C17002_002E,C17002_003E,C17002_004E,C17002_005E,C17002_006E,C17002_007E,C18108_001E,B21001_001E,B21001_002E,B21001_003E,B21001_004E,B21001_022E,&for=tract:*&in=state:06+county:001,013,041,055,075,081,085,095,097&key=5fbaa5725148859f644e88cd2c738b394616a684
API Variable Lookup:https://metrotrans-my.sharepoint.com/personal/ksmith_mtc_ca_gov/Documents/Projects/EJ%20Analysis%202016/EJ%20Selected%20Variables%20API%20Documentation.xlsx?web=1
Convert json Output to CSV Format
Here are a few tools that will convert the API output (Json) into csv format for use in Excel or a database for import into GIS
Preferred Tool to use for converting data to xlsx or csv:
http://www.convertcsv.com/json-to-csv.htm
Another Useful Online Converter
https://json-csv.com/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment