uscensusbureau / citysdk

Convenient JavaScript utilities for working with Census APIs: Statistics, Cartographic GeoJSON, lat/lng -> FIPS, and other niceties (written in ClojureScript)
https://uscensusbureau.github.io/citysdk
MIT License
969 stars 183 forks source link

504 Gateway Timeout Error #315

Closed Remolten closed 5 years ago

Remolten commented 8 years ago

I'm receiving constant slowdown and/or 504 errors when attempting to use CitySDK with Python. The query builder on the website appears to be non-functional as well. Why exactly would this sort of thing be occurring?

brianbtrfld commented 7 years ago

Here is the sample request that is being made from @Remolten which returns the 503 response.

{ "level": "tract", "state": "SD", "sublevel": true, "variables": [ "PCT0120001" ], "api": "sf1", "year": "2010" }

The approach being vetted is getting population by block from the CitySDK.

Is there something wrong with this request?

ghost commented 7 years ago

Hi @Remolten @briangbutterfield

We have had issues in the past with certain services, but if you could send me any console errors that are being thrown that would help me track down the issue...

I have to apologize in advance for any delay in getting back to you. We are currently sans-developer...

brianbtrfld commented 7 years ago

@logantpowell Thank you for the response. I have attached a screenshot of the raw response which indicates response code 503 and the highlighted message.

2016-12-07_1504

ghost commented 7 years ago

On second look, you might be hitting on a more fundamental issue here: Currently, the way the CitySDK is designed, If you want all the blocks in a state, you are going to have to take a multi-step approach:

  1. first, request the sublevel of state (counties);
  2. second, request sublevel for each of the returned counties (tracts);
  3. then the sublevel of each tract (block-group);
  4. finally the sublevel of each block-group (blocks)

Give these a try?

brianbtrfld commented 7 years ago

@logantpowell I definitely read what you are saying and it makes more sense now; however, I am getting the same response (Status 503) on the most simple request which does return data from the interactive query builder.

We are successfully retrieving population by block using the census API, but I would like to confirm whether the CitySDK makes more sense for our scenario.

Additional thoughts?

{ "level": "state", "state": "SD", "sublevel": true, "variables": [], "api": "acs5", "year": "2014" }

Actually, I am not able to get 'any' request to return without a 503. I used the exact sample from the website and it did not work. I have even tried a new API key, same result. Is the site operational?

` import requests from requests.auth import HTTPBasicAuth

apikey = "my_key" request_url = "http://citysdk.commerce.gov"

def main(): request_obj = { 'zip': '21401', 'state': 'MD', 'level': 'state', 'sublevel': False, 'api': 'acs5', 'year': 2010, 'variables': ['income', 'population'] }

response = requests.post(request_url, auth=HTTPBasicAuth(apikey, None), json=request_obj)

print(response.json())

if name == 'main': main() `

Finally, can I pass in the request object a specific county and/or tract in order to perform the multi-step query effort. It does not look like you can based on the documentation.

ghost commented 7 years ago

The CitySDK is geared toward building maps, so if that's what you're trying to do then I would recommend you use it. If not geocoding or mapping, you might be better off using the "naked" API...

To your other request, I'm trying the query builder and the following request is working for me. You might be hitting some syntax problems. The quotes and commas are particularly temperamental.

Request object: { "level": "state", "state": "SD", "sublevel": true, "variables": [ "income", "population" ], "api": "acs5", "year": "2010" }

Response: { "level": "state", "state": "46", "sublevel": true, "variables": [ "NAME", "B19013_001E", "B01003_001E" ], "api": "acs5", "year": "2010", "lat": 44.368, "lng": -100.3364, "county": "065", "tract": "977800", "blockGroup": "4", "place": "49600", "place_name": "Pierre city", "geographyValidForAPI": true, "data": [ { "name": "Aurora County, South Dakota", "state": "46", "county": "003", "NAME": "Aurora County, South Dakota", "B19013_001E": "45230", "B01003_001E": "2739" }, { "name": "Beadle County, South Dakota", "state": "46", "county": "005", "NAME": "Beadle County, South Dakota", "B19013_001E": "40716", "B01003_001E": "16829" }, { "name": "Bennett County, South Dakota", "state": "46", "county": "007", "NAME": "Bennett County, South Dakota", "B19013_001E": "32841", "B01003_001E": "3441" }, { "name": "Bon Homme County, South Dakota", "state": "46", "county": "009", "NAME": "Bon Homme County, South Dakota", "B19013_001E": "41107", "B01003_001E": "7080" }, { "name": "Brookings County, South Dakota", "state": "46", "county": "011", "NAME": "Brookings County, South Dakota", "B19013_001E": "45134", "B01003_001E": "31250" }, { "name": "Brown County, South Dakota", "state": "46", "county": "013", "NAME": "Brown County, South Dakota", "B19013_001E": "45615", "B01003_001E": "36011" }, { "name": "Brule County, South Dakota", "state": "46", "county": "015", "NAME": "Brule County, South Dakota", "B19013_001E": "48277", "B01003_001E": "5128" }, { "name": "Buffalo County, South Dakota", "state": "46", "county": "017", "NAME": "Buffalo County, South Dakota", "B19013_001E": "27926", "B01003_001E": "1932" }, { "name": "Butte County, South Dakota", "state": "46", "county": "019", "NAME": "Butte County, South Dakota", "B19013_001E": "39041", "B01003_001E": "9888" }, { "name": "Campbell County, South Dakota", "state": "46", "county": "021", "NAME": "Campbell County, South Dakota", "B19013_001E": "42833", "B01003_001E": "1431" }, { "name": "Charles Mix County, South Dakota", "state": "46", "county": "023", "NAME": "Charles Mix County, South Dakota", "B19013_001E": "35808", "B01003_001E": "9075" }, { "name": "Clark County, South Dakota", "state": "46", "county": "025", "NAME": "Clark County, South Dakota", "B19013_001E": "43894", "B01003_001E": "3702" }, { "name": "Clay County, South Dakota", "state": "46", "county": "027", "NAME": "Clay County, South Dakota", "B19013_001E": "37198", "B01003_001E": "13816" }, { "name": "Codington County, South Dakota", "state": "46", "county": "029", "NAME": "Codington County, South Dakota", "B19013_001E": "43275", "B01003_001E": "27040" }, { "name": "Corson County, South Dakota", "state": "46", "county": "031", "NAME": "Corson County, South Dakota", "B19013_001E": "30877", "B01003_001E": "4053" }, { "name": "Custer County, South Dakota", "state": "46", "county": "033", "NAME": "Custer County, South Dakota", "B19013_001E": "46743", "B01003_001E": "8085" }, { "name": "Davison County, South Dakota", "state": "46", "county": "035", "NAME": "Davison County, South Dakota", "B19013_001E": "41867", "B01003_001E": "19397" }, { "name": "Day County, South Dakota", "state": "46", "county": "037", "NAME": "Day County, South Dakota", "B19013_001E": "36818", "B01003_001E": "5714" }, { "name": "Deuel County, South Dakota", "state": "46", "county": "039", "NAME": "Deuel County, South Dakota", "B19013_001E": "47000", "B01003_001E": "4373" }, { "name": "Dewey County, South Dakota", "state": "46", "county": "041", "NAME": "Dewey County, South Dakota", "B19013_001E": "33255", "B01003_001E": "5354" }, { "name": "Douglas County, South Dakota", "state": "46", "county": "043", "NAME": "Douglas County, South Dakota", "B19013_001E": "42794", "B01003_001E": "3046" }, { "name": "Edmunds County, South Dakota", "state": "46", "county": "045", "NAME": "Edmunds County, South Dakota", "B19013_001E": "47026", "B01003_001E": "4047" }, { "name": "Fall River County, South Dakota", "state": "46", "county": "047", "NAME": "Fall River County, South Dakota", "B19013_001E": "35833", "B01003_001E": "7078" }, { "name": "Faulk County, South Dakota", "state": "46", "county": "049", "NAME": "Faulk County, South Dakota", "B19013_001E": "38203", "B01003_001E": "2386" }, { "name": "Grant County, South Dakota", "state": "46", "county": "051", "NAME": "Grant County, South Dakota", "B19013_001E": "42625", "B01003_001E": "7382" }, { "name": "Gregory County, South Dakota", "state": "46", "county": "053", "NAME": "Gregory County, South Dakota", "B19013_001E": "33940", "B01003_001E": "4272" }, { "name": "Haakon County, South Dakota", "state": "46", "county": "055", "NAME": "Haakon County, South Dakota", "B19013_001E": "46281", "B01003_001E": "1886" }, { "name": "Hamlin County, South Dakota", "state": "46", "county": "057", "NAME": "Hamlin County, South Dakota", "B19013_001E": "44439", "B01003_001E": "5761" }, { "name": "Hand County, South Dakota", "state": "46", "county": "059", "NAME": "Hand County, South Dakota", "B19013_001E": "45895", "B01003_001E": "3402" }, { "name": "Hanson County, South Dakota", "state": "46", "county": "061", "NAME": "Hanson County, South Dakota", "B19013_001E": "46556", "B01003_001E": "3382" }, { "name": "Harding County, South Dakota", "state": "46", "county": "063", "NAME": "Harding County, South Dakota", "B19013_001E": "34792", "B01003_001E": "1250" }, { "name": "Hughes County, South Dakota", "state": "46", "county": "065", "NAME": "Hughes County, South Dakota", "B19013_001E": "53501", "B01003_001E": "16827" }, { "name": "Hutchinson County, South Dakota", "state": "46", "county": "067", "NAME": "Hutchinson County, South Dakota", "B19013_001E": "39310", "B01003_001E": "7388" }, { "name": "Hyde County, South Dakota", "state": "46", "county": "069", "NAME": "Hyde County, South Dakota", "B19013_001E": "41196", "B01003_001E": "1520" }, { "name": "Jackson County, South Dakota", "state": "46", "county": "071", "NAME": "Jackson County, South Dakota", "B19013_001E": "36354", "B01003_001E": "2991" }, { "name": "Jerauld County, South Dakota", "state": "46", "county": "073", "NAME": "Jerauld County, South Dakota", "B19013_001E": "40607", "B01003_001E": "2038" }, { "name": "Jones County, South Dakota", "state": "46", "county": "075", "NAME": "Jones County, South Dakota", "B19013_001E": "49464", "B01003_001E": "1076" }, { "name": "Kingsbury County, South Dakota", "state": "46", "county": "077", "NAME": "Kingsbury County, South Dakota", "B19013_001E": "44948", "B01003_001E": "5169" }, { "name": "Lake County, South Dakota", "state": "46", "county": "079", "NAME": "Lake County, South Dakota", "B19013_001E": "45606", "B01003_001E": "11008" }, { "name": "Lawrence County, South Dakota", "state": "46", "county": "081", "NAME": "Lawrence County, South Dakota", "B19013_001E": "42356", "B01003_001E": "23670" }, { "name": "Lincoln County, South Dakota", "state": "46", "county": "083", "NAME": "Lincoln County, South Dakota", "B19013_001E": "67365", "B01003_001E": "41289" }, { "name": "Lyman County, South Dakota", "state": "46", "county": "085", "NAME": "Lyman County, South Dakota", "B19013_001E": "36323", "B01003_001E": "3736" }, { "name": "McCook County, South Dakota", "state": "46", "county": "087", "NAME": "McCook County, South Dakota", "B19013_001E": "42022", "B01003_001E": "5639" }, { "name": "McPherson County, South Dakota", "state": "46", "county": "089", "NAME": "McPherson County, South Dakota", "B19013_001E": "31923", "B01003_001E": "2506" }, { "name": "Marshall County, South Dakota", "state": "46", "county": "091", "NAME": "Marshall County, South Dakota", "B19013_001E": "41023", "B01003_001E": "4618" }, { "name": "Meade County, South Dakota", "state": "46", "county": "093", "NAME": "Meade County, South Dakota", "B19013_001E": "46180", "B01003_001E": "25156" }, { "name": "Mellette County, South Dakota", "state": "46", "county": "095", "NAME": "Mellette County, South Dakota", "B19013_001E": "34055", "B01003_001E": "2032" }, { "name": "Miner County, South Dakota", "state": "46", "county": "097", "NAME": "Miner County, South Dakota", "B19013_001E": "43958", "B01003_001E": "2411" }, { "name": "Minnehaha County, South Dakota", "state": "46", "county": "099", "NAME": "Minnehaha County, South Dakota", "B19013_001E": "51799", "B01003_001E": "165799" }, { "name": "Moody County, South Dakota", "state": "46", "county": "101", "NAME": "Moody County, South Dakota", "B19013_001E": "52354", "B01003_001E": "6511" }, { "name": "Pennington County, South Dakota", "state": "46", "county": "103", "NAME": "Pennington County, South Dakota", "B19013_001E": "46849", "B01003_001E": "97922" }, { "name": "Perkins County, South Dakota", "state": "46", "county": "105", "NAME": "Perkins County, South Dakota", "B19013_001E": "33361", "B01003_001E": "2976" }, { "name": "Potter County, South Dakota", "state": "46", "county": "107", "NAME": "Potter County, South Dakota", "B19013_001E": "42422", "B01003_001E": "2380" }, { "name": "Roberts County, South Dakota", "state": "46", "county": "109", "NAME": "Roberts County, South Dakota", "B19013_001E": "37708", "B01003_001E": "10033" }, { "name": "Sanborn County, South Dakota", "state": "46", "county": "111", "NAME": "Sanborn County, South Dakota", "B19013_001E": "44732", "B01003_001E": "2380" }, { "name": "Shannon County, South Dakota", "state": "46", "county": "113", "NAME": "Shannon County, South Dakota", "B19013_001E": "24392", "B01003_001E": "13437" }, { "name": "Spink County, South Dakota", "state": "46", "county": "115", "NAME": "Spink County, South Dakota", "B19013_001E": "45000", "B01003_001E": "6518" }, { "name": "Stanley County, South Dakota", "state": "46", "county": "117", "NAME": "Stanley County, South Dakota", "B19013_001E": "51875", "B01003_001E": "2896" }, { "name": "Sully County, South Dakota", "state": "46", "county": "119", "NAME": "Sully County, South Dakota", "B19013_001E": "48958", "B01003_001E": "1328" }, { "name": "Todd County, South Dakota", "state": "46", "county": "121", "NAME": "Todd County, South Dakota", "B19013_001E": "25196", "B01003_001E": "9575" }, { "name": "Tripp County, South Dakota", "state": "46", "county": "123", "NAME": "Tripp County, South Dakota", "B19013_001E": "40221", "B01003_001E": "5743" }, { "name": "Turner County, South Dakota", "state": "46", "county": "125", "NAME": "Turner County, South Dakota", "B19013_001E": "48068", "B01003_001E": "8368" }, { "name": "Union County, South Dakota", "state": "46", "county": "127", "NAME": "Union County, South Dakota", "B19013_001E": "59889", "B01003_001E": "13903" }, { "name": "Walworth County, South Dakota", "state": "46", "county": "129", "NAME": "Walworth County, South Dakota", "B19013_001E": "39517", "B01003_001E": "5408" }, { "name": "Yankton County, South Dakota", "state": "46", "county": "135", "NAME": "Yankton County, South Dakota", "B19013_001E": "47124", "B01003_001E": "22216" }, { "name": "Ziebach County, South Dakota", "state": "46", "county": "137", "NAME": "Ziebach County, South Dakota", "B19013_001E": "27578", "B01003_001E": "2765" } ] }

neka-io commented 7 years ago

@logantpowell sorry to chime in late but maybe this will be helpful: The 503 error is probably because the API code threw an exception and for some reason didn't restart itself. This happened before. You may want to have someone get on the instance and see what's going on. The query builder uses the library, not the API. That's why it's still working :)

ghost commented 7 years ago

Ahhhhhh... dooooh! Let me ping the CDS to see if we can get a restart. Thank you Negar!

ghost commented 7 years ago

@briangbutterfield We restarted the server... give it another go?

kelsf commented 7 years ago

I'm also getting the 503 error.

I used the python example variables and it continues to show that the server cannot be reached due to the 503 error.

ghost commented 7 years ago

I apologize for any confusion, but the service seems to be working on my end atm:

https://jsfiddle.net/logantpowelll/dsf3bg7n/3/

Remolten commented 7 years ago

@logantpowell I am still getting 503 HTTP errors when running any request via Python via the CitySDK Web API. Perhaps you should try running the requests in Python, because the Javascript SDK may be working, but the normal Web API is not for me (and for others apparently). Thank you for your time.

ghost commented 7 years ago

@tshrestha Can you give us a hand with the Python request? Wondering if it's an HTTPS issue #200

Remolten commented 7 years ago

@logantpowell @tshrestha I have still had no luck with any requests. Visiting http://citysdk.commerce.gov/ in a web browser also throws a 503 HTTP Error.

ghost commented 7 years ago

apologies folks... we're working on our server issue currently... In the meantime, you can run this on your own server (local or hosted).

loganpowell commented 5 years ago

Hello everyone! We've got a new (beta) version, which should address these issues. It's now an NPM library and we've removed some bottle necks to improve reliability/performance. The caveat is that now, the geographies are generalized. You can find out more in the readme.