Facebook Ads Library API - ad_reached_countries, ALL enum does not work

Facebook Ads Library API: ad_reached_countries Parameter Does Not Support ALL Enum!

Facebook Ads Library provides search for published ads on Meta platforms (Facebook, Instagram, Whatsapp). It also provides an API to programmatically search for ads that ran previously or are currently running.

ad_reached_countries and ALL enum option

The documentation states that ad_reached_countries is an array of enums. You can either provide a single country two letter ISO codes, or ISO codes of multiple countries in an array. If you want to retrieve ads for all countries, Facebook Ads Library API documentation states you can use ALL option.

However, during my test I have found out this is not the case and the ALL enum just does not work and no data is ever retrieved.

Workaround / fix for ALL in ad_reached_countries?

Just use all available ISO country codes like this:

['BR','IN','GB','US','CA','AR','AU','AT','BE','CL','CN','CO','HR','DK','DO','EG','FI','FR','DE','GR','HK','ID','IE','IL','IT','JP','JO','KW','LB','MY','MX','NL','NZ','NG','NO','PK','PA','PE','PH','PL','RU','SA','RS','SG','ZA','KR','ES','SE','CH','TW','TH','TR','AE','VE','PT','LU','BG','CZ','SI','IS','SK','LT','TT','BD','LK','KE','HU','MA','CY','JM','EC','RO','BO','GT','CR','QA','SV','HN','NI','PY','UY','PR','BA','PS','TN','BH','VN','GH','MU','UA','MT','BS','MV','OM','MK','LV','EE','IQ','DZ','AL','NP','MO','ME','SN','GE','BN','UG','GP','BB','AZ','TZ','LY','MQ','CM','BW','ET','KZ','NA','MG','NC','MD','FJ','BY','JE','GU','YE','ZM','IM','HT','KH','AW','PF','AF','BM','GY','AM','MW','AG','RW','GG','GM','FO','LC','KY','BJ','AD','GD','VI','BZ','VC','MN','MZ','ML','AO','GF','UZ','DJ','BF','MC','TG','GL','GA','GI','CD','KG','PG','BT','KN','SZ','LS','LA','LI','MP','SR','SC','VG','TC','DM','MR','AX','SM','SL','NE','CG','AI','YT','CV','GN','TM','BI','TJ','VU','SB','ER','WS','AS','FK','GQ','TO','KM','PW','FM','CF','SO','MH','VA','TD','KI','ST','TV','NR','RE','LR','ZW','CI','MM','AN','AQ','BQ','BV','IO','CX','CC','CK','CW','TF','GW','HM','XK','MS','NU','NF','PN','BL','SH','MF','PM','SX','GS','SS','SJ','TL','TK','UM','WF','EH']

This works well and finally you are able to retrieve any ads running in all countries!


Have a comment? Join discussion on Mastodon as a reply to: @dusoft@fosstodon.org