Facebook SDK
The official Python client for the GetSocialAPI Facebook Scraper API.
- Groups: resolve links, overview, members (paginated or all at once)
- Profiles: About/contacts with normalized fields
- Connections: followers, followings, friends
- Automatic retries on 429/502/503, typed exceptions
Source code: github.com/GetSocialAPI/Facebook-Scraper-API
Installation
pip install getsocialapi-facebook
Or from GitHub:
pip install git+https://github.com/GetSocialAPI/Facebook-Scraper-API.git
Client
from getsocialapi_facebook import Client
client = Client(api_key="gsa_live_...")
| Parameter | Default | Description |
|---|---|---|
api_key | env GETSOCIALAPI_FB_API_KEY | your API key |
base_url | Facebook API endpoint | override only for testing |
timeout | 30 | per-request timeout, seconds |
max_retries | 3 | retries on 429/502/503 and network errors |
Groups
# Resolve any group link (slug, m.facebook, share/g) to a group_id
group = client.fb.resolve("https://www.facebook.com/groups/freegarden/")
group_id = group["group_id"] # "800246542990860"
# Group card
client.fb.overview(group_id)
# Members: one raw GraphQL page (1st -> data.group, 2nd+ -> data.fetch__Group)
page = client.fb.members(group_id, first=15)
page["data"]["group"]["group_member_profiles"]["page_info"]["end_cursor"]
# All members, normalized, auto-paginated
members = client.fb.members_all(group_id, max_pages=10)
members["total"], members["members"][0]["name"]
Profile About
contacts = client.fb.contacts("100001797717646")
contacts["gender"], contacts["emails"], contacts["phones"]
# Raw GraphQL if you need the full sections
client.fb.contacts("100001797717646", raw=True)
Connections
followers = client.fb.followers("61595500131774")
followers["data"]["full_profile_list"]["list_items"]["edges"]
client.fb.followings("61595500131774")
client.fb.friends("61595500131774")
can_see_follower_list: false — the list is hidden by privacy settings: only the count is available.
Pagination
Pass page_info.end_cursor as after while has_next_page is true — or use the built-in generators:
for member in client.fb.iter_members(group_id):
print(member["name"])
for follower in client.fb.iter_followers("61595500131774"):
print(follower["id"], follower["name"])
Available: iter_members, iter_followers, iter_followings, iter_friends.
Errors
| Exception | HTTP | Notes |
|---|---|---|
GetSocialFacebookError | — | base class; also network errors |
BadRequestError | 400 | bad parameters |
APIKeyError | 401 | invalid key |
RateLimitError | 429 | .limit from the response |
UpstreamError | 502 | temporary upstream error — retried automatically |
ServiceUnavailableError | 503 | service overloaded — retried automatically |
from getsocialapi_facebook import RateLimitError
try:
client.fb.members_all(group_id)
except RateLimitError as e:
print("limit:", e.limit)
Validation
Client-side checks raise ValueError before any network call:
group_id/user_id — digits up to 20 chars, first — 1–100, max_pages — positive.