diff --git a/.release-please-manifest.json b/.release-please-manifest.json index e72f113..a780111 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "1.14.0" + ".": "1.14.1" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 90737f0..85fb813 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## 1.14.1 (2026-04-11) + +Full Changelog: [v1.14.0...v1.14.1](https://github.com/coingecko/coingecko-python/compare/v1.14.0...v1.14.1) + +### Bug Fixes + +* **client:** preserve hardcoded query params when merging with user params ([ffefe0c](https://github.com/coingecko/coingecko-python/commit/ffefe0c8418ab5f77790f3c21dbd78157879c629)) +* ensure file data are only sent as 1 parameter ([7b09afe](https://github.com/coingecko/coingecko-python/commit/7b09afe02609030c9da627e2f3475063652a254a)) + ## 1.14.0 (2026-03-27) Full Changelog: [v1.13.0...v1.14.0](https://github.com/coingecko/coingecko-python/compare/v1.13.0...v1.14.0) diff --git a/pyproject.toml b/pyproject.toml index 20740ee..c53d260 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "coingecko_sdk" -version = "1.14.0" +version = "1.14.1" description = "The official Python library for the coingecko API" dynamic = ["readme"] license = "Apache-2.0" diff --git a/src/coingecko_sdk/_base_client.py b/src/coingecko_sdk/_base_client.py index 7f93f2b..9f867c2 100644 --- a/src/coingecko_sdk/_base_client.py +++ b/src/coingecko_sdk/_base_client.py @@ -540,6 +540,10 @@ def _build_request( files = cast(HttpxRequestFiles, ForceMultipartDict()) prepared_url = self._prepare_url(options.url) + # preserve hard-coded query params from the url + if params and prepared_url.query: + params = {**dict(prepared_url.params.items()), **params} + prepared_url = prepared_url.copy_with(raw_path=prepared_url.raw_path.split(b"?", 1)[0]) if "_" in prepared_url.host: # work around https://github.com/encode/httpx/discussions/2880 kwargs["extensions"] = {"sni_hostname": prepared_url.host.replace("_", "-")} diff --git a/src/coingecko_sdk/_utils/_utils.py b/src/coingecko_sdk/_utils/_utils.py index eec7f4a..63b8cd6 100644 --- a/src/coingecko_sdk/_utils/_utils.py +++ b/src/coingecko_sdk/_utils/_utils.py @@ -86,8 +86,9 @@ def _extract_items( index += 1 if is_dict(obj): try: - # We are at the last entry in the path so we must remove the field - if (len(path)) == index: + # Remove the field if there are no more dict keys in the path, + # only "" traversal markers or end. + if all(p == "" for p in path[index:]): item = obj.pop(key) else: item = obj[key] diff --git a/src/coingecko_sdk/_version.py b/src/coingecko_sdk/_version.py index 4e910a9..f94297c 100644 --- a/src/coingecko_sdk/_version.py +++ b/src/coingecko_sdk/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "coingecko_sdk" -__version__ = "1.14.0" # x-release-please-version +__version__ = "1.14.1" # x-release-please-version diff --git a/tests/test_client.py b/tests/test_client.py index 2a5c5cc..328f8f8 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -447,6 +447,30 @@ def test_default_query_option(self) -> None: client.close() + def test_hardcoded_query_params_in_url(self, client: Coingecko) -> None: + request = client._build_request(FinalRequestOptions(method="get", url="/foo?beta=true")) + url = httpx.URL(request.url) + assert dict(url.params) == {"beta": "true"} + + request = client._build_request( + FinalRequestOptions( + method="get", + url="/foo?beta=true", + params={"limit": "10", "page": "abc"}, + ) + ) + url = httpx.URL(request.url) + assert dict(url.params) == {"beta": "true", "limit": "10", "page": "abc"} + + request = client._build_request( + FinalRequestOptions( + method="get", + url="/files/a%2Fb?beta=true", + params={"limit": "10"}, + ) + ) + assert request.url.raw_path == b"/files/a%2Fb?beta=true&limit=10" + def test_request_extra_json(self, client: Coingecko) -> None: request = client._build_request( FinalRequestOptions( @@ -1385,6 +1409,30 @@ async def test_default_query_option(self) -> None: await client.close() + async def test_hardcoded_query_params_in_url(self, async_client: AsyncCoingecko) -> None: + request = async_client._build_request(FinalRequestOptions(method="get", url="/foo?beta=true")) + url = httpx.URL(request.url) + assert dict(url.params) == {"beta": "true"} + + request = async_client._build_request( + FinalRequestOptions( + method="get", + url="/foo?beta=true", + params={"limit": "10", "page": "abc"}, + ) + ) + url = httpx.URL(request.url) + assert dict(url.params) == {"beta": "true", "limit": "10", "page": "abc"} + + request = async_client._build_request( + FinalRequestOptions( + method="get", + url="/files/a%2Fb?beta=true", + params={"limit": "10"}, + ) + ) + assert request.url.raw_path == b"/files/a%2Fb?beta=true&limit=10" + def test_request_extra_json(self, client: Coingecko) -> None: request = client._build_request( FinalRequestOptions( diff --git a/tests/test_extract_files.py b/tests/test_extract_files.py index e306f47..5a3b056 100644 --- a/tests/test_extract_files.py +++ b/tests/test_extract_files.py @@ -35,6 +35,15 @@ def test_multiple_files() -> None: assert query == {"documents": [{}, {}]} +def test_top_level_file_array() -> None: + query = {"files": [b"file one", b"file two"], "title": "hello"} + assert extract_files(query, paths=[["files", ""]]) == [ + ("files[]", b"file one"), + ("files[]", b"file two"), + ] + assert query == {"title": "hello"} + + @pytest.mark.parametrize( "query,paths,expected", [