10

I am looking to optimize my Facebook app.

Today I make a batch call with four graph API calls:

/me
/me/friends
/me/likes
/me/feed

If I change this to a single graph API call using field expansion like this:

/me?fields=id,name,username,friends,likes,feed

Will that now count as one hit against the API instead of four for rate limiting purposes?

ShawnDaGeek
  • 4,145
  • 1
  • 22
  • 39
Rich Sutton
  • 10,004
  • 1
  • 17
  • 21
  • Yes, it should, everything else would make little sense. – CBroe Jan 31 '13 at 13:31
  • 1
    I agree that this seems obvious, but the FB rate limiting is pretty opaque, so I'd just like to hear the FB folks validate the assumption. – Rich Sutton Jan 31 '13 at 13:33
  • Your second call *is* a single API call. You aren't using field expansion in it. – cpilko Feb 01 '13 at 01:30
  • Ah thx cpilko ... that's true even when the "fields" are connections (friends, likes, feed)? – Rich Sutton Feb 01 '13 at 19:02
  • @CBroe I do understand your answer, i thought exactly the same! However after some digging on the Facebook developers website I found out that each api call in the batch is counted, see answer below. – Kevin Vermaat May 27 '13 at 12:36

3 Answers3

3

Unfortunately, each call in the batch is counted as an api call, it's just faster to call them within a batch since it will be 1 request. See here documentation on Facebook API:

Limits
We currently limit the number of requests which can be in a batch to 50, but each call within the batch is counted separately for the purposes of calculating API call limits and resource limits. For example, a batch of 10 API calls will count as 10 calls and each call within the batch contributes to CPU resource limits in the same manner.

Source: https://developers.facebook.com/docs/reference/api/batch/

Kevin Vermaat
  • 311
  • 2
  • 4
  • 18
  • 1
    Facebook updated their official documentation in between the time that this question was asked and answered. Thanks Kevin! – Rich Sutton May 28 '13 at 16:11
  • 1
    @RichSutton Nps. Yeah I was thinking something like that :) – Kevin Vermaat May 28 '13 at 17:35
  • Field Expansion != Batch. A batch sends multiple-but-not-necessarily-related queries to Facebook in a single request. Field expansion is like doing a bunch of joins in SQL. It's only one call. – Galen Jul 31 '13 at 01:45
2

Based on real-world testing, I've found that field expansion can count for multiple uses under the rate limit. For example, starting from a quiet state, a sequence of 63 field-expanded calls to a single api (graph.facebook.com/IDENTITY/posts) brought us to the 600 call rate limit.

sethpollack
  • 1,348
  • 1
  • 12
  • 13
0

According to the Facebook Docs,

The Field Expansion feature of the Graph API, allows you to effectively "join" multiple graph queries into a single call.

So your queries above would represent four calls in the Batch form, and one call in the Field Expanded form.

As I noted in a comment above: A batch sends multiple-but-not-necessarily-related queries to Facebook in a single request. Field expansion is like doing joins in SQL through a single query.

Galen
  • 636
  • 6
  • 12