From a146c55af5d867c938d90db7ed7a13a9e7623ec5 Mon Sep 17 00:00:00 2001 From: Oussema Frikha Date: Mon, 5 Oct 2026 15:29:54 +0400 Subject: [PATCH] fix: get_group_metadata called a non-existent endpoint (v0.1.2) The API has no /facebook/groups/metadata route, so get_group_metadata() returned 404 on every call. It now calls /facebook/groups/details and returns the raw JSON, with a DeprecationWarning pointing to get_group_details(). Removal planned for 0.2.0. Bumps to 0.1.2 so PyPI also picks up the README fixes merged since 0.1.1. --- CHANGELOG.md | 19 +++++++++++++++++++ README.md | 1 - socialapis/_version.py | 2 +- socialapis/facebook/_client.py | 23 ++++++++++++++++++----- tests/test_facebook.py | 22 ++++++++++++++++++++++ 5 files changed, 60 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c2a3ea7..2ad789f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,25 @@ All notable changes to this project will be documented here. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.1.2] — 2026-10-05 + +### Fixed + +- **`Facebook.get_group_metadata` / `AsyncFacebook.get_group_metadata`** + called `/facebook/groups/metadata`, an endpoint the API doesn't have, so + every call returned 404. They now call `/facebook/groups/details` and + return its raw JSON. + +### Deprecated + +- `get_group_metadata()` — use `get_group_details()` (typed `GroupInfo`). + Emits `DeprecationWarning`; removed in 0.2.0. + +### Docs + +- README: JavaScript/TypeScript and Go SDKs are released (no longer + "coming soon"); MCP server linked; endpoint count corrected to 50. + ## [0.1.1] — 2026-06-22 ### Fixed (breaking for the typed-model methods) diff --git a/README.md b/README.md index bdb79c5..056e2b8 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,6 @@ calls. **Groups** - `get_group_id(group)` - `get_group_details(group)` → `GroupInfo` (typed model) -- `get_group_metadata(group)` — lightweight metadata only - `get_group_posts(group)` - `get_group_videos(group_id)` diff --git a/socialapis/_version.py b/socialapis/_version.py index 1cd93ce..881e249 100644 --- a/socialapis/_version.py +++ b/socialapis/_version.py @@ -4,4 +4,4 @@ # this manually for a release — use `git tag vX.Y.Z` and the CI does the # rest via hatchling's dynamic-version feature (see pyproject.toml). -__version__ = "0.1.1" +__version__ = "0.1.2" diff --git a/socialapis/facebook/_client.py b/socialapis/facebook/_client.py index 3a014e6..ff824ba 100644 --- a/socialapis/facebook/_client.py +++ b/socialapis/facebook/_client.py @@ -26,6 +26,7 @@ from __future__ import annotations +import warnings from types import TracebackType from typing import TYPE_CHECKING, Any @@ -247,13 +248,19 @@ def get_group_details(self, group: str, **kwargs: Any) -> GroupInfo: return GroupInfo.model_validate(response.json()) def get_group_metadata(self, group: str, **kwargs: Any) -> dict[str, Any]: - """Return lightweight Group metadata (name, id, url, image). + """Deprecated: use :meth:`get_group_details`. - Cheaper than ``get_group_details`` when you only need IDs/names. - Backed by ``GET /facebook/groups/metadata``. + The API has no ``/facebook/groups/metadata`` endpoint, so this method + returned 404 in 0.1.0–0.1.1. It now calls ``GET /facebook/groups/details`` + and returns the raw JSON. It will be removed in 0.2.0. """ + warnings.warn( + "get_group_metadata() is deprecated; use get_group_details().", + DeprecationWarning, + stacklevel=2, + ) return self._get( - "/facebook/groups/metadata", + "/facebook/groups/details", _params(("link", _as_facebook_group_url(group)), extra=kwargs), ).json() @@ -713,9 +720,15 @@ async def get_group_details(self, group: str, **kwargs: Any) -> GroupInfo: return GroupInfo.model_validate(response.json()) async def get_group_metadata(self, group: str, **kwargs: Any) -> dict[str, Any]: + """Deprecated: use :meth:`get_group_details`. See the sync client.""" + warnings.warn( + "get_group_metadata() is deprecated; use get_group_details().", + DeprecationWarning, + stacklevel=2, + ) return ( await self._get( - "/facebook/groups/metadata", + "/facebook/groups/details", _params(("link", _as_facebook_group_url(group)), extra=kwargs), ) ).json() diff --git a/tests/test_facebook.py b/tests/test_facebook.py index 1825cd0..efa641d 100644 --- a/tests/test_facebook.py +++ b/tests/test_facebook.py @@ -146,6 +146,28 @@ def test_get_group_id_routes_to_groups_id_endpoint() -> None: ) +@respx.mock +def test_get_group_metadata_is_deprecated_alias_for_group_details() -> None: + route = respx.get("https://api.socialapis.io/facebook/groups/details").mock( + return_value=httpx.Response(200, json={"group_id": "187988788687356"}) + ) + with Facebook(api_token="t") as fb, pytest.warns(DeprecationWarning, match="get_group_details"): + data = fb.get_group_metadata("gieldagryplanszowe") + assert route.called + assert data == {"group_id": "187988788687356"} + + +@respx.mock +async def test_async_get_group_metadata_routes_to_group_details() -> None: + route = respx.get("https://api.socialapis.io/facebook/groups/details").mock( + return_value=httpx.Response(200, json={"group_id": "187988788687356"}) + ) + async with AsyncFacebook(api_token="t") as fb: + with pytest.warns(DeprecationWarning, match="get_group_details"): + await fb.get_group_metadata("gieldagryplanszowe") + assert route.called + + @respx.mock def test_search_pages_passes_query_and_extra_kwargs() -> None: route = respx.get("https://api.socialapis.io/facebook/search/pages").mock(