cenpy-devs / cenpy

Explore and download data from Census APIs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

APIConnection.query - documentation bug for geo_unit

JoeGermuska opened this issue · comments

This is very small, but the docs for cenpy.remote.APIConnection.query indicate that geo_unit can be dict or string

cenpy/cenpy/remote.py

Lines 145 to 158 in 1072257

Conduct a query over the USCB api connection
Parameters
-----------
cols : list of str
census column names to request
geo_unit : dict or str
identifiers for the basic spatial unit of the query
geo_filter : dict
required geometries above the specified geo_unit needed
to complete the query
apikey : str
USCB-issued API key for your query.
**kwargs : additional search predicates can be passed here

but there's no sign in the implementation of ever checking for a dict.

Before submitting a PR, would it be better to fix the docs? Or add support for it as a dict? I mostly use the ACS, and as far as I can tell, the for parameter in the API never takes more than one type, so I'm not sure there's need for a dict -- but maybe some of the other endpoints behave differently?

I think adding support for dict would be preferable. This removes the string formatting responsibility from the end user.

In the ACS, the for parameter would only have one key but it can accept multiple types of values:

type query
wildcard https://api.census.gov/data/2019/acs/acs5?get=NAME&for=county:*&in=state:06
fips https://api.census.gov/data/2019/acs/acs5?get=NAME&for=county:069&in=state:06
list of fips https://api.census.gov/data/2019/acs/acs5?get=NAME&for=county:069,071&in=state:06