Not getting filtered ads from facebook ads api

Viewed 607

I am using facebook marketing api to retrieve fb ads. Using facebook graph api explorer I am trying to retrieve list of ads on the basis of ad-sets

https://graph.facebook.com/v10.0/adset_id/ads?fields=name,configured_status&configured_status=["ACTIVE"]

but it showing me all the ads(Active,Paused) instead of filtering(active only). Is there anything I am missing?

1 Answers

You should use the filtering params. Seems is not possible to filter for status or configured_status but you should use the effective_status instead.

...&filtering=[{ "field": "effective_status","operator": "IN","value": ["ACTIVE" ]}]

As example, for this adsets:

<adset-id>/ads?fields=id,status,effective_status

With the following data:

{
  "data": [
    {
      "id": "<ad-id>",
      "status": "ACTIVE",
      "effective_status": "ACTIVE"
    },
    {
      "id": "<ad-id>",
      "status": "PAUSED",
      "effective_status": "PAUSED"
    },
    {
      "id": "<ad-id>",
      "status": "PAUSED",
      "effective_status": "PAUSED"
    },
   .....
}

You can apply the filtering like:

<adset-id>/ads?fields=id,status,effective_status&filtering=[{ "field": "effective_status","operator": "IN","value": ["ACTIVE" ]}]

Will return:

{
  "data": [
    {
      "id": "<ad-id>",
      "status": "ACTIVE",
      "effective_status": "ACTIVE"
    }
  ],
  ....
}
Related