Get ads line items doesnt return the true total_count value correctly


#1

twurl -H ads-api.twitter.com /1/accounts/xxx/campaigns

data_type":“campaign”,“total_count”:49195,“next_cursor”:“8t5pqwfeo”

twurl -H ads-api.twitter.com /1/accounts/xxx/line_items

“data_type”:“line_item”,“total_count”:200,“next_cursor”:“8yep593pc”

I know we have really lot of line item, and by the amount of campaign assuming 1 to 1 relationship between campaign count and line item count, at least it should be 49195, but in reality it is hundred of thousands…

I think the api is not returning correct value


#2

Hi,

I checked the backend and there are actually about 97,000 line items for this account…which is on the high end.

I would hope you are able to use campaign_ids parameter to scope the line items result and that this doesn’t actually block anything with your implementation. Please let us know if that is not the case.

Thanks,

John


#3

Line item limit is by ad account right, this is why we need to know the total line item per ad account (eg. 18ce53ymmtp) for us to do better control of our logic.

I’m assuming there is plan underway to get this fixed, any idea when it will be out?

I think getting every line item per campaign will eventually cost us the rate limit issue, I would not prefer to go that way. Plus, I think it will be slow too…


#4

Definitely not all of those line items are being used at any moment of time, so it’s more important that you keep track of potentially active line items. You should be able to retrieve the list of campaign IDs, then use those to retrieve each set of line items that map to those campaign IDs individually.

We would not recommend to sync all of those 10s of thousands of line items every day because it would definitely be redundant work, at least you should sort by updated_at or created_at and take only the ones that have changed or newly created.


#5

Do you mean that the line items can be get using the campaign’s id?
AFAIK, the API does not provide the endpoint to get line_items using the campaign’s id (at least in the ads API Reference). How can I get the line_items using campaign’s id?

Thank you


#6

Yes this endpoint:
https://dev.twitter.com/ads/reference/get/accounts/account_id/line_items

Should be able to take a campaign_ids parameter to scope the line items returned (makes most sense 1 campaign at a time), generally we expect partners to store entity information in a database so that you don’t need to keep calling the complete list of entities in an interactive UI.

You should be able to do something like:

twurl -H ads-api.twitter.com '/1/accounts/18ce53ymmtp/line_items/?campaign_ids=7icew'

To test this out!


#7

I understand that I can get line item count by campaignid by adding up the line items for each campaign…

We are getting the campaign count from below campaigns endpoint, we should be able to do the same for line_items.

Our side are all familiar with the rate limit issue, so we dont want to retrieve all campaign for this ad account, then iteratively get line item for each campaign, be it only ACTIVE ones. I understand that this is another solution (though will definitely hit rate limit issue later on, but also relatively slow), but total_count for line_items should return the correct value, right? It is far easier and also will save the server from getting so many get line_items call, and having to process them.

Last thing I want is to hit rate limit on both get campaigns and get line_items. It will be a blocker.

I’m hoping effort is underway to fix this… if so, do we have an idea when it will be available?

twurl -H ads-api.twitter.com /1/accounts/xxx/campaigns

data_type":“campaign”,“total_count”:49195,“next_cursor”:“8t5pqwfeo”


#8

The issue will be tracked but I cannot guarantee a turnaround time since it’s not reproing for other accounts and from our perspective there is a valid workaround. We generally in the past have strongly recommended to not hit the index endpoints (the endpoints which can return a huge total count) without applying one of the filter parameters, because it’s actually more strenuous on our backend as well to fetch and count the complete set of data.

There’s not an easy way to filter to just active line items, the main trick is to sort by created or update fields OR to completely maintain the database info on your end and handle it with querying. You should then not have to hit campaign or line items other than syncing data periodically with your server/database and you should be able to sync only items that have chance of being changed (serving/active and not expired).


#9

Hey @aminmonster703 sorry for not following up here as soon as it was fixed but this issue was actually fixed a couple weeks ago. Please post a new thread if you see any other problems!