Mr Sarkisian
Mr Sarkisian

Reputation: 11

How to get all available field names in Facebook API (get_insights) method?

    def get_campaigns_insight(self, start_date, end_date, batch_size):
        params = {
            'time_range': {'since':start_date,'until':end_date},
            'filtering': [],
            'level': 'campaign',
            'breakdowns': ['country'],
            'limit': batch_size,
            'date_preset': 'lifetime',
        }

        fields = ['campaign_name', 'canvas_avg_view_percent']
       

        response = self.account.get_insights(
            fields=fields,
            params=params,
        )

        data = str(response)

Currently I am passing the field names in a list and throwing it into the parameters as an argument, this works and i can manually add the names from the documentation, but surely there should be a way to get all the fields available right?

Upvotes: 0

Views: 631

Answers (1)

andyrandy
andyrandy

Reputation: 74014

There is no way to get ALL fields, else a lot of users would use the oppertunity and use bandwith they do not really need - because you will most likely not need ALL fields. For all API calls, Facebook only returns a few default fields and additional fields you specify.

Upvotes: 2

Related Questions