Queries Google Data Commons for public statistical data from global sources — demographic, economic, health, and environmental indicators. Resolves geographic entities to DCIDs and pulls time-series statistics without requiring an API key.
Data Commons aggregates data from census bureaus, health organizations, environmental agencies, and other authoritative sources into a unified knowledge graph. This skill answers statistical questions from it without an API key: scripts/query_datacommons.py reads observations from the JSON API that the datacommons.org website itself uses, and resolves names and Wikidata IDs through the keyless v2 resolve endpoint. The documented Python client (datacommons-client, below) is the optional keyed path — its observation and node methods return HTTP 401 without DC_API_KEY.
The keyed client is verified against datacommons-client 2.1.6 (current as of 2026-09; Python ≥ 3.10). This is the V2 client (package datacommons_client), not the legacy datacommons (V1) package — the two have different APIs; do not mix them. Keyword names matter: the place-hierarchy helpers take place_dcids, fetch_entity_names takes entity_dcids, and fetch_property_values takes properties — passing node_dcids to them raises TypeError.
| Scenario | Use Instead |
|---|---|
| A specific FRED economic series (GDP, CPI, interest rates) with vintage/revision data | alterlab-fred |
| U.S. Treasury fiscal data (debt, spending, revenue) | alterlab-usfiscaldata |
| NCI Imaging Data Commons (CT/MR/pathology images) — a different "Data Commons" | alterlab-imaging-data-commons |
| Spatial joins, buffers, or mapping of geometries | alterlab-geopandas |
| Finding clinical trials (recruitment status, phase, NCT IDs, enrollment) | alterlab-clinicaltrials |
| Bibliometrics: papers published per year on a topic, citation counts or trends | alterlab-research-lookup |
Hand-off rule. When the request matches a row above, open your answer by naming that skill by its exact id (for example alterlab-fred) and saying in one line why it fits better, then stop applying this skill's procedure. Name it even when you also need to ask for missing input. If only part of the request is out of scope, name the skill for that part and do only the in-scope part. A brief general pointer is fine; the named skill does the work.
No key, no install (standard library only). Verified live 2026-10-22:
S=scripts/query_datacommons.py
python $S resolve California Texas --type State # {"California": ["geoId/06"], ...}
python $S resolve --wikidata Q30 Q99 # Q30 -> country/USA, Q99 -> geoId/06
python $S resolve --coords 37.7749,-122.4194 # -> geoId/0667000 city, geoId/06075, geoId/06, ...
python $S observe Count_Person country/TUR --date 2020 # 83384680 (World Bank WDI)
python $S observe Count_Person geoId/06 geoId/48 --date all --csv > pop.csv # full series
python $S within Median_Income_Household geoId/06 County --date 2020 --names # all 58 counties
python $S vars-search "unemployment rate" --place country/USA
python $S has UnemploymentRate_Person Count_Person --entity country/USA
Every observation comes back as a tidy record — variable, entity, date, value plus the
facet's provenanceId, provenanceUrl, measurementMethod, unit — so it loads straight
into pandas (pd.read_csv("pop.csv"), then pivot_table(index="date", columns="entity")).
| Need | Keyless endpoint (GET unless noted) |
|---|---|
| Latest / one date | https://datacommons.org/api/observations/point?entities=…&variables=…[&date=2020] |
Full time series (the client's date="all") | …/api/observations/series?entities=…&variables=… |
Every child of a place in one call (the client's containedInPlace expression) | …/api/observations/point/within?parentEntity=geoId/06&childType=County&variables=…&date=2020 (or series/within) |
| Names, parents, descendants | …/api/place/name?dcids=…, …/api/place/parent?dcid=…, …/api/place/descendent?dcids=…&descendentType=County |
| Find / check variables | …/api/stats/stat-var-search?query=…&places=…; POST …/api/observation/existence {"entities":[…],"variables":[…]} |
| Name / Wikidata → DCID | POST https://api.datacommons.org/v2/resolve {"nodes":[…],"property":"<-description{typeOf:State}->dcid"} (or <-wikidataId->dcid) |
| Coordinates → DCIDs | v2 resolve {"nodes":["37.7749#-122.4194"],"property":"<-geoCoordinate->dcid"}, plus POST https://api.datacommons.org/v1/recon/resolve/coordinate {"coordinates":[{"latitude":37.7749,"longitude":-122.4194}]} |
Know the limits of this route and say so in the answer:
github.com/datacommonsorg/website, server/routes/), is not part of the documented REST API, and can change without notice. Cite the record's provenanceUrl and the retrieval date; robots.txt does not disallow it, but keep request rates modest.observation.fetch can return every facet (filter_facet_domains).UnemploymentRate_Person, BLS) need YYYY-MM; --date 2020 returns nothing for them — use latest or all.<-geoCoordinate->dcid answers for some points only, without the city (2026-11-04: 37.77#-122.4194 → county, state, country; 37.7749#-122.4194 → nothing). Rounding is no fix: it moves the point. The script also asks the keyless v1 coordinate resolver, which returns every containing place at full precision (city, county, state, tract, ZIP), and only if both are empty falls back to the US Census geocoder (GEOID → geoId/<GEOID>) or OpenStreetMap Nominatim → Wikidata (≤ 1 request/s). Its via field names the route behind each answer.Say how it was retrieved. End every answer with a short "How this was retrieved" line a reader can re-run: the command or endpoint with its key parameters (variable; entity DCIDs and the route that resolved each; date, with all for a full series as in the client's date="all"), for a hierarchy query the relation it stands for (geoId/06<-containedInPlace+{typeOf:County}), the facet's provenanceUrl, and the retrieval date.
--backend api forces the documented v2 API; without DC_API_KEY it exits with an error naming the key and the keyless default instead of answering from another source. With the key set and no --backend, observe/within use the v2 API.
datacommons-client (needs DC_API_KEY)The sections from here to "Working with Pandas" describe the documented Python client. Its
resolve methods work keyless; observation and node methods need DC_API_KEY (free at
https://apikeys.datacommons.org/). Use it when the user has a key or needs every facet.
Install the Data Commons V2 client with Pandas support (extra is lowercase pandas):
uv pip install "datacommons-client[pandas]"
For basic usage without Pandas:
uv pip install datacommons-client
The Data Commons API consists of three main endpoints, each detailed in dedicated reference files:
Query time-series statistical data for entities. See references/observation.md for comprehensive documentation.
Primary use cases:
Common patterns:
from datacommons_client import DataCommonsClient
client = DataCommonsClient()
# Get latest population data
response = client.observation.fetch(
variable_dcids=["Count_Person"],
entity_dcids=["geoId/06"], # California
date="latest"
)
# Get time series
response = client.observation.fetch(
variable_dcids=["UnemploymentRate_Person"],
entity_dcids=["country/USA"],
date="all"
)
# Query by hierarchy
response = client.observation.fetch(
variable_dcids=["Median_Income_Household"],
entity_expression="geoId/06<-containedInPlace+{typeOf:County}",
date="2020"
)
Explore entity relationships and properties within the knowledge graph. See references/node.md for comprehensive documentation.
Primary use cases:
Common patterns:
# Discover properties
labels = client.node.fetch_property_labels(
node_dcids=["geoId/06"],
out=True
)
# Navigate hierarchy (dict: DCID -> list of {"dcid", "name", "types"})
children = client.node.fetch_place_children(
place_dcids="country/USA",
children_type="State",
)
# Get entity names (dict: DCID -> Name(value=..., language=...))
names = client.node.fetch_entity_names(
entity_dcids=["geoId/06", "geoId/48"]
)
Translate entity names, coordinates, or external IDs into Data Commons IDs (DCIDs). See references/resolve.md for comprehensive documentation.
Primary use cases:
Common patterns:
# Resolve by name
response = client.resolve.fetch_dcids_by_name(
names=["California", "Texas"],
entity_type="State"
)
# Resolve by coordinates (returns a ResolveResponse, not a bare DCID)
coord_response = client.resolve.fetch_dcid_by_coordinates(
latitude="37.7749",
longitude="-122.4194"
)
# Resolve Wikidata IDs
response = client.resolve.fetch_dcids_by_wikidata_id(
wikidata_ids=["Q30", "Q99"]
)
Most Data Commons queries follow this pattern:
Resolve entities (if starting with names):
resolve_response = client.resolve.fetch_dcids_by_name(
names=["California", "Texas"], entity_type="State"
)
# to_dict() -> {"entities": [{"node": "California", "candidates": [{"dcid": ...}]}, ...]}
dcids = [e["candidates"][0]["dcid"]
for e in resolve_response.to_dict()["entities"]
if e.get("candidates")]
# or: resolve_response.to_flat_dict() -> {"California": "geoId/06", ...}
# (a list of DCIDs when the name is ambiguous)
Discover available variables (optional):
variables = client.observation.fetch_available_statistical_variables(
entity_dcids=dcids
)
Query statistical data:
response = client.observation.fetch(
variable_dcids=["Count_Person", "UnemploymentRate_Person"],
entity_dcids=dcids,
date="latest"
)
Process results:
# As dictionary
data = response.to_dict()
# As flat records (date, entity, variable, value + facet metadata).
# to_observation_records() returns a pydantic model — dump it before
# building a DataFrame, or the columns come out as 0..N.
records = response.to_observation_records().model_dump()
df = pd.DataFrame(records)
To skip the manual conversion, the client also exposes a dedicated DataFrame accessor that runs the same query and returns a tidy DataFrame directly:
df = client.observations_dataframe(
variable_dcids=["Count_Person"],
entity_dcids=["geoId/06", "geoId/48"],
date="all",
)
Statistical variables use specific naming patterns in Data Commons:
Common variable patterns:
Count_Person - Total populationCount_Person_Female - Female populationUnemploymentRate_Person - Unemployment rateMedian_Income_Household - Median household incomeCount_Death - Death countMedian_Age_Person - Median ageDiscovery methods:
# Check what variables are available for an entity
available = client.observation.fetch_available_statistical_variables(
entity_dcids=["geoId/06"]
)
# Or explore via the web interface
# https://datacommons.org/tools/statvar
The idiomatic path is the client's observations_dataframe() accessor, which mirrors
observation.fetch() arguments but returns a tidy DataFrame in one call (requires the
pandas extra):
df = client.observations_dataframe(
variable_dcids=["Count_Person"],
entity_dcids=["geoId/06", "geoId/48"],
date="all",
)
# Columns: date, entity, variable, value (plus facet/provenance columns)
# Reshape for analysis
pivot = df.pivot_table(
values='value',
index='date',
columns='entity'
)
For every entity of a type under a parent place, pass entity_dcids="all" with
entity_type and parent_entity:
df = client.observations_dataframe(
variable_dcids=["Median_Income_Household"],
date="latest",
entity_dcids="all",
entity_type="County",
parent_entity="geoId/06",
)
If you already have a response object, flatten it with to_observation_records()
(singular "observation"; there is no to_observations_as_records) and dump it:
response = client.observation.fetch(
variable_dcids=["Count_Person"],
entity_dcids=["geoId/06", "geoId/48"],
date="all",
)
df = pd.DataFrame(response.to_observation_records().model_dump())
For api.datacommons.org (the documented API):
UNAUTHENTICATED; name and
Wikidata resolution answer without one. Everything statistical is also served keyless
by the website API (see "Keyless Path")export DC_API_KEY="your_key" or DataCommonsClient(api_key="your_key")For custom Data Commons instances:
client = DataCommonsClient(url="https://custom.datacommons.org")Comprehensive documentation for each endpoint is available in the references/ directory:
references/observation.md: Complete Observation API documentation with all methods, parameters, response formats, and common use casesreferences/node.md: Complete Node API documentation for graph exploration, property queries, and hierarchy navigationreferences/resolve.md: Complete Resolve API documentation for entity identification and DCID resolutionreferences/getting_started.md: Quickstart guide with end-to-end examples and common patternsfetch_available_statistical_variables() to see what's queryablefilter_facet_domains to ensure data from the same sourcereferences/ directoryscripts/query_datacommons.py — keyless helper (standard library only): resolve
(names, --wikidata, --coords), observe, within, names, parents, children,
vars-search, has; --csv for tidy records; --backend api for the keyed v2 API.
Examples are under "Keyless Path".
What SKILL.md sets; muted values are Claude Code's defaults
Not loaded · from alterlab-writing-tools
Claude Code won't load this skill
It ships in alterlab-writing-tools at skills/, but Claude Code only loads skills/<name>/SKILL.md and folders listed under skills in plugin.json. Installing the plugin doesn't add it.
Generated from the plugin's indexed repository (alterlab-ieu/alterlab-academic-skills) — no native marketplace selected
npx claudepluginhub p/alterlab-ieu-alterlab-writing-tools241 skills in this plugin
/alterlab-abm-mesaBuilds agent-based models of social systems with Mesa 3 — the current AgentSet API (model.agents.shuffle_do('step'), auto-assigned unique_id, mandatory super().__init__(rng=...)), cell spaces (mesa.discrete_space OrthogonalMooreGrid / classic mesa.space grids), the DataCollector, batch_run parameter sweeps, and SolaraViz — for emergence, segregation, diffusion, opinion dynamics, and cooperation models. It uses the Mesa 3.x API (the old mesa.time schedulers like RandomActivation are removed) and treats the model as a generative theory to be validated, not just run. Use when the request mentions an agent-based model, Mesa, simulating interacting agents, or emergent macro behavior from micro rules. For discrete-event (queueing/process) simulation prefer alterlab-simpy; for reinforcement learning prefer alterlab-stable-baselines3. Part of the AlterLab Academic Skills suite./alterlab-academic-careerPrepares academic career documents and professional-development materials for faculty and researchers. Use when drafting academic CVs, research statements, teaching philosophies, diversity statements, faculty-position cover letters, tenure dossiers, promotion narratives, academic portfolios, or mentorship statements, and when planning conference-networking strategy, building academic web presence, setting up ORCID profiles, or understanding impact metrics. Part of the AlterLab Academic Skills suite.2 plugins in one repository ship this exact skill · first indexed Nov 9, 2026
Other plugins' skills for the same job