Default return in v0 and v1

v1
analytics

#1

I was comparing v1 metrics return with v0, and I noticed that v1 return default null while v0 return default [0], for example “billed_charge_local_micro”: [0] in v0, but “billed_charge_local_micro”: null in v1. Is this intended?

In documentation link below, it mentioned data type as “Array of ints”, does this also mean “Array of nullable ints”?

https://dev.twitter.com/ads/analytics/metrics-and-segmentation-in-analytics

//v1

tw -H ads-api.twitter.com “/1/stats/accounts/18ce53x6z98?entity=FUNDING_INSTRUMENT&entity_ids=iu4u7&start_time=2014-10-22T00:00:00Z&end_time=2014-10-29T00:00:00Z&granularity=TOTAL&metric_groups=ENGAGEMENT,BILLING&placement=ALL_ON_TWITTER”

//v0

twurl -H ads-api.twitter.com “/0/stats/accounts/18ce53x6z98/funding_instruments/iu4u7?start_time=2014-10-22T00:00:00Z&end_time=2014-10-29T00:00:00Z&granularity=TOTAL”

//v1

    {
        "data_type": "stats",
        "time_series_length": 1,
        "data": [{
            "id": "iu4u7",
            "id_data": [{
                "segment": null,
                "metrics": {
                    "impressions": null,
                    "billed_charge_local_micro": null,
                    "follows": null,
                    "retweets": null,
                    "likes": null,
                    "engagements": null,
                    "replies": null,
                    "billed_engagements": null
                }
            }]
        }],
        "request": {
            "params": {
                "start_time": "2014-10-22T00:00:00Z",
                "segmentation_type": null,
                "entity_ids": ["iu4u7"],
                "end_time": "2014-10-29T00:00:00Z",
                "country": null,
                "placement": "ALL_ON_TWITTER",
                "granularity": "TOTAL",
                "entity": "FUNDING_INSTRUMENT",
                "platform": null,
                "metric_groups": ["ENGAGEMENT",
                "BILLING"]
            }
        }
    }

//v0

{
        "data_type": "stats",
        "data": {
            "start_time": "2014-10-22T00:00:00Z",
            "promoted_tweet_timeline_card_engagements": [0],
            "promoted_account_follow_rate": [0.0],
            "promoted_tweet_search_url_clicks": [0],
            "promoted_tweet_search_clicks": [0],
            "promoted_tweet_search_engagement_rate": [0.0],
            "promoted_tweet_search_favorites": [0],
            "billed_charge_local_micro": [0],
            "promoted_tweet_search_retweets": [0],
            "promoted_tweet_timeline_favorites": [0],
            "promoted_tweet_app_open_attempts": [0],
            "promoted_tweet_search_card_engagements": [0],
            "promoted_account_impressions": [0],
            "end_time": "2014-10-29T00:00:00Z",
            "promoted_tweet_search_replies": [0],
            "promoted_tweet_search_follows": [0],
            "promoted_account_profile_visits": [0],
            "promoted_tweet_timeline_clicks": [0],
            "id": "iu4u7",
            "promoted_tweet_timeline_impressions": [0],
            "promoted_account_follows": [0],
            "promoted_tweet_timeline_url_clicks": [0],
            "promoted_tweet_timeline_engagement_rate": [0.0],
            "billed_follows": [0],
            "granularity": "TOTAL",
            "promoted_tweet_timeline_retweets": [0],
            "promoted_tweet_timeline_replies": [0],
            "promoted_tweet_app_install_attempts": [0],
            "billed_engagements": [0],
            "promoted_tweet_timeline_follows": [0],
            "promoted_tweet_search_engagements": [0],
            "promoted_tweet_timeline_engagements": [0],
            "promoted_tweet_search_impressions": [0]
        },
        "request": {
            "params": {
                "start_time": "2014-10-22T00:00:00Z",
                "end_time": "2014-10-29T00:00:00Z",
                "funding_instrument_id": "iu4u7",
                "account_id": "18ce53x6z98",
                "granularity": "TOTAL"
            }
        }
    }

#2

I can only speak from experience, but the whole JSON array object will now be null instead of full of zeroes when there are none of that metric. I can see why they changed to this method because before you could ask for like 20 days with hour breakdown and get back arrays of empty 0’s that were 20*24 ints long. This wasted lots of space in the response size.

So now if any of the values in the time range are not zero, then you will get an array with everything being zero or a number. Nothing in the array will be null. However if there are no stats at all in that time, then the entire array will not exists because it will be null.


#3

That’s exactly correct @guptamedia!


#4