CSV
You don't need an API to pull remote data!
You can publish you data in a Google Sheets and pull it via url in your code.
Likewise, github hosted files are accessible in a similar manner.
category | description | shortname | |
---|---|---|---|
0 | CD | Total Population | Tpop |
1 | CD | Total Male Population | Male |
2 | CD | Total Female Population | Female |
3 | CD | Percent of Residents - Black/African-American ... | Paa |
4 | CD | Percent of Residents - White/Caucasian (Non-Hi... | Pwhite |
TRACTCE10 | GEOID10 | CSA2010 | |
---|---|---|---|
0 | 10100 | 24510010100 | Canton |
1 | 10200 | 24510010200 | Patterson Park North & East |
2 | 10300 | 24510010300 | Canton |
3 | 10400 | 24510010400 | Canton |
4 | 10500 | 24510010500 | Fells Point |
JSON
Simple JSON
Note how raw text can be loaded
And the JSON structure may vary.
Here the Json txt takes the form of an array of objects, commonly refered to as an 'object array'.
Notice the difference?
col1 | col2 | |
---|---|---|
row1 | 1 | x |
row2 | 2 | y |
row3 | 3 | z |
col1 | col2 | |
---|---|---|
0 | 1 | x |
1 | 2 | y |
2 | 3 | z |
Json by URL (First API Example)
Heres a Really Simple Example API
provider | WARNING_UPGRADE_TO_V6 | terms | base | date | time_last_updated | rates | |
---|---|---|---|---|---|---|---|
AED | https://www.exchangerate-api.com | https://www.exchangerate-api.com/docs/free | https://www.exchangerate-api.com/terms | ALL | 2021-06-29 | 1624924802 | 0.0357 |
AFN | https://www.exchangerate-api.com | https://www.exchangerate-api.com/docs/free | https://www.exchangerate-api.com/terms | ALL | 2021-06-29 | 1624924802 | 0.7700 |
ALL | https://www.exchangerate-api.com | https://www.exchangerate-api.com/docs/free | https://www.exchangerate-api.com/terms | ALL | 2021-06-29 | 1624924802 | 1.0000 |
This is the census' ones
You can get a full list of tableId's from downloads here.
or explore the available ones by not submitting a tableID in the query
https://api.census.gov/data/2019/acs/acs5/groups/.jsongroups | |
---|---|
0 | {'name': 'B17015', 'description': 'POVERTY STA... |
1 | {'name': 'B18104', 'description': 'SEX BY AGE ... |
2 | {'name': 'B17016', 'description': 'POVERTY STA... |
3 | {'name': 'B18105', 'description': 'SEX BY AGE ... |
4 | {'name': 'B17017', 'description': 'POVERTY STA... |
Notice how the response varys when we actually give it a valule.
In this case we are given back meta data on table columns.
The response to any query is given in the acs documentation
https://api.census.gov/data/2019/acs/acs5/groups/B17015.jsonvariables | |
---|---|
B17015_001E | {'label': 'Estimate!!Total:', 'concept': 'POVE... |
B17015_001EA | {'label': 'Annotation of Estimate!!Total:', 'c... |
B17015_001M | {'label': 'Margin of Error!!Total:', 'concept'... |
B17015_001MA | {'label': 'Annotation of Margin of Error!!Tota... |
B17015_002E | {'label': 'Estimate!!Total:!!Income in the pas... |
Json by File
Sometimes Json doesn't come in the form you want.
In times like those, you can download the data directly to a file using the wget terminal command
This is the json - machine readable - file provided by the Census bureau.
It has the data we want stored as an attribute within a larger 'object'.
Here is one way to read in the json, access the attribute, and then load it up for use.
From there, you'd do whatever operations you need on it (either manuall or with code).
And then it can be loaded up as a dataset
Esri (Second API Example)
BNIA uses ARCGIS/ ESRI to store its data for programmatic retrieval in a bunch of our applicatons.
For certain API services, tools can be provided to help you build and model your query.
Here is ESRIs
To read in the Geospatial information provided by Esri requires the use of a speical library
OBJECTID | Name | Shape__Area | Shape__Length | geometry | |
---|---|---|---|---|---|
0 | 1 | Abell | 1.890312e+05 | 1796.137499 | POLYGON ((-76.61113 39.32345, -76.61167 39.323... |
1 | 2 | Allendale | 1.052283e+06 | 4351.591130 | POLYGON ((-76.67263 39.29184, -76.67263 39.291... |
2 | 3 | Arcadia | 5.854937e+05 | 3739.317928 | POLYGON ((-76.56853 39.33595, -76.56814 39.335... |
3 | 4 | Arlington | 4.677565e+05 | 2973.669980 | POLYGON ((-76.68627 39.34791, -76.68646 39.348... |
4 | 5 | Armistead Gardens | 1.224526e+06 | 5155.929124 | POLYGON ((-76.55880 39.30646, -76.55892 39.306... |