AppNexus API未返回的维度

时间:2015-06-05 18:45:54

标签: api rest

我试图设置与AppNexus reporting API的集成,遇到问题,并想知道StackOverflow社区中是否有人有分享的洞察力。

AppNexus API使用curl进行漫步,除了不返回组/尺寸外,它还可以进行排序。这就是我的所作所为:

有一个名为auth的文件,其中包含我们的凭据:

# JSON file containing our credentials
$ cat auth
{
    "auth": {
        "username" : "ourAppNexusApiUsername",
        "password" : "ourSecretApiUserPassword"
    }
}

还有一个包含查询的JSON文件。注意"列中的尺寸"列表:

# The query itself, in JSON format. 
$ cat query.json 
{
    "report": {
        "format": "csv",
        "report_interval": "yesterday",
        "groups": [
            "publisher_id",
            "imp_type",
            "geo_country",
            "placement_id"
        ],
        "columns": [
            "imps_total",
            "imps_kept",
            "imps_resold",
            "publisher_filled_revenue",
            "total_convs"
        ],
        "report_type": "publisher_analytics"
    }
}

我能够进行身份验证:

$ curl -b cookies -c cookies -X POST -d @auth 'https://api.appnexus.com/auth'

{"response":{"status":"OK","token":"hbapi:133820:5571c87753c27:nym2","dbg_info":{"instance":"56.bm-hbapi.prod.lax1","slave_hit":false,"db":"master","parent_dbg_info":{"instance":"63.bm-hbapi.prod.nym2","slave_hit":false,"db":"master","parent_dbg_info":{"instance":"38.bm-api.prod.nym2","slave_hit":false,"db":"master","time":482.32913017273,"version":"1.15.279","warnings":[],"slave_lag":0,"start_microtime":1433520246.311},"awesomesauce_cache_used":false,"count_cache_used":false,"warnings":[],"time":1078.0298709869,"start_microtime":1433520246.2796,"version":"1.15.527","slave_lag":0,"output_term":"not_found"},"awesomesauce_cache_used":false,"count_cache_used":false,"warnings":[],"time":1360.9290122986,"start_microtime":1433520246.1491,"version":"1.15.527","slave_lag":1,"output_term":"not_found","master_instance":"63.bm-hbapi.prod.nym2","proxy":true,"master_time":1078.0298709869}}}

我可以为特定的发布商申请报告。它返回report_id:72734c3a2df81522c7bae6684cfdd65c

$ curl -b cookies -c cookies -X POST -d @query.json 'http://api.appnexus.com/report?publisher_id=510332'

{"response":{"status":"OK","report_id":"72734c3a2df81522c7bae6684cfdd65c","existing":false,"cached":true,"dbg_info":{"instance":"58.bm-hbapi.prod.lax1","slave_hit":false,"db":"master","reads":0,"read_limit":100,"read_limit_seconds":60,"writes":1,"write_limit":60,"write_limit_seconds":60,"parent_dbg_info":{"instance":"61.bm-hbapi.prod.nym2","slave_hit":false,"db":"master","reads":0,"read_limit":100,"read_limit_seconds":60,"writes":1,"write_limit":60,"write_limit_seconds":60,"awesomesauce_cache_used":false,"count_cache_used":false,"warnings":[],"time":264.3940448761,"start_microtime":1433520268.8354,"version":"1.15.527","output_term":"not_found","reporting_dbg_info":{"instance":"11.bm-report-processor.prod.nym2","version":"1.72.130","time":1094.5529937744,"start_microtime":1433520268,"warnings":[],"api_cache_hit":"0","output_term":null}},"awesomesauce_cache_used":false,"count_cache_used":false,"warnings":[],"time":1238.8980388641,"start_microtime":1433520267.9206,"version":"1.15.527","output_term":"not_found","master_instance":"61.bm-hbapi.prod.nym2","proxy":true,"master_time":264.3940448761}}}

我能够下载报告,但遗憾的是,缺少报告组

$ curl -b cookies -c cookies 'http://api.appnexus.com/report-download?id=72734c3a2df81522c7bae6684cfdd65c'

imps_total,imps_kept,imps_resold,publisher_filled_revenue,total_convs
65086432,0,42898432,1234.776809,4

我想我不是第一个遇到这种情况的人。有人有什么想法/建议吗?

编辑:

我上传了quick & dirty Python script to a Github repo以便于测试。

此外,AppNexus通过电子邮件回复:

  

看起来您已经掌握了一些移动文档   报告,而不是我们的标准发布者分析报告。   你应该改变"组" to" row_per"像这样:"

{
    "report": {
        "format": "csv",
        "report_interval": "yesterday",
        "row_per": [
            "hour"
        ],
        "columns": [
            "imps_total"
        ],
        "report_type": "publisher_analytics"
    }
}

我试过这个,但它没有用。

2 个答案:

答案 0 :(得分:1)

AppNexus console(Appnexus' web-UI)使用相同的API来提供内容。

如果您能够通过生成报告来生成您正在寻找的输出,则可以通过点击“打开API查看器”来对API调用进行反向工程。在屏幕的底部。这将显示用于创建报告的API参数。

答案 1 :(得分:1)

AppNexus tech writer here (months later!). I'm pretty sure the example reporting API call on that page was wrong (and I've just fixed it – you can check it out here).

My understanding after testing the reporting API calls out is that:

  1. The "bad" example from the docs doesn't work (as you said – now fixed)
  2. You do get grouping behavior as long as you are grouping data (using "row_per") that you explicitly asked for (using "columns").

In other words, you must ask for data fields in "columns" and then group them (or more likely a subset) using "row_per". Here's the example I used in the updated docs:

{
    "report": {
        "report_type": "publisher_analytics",
        "report_interval": "yesterday",
        "columns": [
            "geo_country",
            "imp_type",
            "placement",
            "clicks",
            "total_convs",
            "publisher_revenue"
        ],
        "groups": [
            "geo_country",
            "imp_type",
            "placement",
        "imps_total"
        ],
        "name": "Publisher Analytics - 10/30/2015"
    }
}

I used quotes around "bad" above because I'm not sure if it's a bug in our API or the expected behavior - I'm trying to find that out with our engineering team now, but it's Friday afternoon, so I may have to check in again later.

In any case, I've updated the example on the page to reflect the actual behavior as tested for the time being.

Two more things:

  1. That page is for our regular publisher analytics report. It's not mobile-specific, we just published it there too so it'd be available externally for some of our customers' customers. Sorry for the confusion!

  2. According to my testing this afternoon, "row_per" and "groups" both work, and exhibit the same behavior.

I'm probably too late to help you out, but hopefully this is useful to someone!