Skip to content

Latest commit

 

History

History
48 lines (32 loc) · 1.78 KB

index.md

File metadata and controls

48 lines (32 loc) · 1.78 KB
layout title nav_order parent has_children
default
Python
40
API
true

Data Commons Python API

The Data Commons Python API is a Python library that enables developers to programmatically access nodes in the Data Commons knowledge graph. This package allows users to explore the structure of the graph, integrate statistics from the graph into data analysis workflows and much more.

Note: The Python API only supports V1 of the REST APIs.

Before proceeding, make sure you have followed the setup instructions below.

Install the Python Data Commons API

This procedure uses a Python virtual environment as recommended by Google Cloud Setting up a Python development environment{: target="_blank"}.

  1. If not done already, install python3 and pip3. See Installing Python for procedures.
  2. Go to your project directory and create a virtual environment using venv, as described in Using venv to isolate dependencies{: target="_blank"}.
  3. Install the the datacommons package:
$ pip install datacommons

You are ready to go! You can view our tutorials on how to use the API to perform certain tasks using Google Colab{: target="_blank"}, or refer to pages in the navigation bar for detailed information about all the methods available.

Run Python interactively

The pages in this site demonstrate running Python methods interactively from the Bash shell. To use this facility, be sure to import the datacommons package:

From your virtual environment, run:

python3
>>> import datacommons
>>>