How to get a list of campaign relevant countries



Hi all!

When I create a campaign, there is a “Select your audience (STEP 2 OF 4)” section in which I choose the relevant countries for my campaign.

Is there a way to retrieve this list of countries using the ads-api?



Hi @AlonDvirPlus500! You can search for all locations, not only countries, using (please note:


Thanks for stepping in, @majoritasdev!

@AlonDvirPlus500: To follow up on the previous post, you can do the following using the Ads API to get a list of countries:

$ twurl -H "/1/targeting_criteria/locations?location_type=COUNTRY" | jq .

Note that, by default, the data array returns 200 country objects. You can increase that using the count param or you can use the original next_cursor value with the cursor param in a subsequent request:

$ twurl -H "/1/targeting_criteria/locations?location_type=COUNTRY&cursor=xxxxx" | jq .

Please let us know if you need anything else. If not, I’ll close this. Thanks!


Hi @juanshishido and @majoritasdev,

Thanks for you reply. However, it doesn’t answer my question.
On campaign creation/edit GUI platform, There is a required field of LOCATION for the campaign.
Using that field, each one of my campaigns has a list of countries in which it runs.

I want to retrieve for each one of my campaigns the relevant list of countries, as defined above.
I don’t want to get a list of all the countries supported by Twitter.

I would have expected the “GET accounts/:account_id/campaigns” API to contain locations field. I would like to get that information, despite the fact that no such field exists.

how can I do this?

I hope my question is clearer now.
Thanks again!


Ahh! So you want to get the locations of existing campaigns. Well, for this you need to get the campaign’s line item and then get the line item’s targeting options using Among them there is / are some items with targeting_type = "LOCATION". That is what you’re looking for.

Also note that when you get campaigns created in Twitter Ads UI, those have only one line item per campaign. Multiple line items per campaign are only available through the Ads API.


Thanks for the clarification, @AlonDvirPlus500.

Below is an example of how to do what @majoritasdev described.

To get details for the campaigns associated with your account (this returns 200 results by default):

$ twurl -H "/1/accounts/XXXXX/campaigns" | jq .

Choose the campaign IDs you want to look up. Use the campaign_ids param and pass in a comma-separated list of IDs to get the line items associated with those campaigns (this returns a max of 1,000 per request):

$ twurl -H "/1/accounts/XXXXX/line_items?campaign_ids=aaaa,bbbb,cccc" | jq .

(Note: if you want the line items for every campaign, omit the campaign_ids param.)

Finally, you’ll want to get the targeting criteria associated with each line item. You’ll do this for each line item ID (you’ll have to write a loop).

$ twurl -H "/1/accounts/XXXXX/targeting_criteria?line_item_id=yyyy" | jq '.data | .[] | select(.location_type=="COUNTRY")'

Each line item can have multiple targeting criteria. Because we only want the country information, we use jq '.data | .[] | select(.location_type=="COUNTRY")'.

Hope this helps.