From 0d08080ecbcec8436258841fc4f4817648fcc470 Mon Sep 17 00:00:00 2001 From: Oussema Frikha Date: Mon, 22 Jun 2026 23:34:13 +0100 Subject: [PATCH] docs: sync README + examples to v0.1.1 typed-model field names MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit v0.1.0's README and examples used the field names I'd guessed for the typed models. v0.1.1 (PR #6) rewrote the models with the real field names the API returns. The README + two example scripts still referenced the old names — anyone copy-pasting the code would get AttributeError. Field-name fixes (applied to README + examples/quickstart.py + examples/migrate-from-kevinzg.py): page.name → page.title page.likes → page.likes_count page.followers → page.followers_count page.about → page.bio page.verified → dropped (no equivalent in real API response) profile.followers → profile.followers_count profile.posts_count → profile.media_count profile.full_name and profile.is_verified were already correct. Verified locally: ruff check . → All checks passed! ruff format --check . → 17 files already formatted pytest → 33 passed, 80% coverage No code changes to the SDK — pure docs / example sync. --- README.md | 6 +++--- examples/migrate-from-kevinzg.py | 8 +++++--- examples/quickstart.py | 16 ++++++++++------ 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index d3592ca..0c33027 100644 --- a/README.md +++ b/README.md @@ -19,11 +19,11 @@ from socialapis import Facebook, Instagram fb = Facebook(api_token="...") page = fb.get_page_info("EngenSA") -print(page.name, page.likes, page.category) +print(page.title, page.followers_count, page.category) ig = Instagram(api_token="...") profile = ig.get_profile_details("instagram") -print(profile.username, profile.followers) +print(profile.username, profile.followers_count) ``` **[Get a free API token →](https://socialapis.io/auth/signup)** — 200 calls/month, no credit card @@ -244,7 +244,7 @@ async def main(): for slug in ["EngenSA", "Microsoft", "GitHub"] ]) for page in pages: - print(page.name, page.followers) + print(page.title, page.followers_count) asyncio.run(main()) ``` diff --git a/examples/migrate-from-kevinzg.py b/examples/migrate-from-kevinzg.py index 010ca2f..f854d5f 100644 --- a/examples/migrate-from-kevinzg.py +++ b/examples/migrate-from-kevinzg.py @@ -61,10 +61,12 @@ def main() -> None: "Out of credits. Upgrade at https://socialapis.io/pricing" ) from None - # Same fields kevinzg returned, but now typed (page.name not page["name"]) - print(f"Page: {page.name}") + # Same data kevinzg returned, but now typed (page.title not page["name"]). + # Field names match the API exactly — see PageInfo in the SDK docs. + print(f"Page: {page.title}") print(f" Category: {page.category}") - print(f" Likes: {page.likes:,}" if page.likes else " Likes: n/a") + print(f" Likes: {page.likes_count:,}" if page.likes_count else " Likes: n/a") + print(f" Followers:{page.followers_count:,}" if page.followers_count else "") # kevinzg's `for post in get_posts(...)` equivalent — paginate via cursors result = fb.get_page_posts("EngenSA") diff --git a/examples/quickstart.py b/examples/quickstart.py index bc2fdc2..24bd13f 100644 --- a/examples/quickstart.py +++ b/examples/quickstart.py @@ -44,11 +44,11 @@ def main() -> None: page = fb.get_page_info("EngenSA") except (RateLimitError, InsufficientCreditsError) as exc: raise SystemExit(f"Facebook call failed: {exc}") from exc - print(f"Facebook page: {page.name}") + print(f"Facebook page: {page.title}") print(f" Category: {page.category}") - print(f" Likes: {page.likes:,}" if page.likes else " Likes: n/a") - print(f" Followers: {page.followers:,}" if page.followers else " Followers: n/a") - print(f" Verified: {page.verified}") + print(f" Likes: {page.likes_count:,}" if page.likes_count else " Likes: n/a") + print(f" Followers: {page.followers_count:,}" if page.followers_count else " Followers: n/a") + print(f" Bio: {(page.bio or '')[:80]}") print() # Instagram @@ -59,8 +59,12 @@ def main() -> None: raise SystemExit(f"Instagram call failed: {exc}") from exc print(f"Instagram profile: @{profile.username}") print(f" Full name: {profile.full_name}") - print(f" Followers: {profile.followers:,}" if profile.followers else " Followers: n/a") - print(f" Posts: {profile.posts_count}") + print( + f" Followers: {profile.followers_count:,}" + if profile.followers_count + else " Followers: n/a" + ) + print(f" Media: {profile.media_count}") print(f" Verified: {profile.is_verified}")