【问题标题】:API call to Fathom Analytics via Postman通过 Postman 调用 Fathom Analytics 的 API
【发布时间】:2023-02-16 00:12:59
【问题描述】:

我正在尝试对 Fathom Analytics 进行 API 调用。但我无法弄清楚过滤选项(例如过滤特定路径名的报告)。有人可以帮我解决这个问题吗?

curl --location --request GET 'https://api.usefathom.com/v1/aggregations?entity=pageview&entity_id=[SITE_ID_HERE]&aggregates=visits, uniques, pageviews, avg_duration, bounce_rate' \
--header 'Authorization: Bearer [BEARER_TOKEN_HERE]' 

如何在此处插入 json-payload 以使用 Fathom Filter 选项 (https://usefathom.com/api#aggregation)

另外,我在 python 中重建了 api 调用,但没有成功。当我从 API 调用中删除有效负载时,它工作正常。

import requests

endpoint = "https://api.usefathom.com/v1/aggregations?entity=pageview&entity_id=[SITE_ID]&aggregates=pageviews,visits,uniques,avg_duration,bounce_rate&date_from=2022-10-01&date_to=2022-10-31"
payload = [{"property": "pathname",
        "operator": "is",
        "value": "/[URL TO FILTER]"}]
headers = {
    "Authorization": "[BEARER_TOKEN]"}

response=requests.get(endpoint, json=payload, headers=headers)

print(response.json())

【问题讨论】:

    标签: python


    【解决方案1】:

    我对此也有些挣扎,在我的例子中,当我在 JSON 有效负载本身而不是 curl 命令中包含“过滤器”键名称时,它起作用了。

    这是对我有用的:

    curl https://api.usefathom.com/v1/aggregations 
      -H "Authorization: Bearer [BEARER_TOKEN_HERE]" 
      -H "Accept: application/json" 
      -d entity="pageview" 
      -d entity_id="[SITE_ID_HERE]" 
      -d aggregates="pageviews" 
      -d "{'filters': [{'property':'country', 'operator':'is', 'value':'UK'}]}" 
      -G
    

    将 JSON 移动到它自己的文件 (payload.json) 并将该 curl 行更新为此也有效:

      -d @payload.json 
    

    【讨论】:

      猜你喜欢
      • 2020-05-20
      • 1970-01-01
      • 2021-02-11
      • 2017-06-30
      • 1970-01-01
      • 2017-01-14
      • 2021-09-21
      • 1970-01-01
      • 2021-01-23
      相关资源
      最近更新 更多