Skip to main content

Facebook SDK (Python)

The official Python client for the GetSocialAPI Facebook API. A thin layer over the REST API: auth, automatic retries and typed exceptions — raw Facebook JSON in, raw JSON out. Every list method returns one page; walk cursors yourself (see the API Reference pages).

Endpoint semantics — parameters, response fields, limits and notes — live in the Facebook API Reference. This page covers only the library itself.

Source code: github.com/GetSocialAPI/Facebook-Scraper-API

Installation​

pip install git+https://github.com/GetSocialAPI/Facebook-Scraper-API.git

Requires Python 3.9+ and requests.

Client​

from getsocialapi_facebook import Client

client = Client(api_key="gsa_live_...")
ParameterDefaultDescription
api_keyenv GETSOCIALAPI_FB_API_KEYyour API key
base_urlFacebook API endpointoverride only for testing
timeout30per-request timeout, seconds
max_retries3retries on 429/500/502/503/504 and network errors

All endpoints hang off client.fb.* (alias client.facebook.*) — see the Facebook API Reference for what is available and what each call returns.

Pagination​

Every method returns one raw page as received. Pass the cursor from the previous response (next_max_id as max_id for Instagram, page_info.end_cursor as after for Facebook) until it is null / has_next_page is false.

Errors​

ExceptionHTTPNotes
GetSocialFacebookError—base class; also network errors
BadRequestError400bad parameters
APIKeyError401invalid key
RateLimitError429.limit from the response
UpstreamError502temporary upstream error — retried automatically
ServiceUnavailableError503service overloaded — retried automatically
from getsocialapi_facebook import RateLimitError

try:
client.fb.members(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.