There is a issue doing so, I am not able to get the exact spend totals, Any help is greatly appreciated.
In the UI, Say I want to find the ad spends on 14th June. So I Input date start as 2022-06-14 and end date as 2022-06-14, the total spend it gave me was $215.93
When the same was done by API
https://ads-api.twitter.com/{{version}}/stats/accounts/{{ACC_ID}}/active_entities?end_time=2022-06-15T00:00:00Z&entity=CAMPAIGN&start_time=2022-06-14T00:00:00Z
(In the API I cannot specify the start date same as end date, so I specify from 2022-06-14T00:00:00Z to midnight 2022-06-15T00:00:00Z)
{ "request": { "params": { "account_id": "xxxxxxxxx", "entity": "CAMPAIGN", "start_time": "2022-06-14T00:00:00Z", "end_time": "2022-06-15T00:00:00Z" } }, "data": [ { "entity_id": "huiuj", "activity_start_time": "2022-06-13T12:35:31Z", "activity_end_time": "2022-06-14T23:59:25Z", "placements": [ "ALL_ON_TWITTER" ] }, { "entity_id": "hyac2", "activity_start_time": "2022-06-13T00:25:12Z", "activity_end_time": "2022-06-13T12:18:04Z", "placements": [ "ALL_ON_TWITTER" ] } ] }
https://ads-api.twitter.com/{{version}}/stats/jobs/accounts/{{ACC_ID}}?end_time=2022-06-15T00:00:00Z&entity=CAMPAIGN&entity_ids=hyac2,huiuj,hwbna&granularity=HOUR&metric_groups=BILLING&placement=ALL_ON_TWITTER&start_time=2022-06-14T00:00:00Z&country=96683cc9126741d1&segmentation_type=REGIONS
It is giving me a response as below, Which is totalled to 267.02392700 instead of $215.93
Where I am going wrong? I want to adapt my API request to get the total as 215.93 same like the UI report.
{"data_type":"stats","time_series_length":24,"data":[{"id":"huiuj","id_data":[{"segment":{"segment_name":"Delaware, US","segment_value":"3f5897b87d2bf56c"},"metrics":{"billed_engagements":[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0],"billed_charge_local_micro":[0,0,0,0,0,0,0,0,0,0,0,0,2900000,0,0,2500000,0,0,0,0,0,0,0,0]}},{"segment":{"segment_name":"California, US","segment_value":"fbd6d2f5a4e4a15e"},"metrics":{"billed_engagements":[0,0,0,0,0,0,0,0,0,0,1,1,0,2,2,0,1,0,0,0,0,0,0,1],"billed_charge_local_micro":[0,0,0,0,0,0,0,0,0,0,3200000,2900000,0,5800000,5400000,0,3000000,0,0,0,0,0,0,3000000]}},{"segment":{"segment_name":"Connecticut, US","segment_value":"e86b380cfefcced5"},"metrics":{"billed_engagements":[0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0],"billed_charge_local_micro":[0,0,0,0,0,0,0,0,0,0,3000000,0,0,3000000,0,0,0,0,0,0,0,0,0,0]}},{"segment":{"segment_name":"New Jersey, US","segment_value":"65b4760a2b411e11"},"metrics":{"billed_engagements":[0,0,0,0,1,0,0,0,0,0,0,0,1,2,2,0,1,0,0,0,0,1,0,0],"billed_charge_local_micro":[0,0,0,0,3000000,0,0,0,0,0,0,0,1900,6000000,5900000,0,3200000,0,0,0,0,3200000,0,0]}},{"segment":{"segment_name":"Pennsylvania, US","segment_value":"dd9c503d6c35364b"},"metrics":{"billed_engagements":[1,0,0,0,0,0,0,0,0,0,1,2,3,1,0,0,0,0,0,0,0,0,0,0],"billed_charge_local_micro":[3000000,0,0,0,0,0,0,0,0,0,2867094,4543568,9100000,3200000,0,0,0,0,0,0,0,0,0,0]}},{"segment":{"segment_name":"New York, US","segment_value":"94965b2c45386f87"},"metrics":{"billed_engagements":[1,0,0,0,0,0,0,0,0,1,1,3,3,3,1,0,0,0,0,1,0,0,0,0],"billed_charge_local_micro":[3200000,0,0,0,0,0,0,0,0,3000000,3000000,10751704,10637634,8400000,3000000,0,0,0,0,3200000,0,0,0,0]}},{"segment":{"segment_name":"Nevada, US","segment_value":"d374fb61a20fb74f"},"metrics":{"billed_engagements":[0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"billed_charge_local_micro":[0,0,0,0,0,3000000,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},{"segment":{"segment_name":"Texas, US","segment_value":"e0060cda70f5f341"},"metrics":{"billed_engagements":[1,0,0,0,2,0,0,0,0,0,4,1,1,2,1,0,0,1,0,0,0,1,0,0],"billed_charge_local_micro":[3000000,0,0,0,6400000,0,0,0,0,0,10330789,3200000,2900000,5900000,2900000,0,0,2900000,0,0,0,3000000,0,0]}},{"segment":{"segment_name":"Florida, US","segment_value":"4ec01c9dbc693497"},"metrics":{"billed_engagements":[0,0,0,0,0,0,0,0,0,1,1,2,2,5,0,0,0,1,0,0,0,0,0,0],"billed_charge_local_micro":[0,0,0,0,0,0,0,0,0,3200000,3000000,5900000,6400000,14800000,0,0,0,2900000,0,0,0,0,0,0]}},{"segment":{"segment_name":"Unknown","segment_value":"0000000000000000"},"metrics":{"billed_engagements":[1,0,0,0,1,0,0,0,0,1,2,3,4,5,2,0,1,0,0,1,0,0,0,0],"billed_charge_local_micro":[3200000,0,0,0,3000000,0,0,0,0,3000000,6000000,10751704,10639534,14400000,6000000,0,3200000,0,0,3200000,0,0,0,0]}}]},{"id":"hwbna","id_data":[]},{"id":"hyac2","id_data":[]}],"request":{"params":{"start_time":"2022-06-14T00:00:00Z","segmentation_type":"REGIONS","entity_ids":["hyac2","huiuj","hwbna"],"end_time":"2022-06-15T00:00:00Z","country":"-6997c336ed98be2f","placement":"ALL_ON_TWITTER","granularity":"HOUR","entity":"CAMPAIGN","platform":null,"metric_groups":["BILLING"]}}}