如何在第三方 API 中发出请求并在 google BigQuery 上定期加载结果?我应该使用哪些 google 服务?

How to make requests in third party APIs and load the results periodically on google BigQuery? What google services should I use?

我需要从第三方 API 获取数据并将其提取到 google BigQuery 中。也许,我需要通过 google 服务自动执行此过程以定期执行此操作。

我正在尝试使用 Cloud Functions,但它需要一个触发器。我也读过关于 App Engine 的文章,但我认为它不适合只对一个函数进行拉取请求。

另一个疑问是:我需要将数据加载到云存储中还是可以直接将其加载到 BigQuery 中?我应该使用 Dataflow 并进行任何配置吗?

def upload_blob(bucket_name, request_url, destination_blob_name):
    """
    Uploads a file to the bucket.
    """
    storage_client = storage.Client()
    bucket = storage_client.get_bucket(bucket_name)
    blob = bucket.blob(destination_blob_name)

    request_json = requests.get(request_url['url'])

    print('File {} uploaded to {}.'.format(
        bucket_name,
        destination_blob_name))

def func_data(request_url):
    BUCKET_NAME = 'dataprep-staging'
    BLOB_NAME = 'any_name'
    BLOB_STR = '{"blob": "some json"}'

    upload_blob(BUCKET_NAME, request_url, BLOB_NAME)
    return f'Success!'

我希望获得有关我应该用于创建此管道的体系结构(google 服务)的建议。例如,使用云函数(从 API 获取数据),然后使用服务 'X' 调度作业将数据输入存储,最后从存储中拉取数据。

可以使用函数。创建一个 http triggered function and call it periodically with cloud scheduler.

对了,你也可以调用appengine或cloud的http端点运行。

关于存储,答案是否定的。如果 API 结果对于函数允许的内存来说不是太大,你 can write in /tmp directory and load data to bigquery with this file。如果需要,您可以将函数的大小设置为 2go