Hi all,
I'm having issues accessing a (U.S.) Census Bureau API through Stata. My hunch is that it may be due to the bureau switching to an HTTPS-only system for API requests last year (for more info on this see here).
I've tried changing the URL i'm calling to be http but the census server automatically switches it to https, at which point I get a failure on the Stata side. Here is some code that shows the different errors:
To replicate this on your machine you'll need to get a key from the Census Bureau and input it in the above code where it says your_key_here; i can vouch that doing so is pain-free and only requires organizational name and email: https://api.census.gov/data/key_signup.html
This is the error I get when I run the above program:
Note the above is http. If I change it to https (so the API call reads copy "https://api.census.gov...") Stata returns this error:
I notice that William Lisowski has come across the same error previously (and related to the http / https issue), and flagged it in comment #4 of this Statalist post. I also found somebody who seems to be experiencing almost exactly the same issue accessing Census Bureau data through Stata on the American Community Survey Data Users Group site here.
Does anyone have any further information about this? Are other user-written programs that use Census Bureau APIs now failing?
I am running Stata 14.2 on Mac OS X El Capitan and wonder whether it might be a version thing and that Stata Corp shipped a modification with 15.x.
I'm having issues accessing a (U.S.) Census Bureau API through Stata. My hunch is that it may be due to the bureau switching to an HTTPS-only system for API requests last year (for more info on this see here).
I've tried changing the URL i'm calling to be http but the census server automatically switches it to https, at which point I get a failure on the Stata side. Here is some code that shows the different errors:
Code:
cap prog drop apicheck program apicheck tempfile webfile copy "http://api.census.gov/data/2010/sf1?key=your_key_here&get=P0050001,P0050002&for=zip+code+tabulation+area:*&in=state:02" "webfile.txt" import delimited "webfile.txt", clear end apicheck
This is the error I get when I run the above program:
Code:
file http://api.census.gov/data/2010/sf1?key=224506d438e3392533d0309d44a6f45eda2d19d0&get=P0050003,P0050004,P00500 > 05,P0050006&for=zip+code+tabulation+area:*&in=state:02 not found server says file temporarily redirected to https://api.census.gov/data/2010/sf1?key=224506d438e3392533d0309d44a6f4 > 5eda2d19d0&get=p0050003,p0050004,p0050005,p0050006&for=zip+code+tabulation+area:*&in=state:02 r(601);
Code:
Received fatal alert: handshake_failure r(5100);
Does anyone have any further information about this? Are other user-written programs that use Census Bureau APIs now failing?
I am running Stata 14.2 on Mac OS X El Capitan and wonder whether it might be a version thing and that Stata Corp shipped a modification with 15.x.
Comment