Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #286 from codefordc/combined-apiconn-prs
Combined ApiConn pull requests
- Loading branch information
Showing
10 changed files
with
664 additions
and
199 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
|
||
Configuring the Amazon Web Services Command Line Interface (awscli) | ||
------------------------------------------------------------------- | ||
|
||
Looking for instructions on downloading data from S3? These have moved to `our website <http://housinginsights.org/resources/aws-sync.html/>`_. | ||
|
||
|
||
Getting data from APIs | ||
====================== | ||
|
||
Using get_api_data.py | ||
------------- | ||
|
||
get_api_data.py is a command line script to pull data from external data sources. | ||
It uses modules in the housinginsights/sources directory to pull information from external data sources. | ||
See get_api_data.py for detailed instructions on how to run and parameters. | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
''' | ||
INCOMPLETE APPROACH | ||
See this issue: https://github.com/codefordc/housing-insights/issues/152 | ||
for some comments on latest status and next steps. | ||
The core method will need to be renamed to `get_data` and should have the same | ||
method signature as others. the current opendata.py file is a good model to | ||
look at to provide consistent approach. | ||
''' | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
import os | ||
import sys | ||
|
||
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), | ||
os.pardir,os.pardir))) | ||
|
||
from housinginsights.sources.base import BaseApiConn | ||
|
||
# secrets.json, yo | ||
census_key = os.environ.get("CENSUS_KEY") | ||
|
||
|
||
class CensusApiConn(BaseApiConn): | ||
""" | ||
Census API connector, confined to ACS5 2015 for now. | ||
""" | ||
BASEURL = 'http://api.census.gov/data' | ||
|
||
def __init__(self, arg): | ||
super(CensusApiConn, self).__init__(CensusApiConn.BASEURL) | ||
self.arg = arg | ||
|
||
def getacs5(self): | ||
params = {'key': census_key, 'get': 'B01003_001E,B25057_001E,B25058_001E,B25059_001E', 'for': 'tract:*', 'in': 'state:11'} | ||
result = self.get('/2015/acs5', params=params) | ||
if result.status_code != 200: | ||
err = "An error occurred during request: status {0}" | ||
raise Exception(err.format(result.status_code)) | ||
else: | ||
data = result | ||
print(data.text) | ||
|
||
|
||
CensusApiConn('fakearg').getacs5() |
Oops, something went wrong.