Export and read your carbon footprint using an API

Carbon Footprint does not have a dedicated public API. However, you can export your carbon footprint via the BigQuery Data Transfer Service API and then query the data using the BigQuery API.

Create an export via API

Use the BigQuery Data Transfer Service API to create a transfer, using the following payload:

{
  "dataSourceId": "61cede5a-0000-2440-ad42-883d24f8f7b8",
  "displayName": "NAME",
  "params": {
    "billing_accounts": "BILLING_ACCOUNT_IDS"
  },
  "destinationDatasetId": "DATASET",
  "schedule": "every day 00:00"
}

Replace:

  • NAME with your transfer config name, for example "Company Carbon Report"
  • BILLING_ACCOUNT_IDS with your billing account ID. This value can be a comma-separated list of billing account IDs. For example XXXXXX-XXXXXX-XXXXXX,XXXXXX-XXXXXX-XXXXXX
  • DATASET with the destination BigQuery dataset ID in the current project. For example, company_carbon_report

Query an existing export via API

Before querying the API, write a SQL query that returns the desired data from the exported dataset.

After you have configured an export to BigQuery, use the BigQuery API or BigQuery libraries to run the query as a Job.

What's next?