2

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?

Matteo
  • 37,680
  • 11
  • 100
  • 115
md samual
  • 305
  • 3
  • 15

1 Answers1

1

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"
    }
  ],
  ....
}
Matteo
  • 37,680
  • 11
  • 100
  • 115
  • Since I have active, paused and deleted ads in facebook marketing. But the url you provided responding empty data for active and paused status. But for deleted ads it is displaying data using archived status. – md samual Mar 18 '21 at 10:19
  • 1
    @mdsamual Well, `effective_status` does not necessarily equal `configured_status`. For example, if your campaign itself is paused, the effective status of your underlying ads is going to be `CAMPAIGN_PAUSED`, regardless of whether they're active or paused themselves. It's strange that Facebook doesn't allow filtering by configured status (or just status, for that matter), but that is the harsh reality. Facebook's gonna be Facebook... – Riwen Mar 22 '21 at 14:26