API.AI 访问 google BigQuery public 数据集

API.AI to access google BigQuery public datasets

我想在 Herokupython 上访问 google BigQuery public 数据集

例子 - 莎士比亚 https://bigquery.cloud.google.com/table/bigquery-public-data:samples.shakespeare

基本上在下面的例子中而不是雅虎天气api我想访问莎士比亚数据集

https://github.com/api-ai/apiai-weather-webhook-sample

我可以只使用我生成的 API_KEY 作为它的 public 数据集访问它吗?还是我需要 OAuth 身份验证?

https://support.google.com/cloud/answer/6158857?hl=en

根据上面的 link 我可以看到这个 "If you're calling only APIs that do not require user data, such as the Google Custom Search API, then API keys might be simpler to use than OAuth 2.0 access tokens."

我在 GAE 中尝试了很多变体,但遇到了项目 ID 变为空的问题,因此现在打算在 Heroku 中尝试,但想知道我是否只需要在 [=38] 中生成的 API_KEY =] 云控制台或者我需要 OAuth,因为他们需要将查询关联到项目以进行计费? 我已经在 Heroku 上实现了 yahoo weather api 示例并且可以正常工作,但需要将对 yahoo weather 的调用替换为对 BigQuery public 数据集的调用。

如果我对你的问题的理解正确,你想知道如何使用 Python 以编程方式访问 BigQuery public 数据集,更具体地说,如何进行身份验证。

您需要:

  1. 确保在控制台中启用了 BigQuery API。
  2. 在控制台中生成一个服务帐户。
  3. 下载 JSON 密钥。
  4. 导出环境 GOOGLE_APPLICATION_CREDENTIALS 变量以指向密钥。
  5. 使用 Google Python client lib 在 BigQuery 中查询数据。

更多信息here

注意:这与访问您自己的 datasets/tables.

的过程相同