facebookfacebook-graph-apifacebook-workplace

Facebook Workplace Graph API, return unlimited


How do I return a set of results that is unlimited in size from Facebook Workplace's Graph API? It is limited by default to 25, but I can manually increase this by introducing the limit parameter.

https://graph.facebook.com/<company_id>/members?limit=500

I can obviously use a limit value way in excess of anything I'll need, but that just seems messy. Is there a way to prevent Facebook from limiting the number of results returned?


Solution

  • There is no option to get unlimited results, you can use paging to get all of them - with a recursive function, for example.

    Paging: https://developers.facebook.com/docs/graph-api/using-graph-api/#paging

    If you are using Node.js on your server, you can also use async/await, like in this example: Asynchronous method in while loop with Graph API paged