Get Places Contained within Another Place

datacommons.get_places_in(dcids, place_type)

Given a list of Place DCID’s, (e.g. County, State, Country, etc…), return the DCIDs of places contained within, of a specified type.


  • dcids (list of str) - DCIDs of parent places to query for.

  • place_type (str) - The type of the contained child Places within the given DCIDs to filter by. E.g. City and County are contained within State. For a full list of available types, see subClassOf Place.


A dict from a given dcid to a list of places identified by dcids of the given place_type.


  • ValueError - If the payload returned by the Data Commons REST API is malformed or the API key is not set.

Be sure to initialize the library, and specify the API key. Check the Python library setup guide for more details.


We would like to get all Counties contained in [California}( Specifying the dcids as a list result in the following:

>>> import datacommons as dc
>>> dc.set_api_key(YOUR_API_KEY_HERE)
>>> dc.get_places_in(["geoId/06"], "County")
  'geoId/06': [
    ...  # and 53 more