Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
- name: Get GitHub OIDC Token
if: github.repository == 'stainless-sdks/finch-python'
id: github-oidc
uses: actions/github-script@v6
uses: actions/github-script@v8
with:
script: core.setOutput('github_token', await core.getIDToken());

Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "1.44.1"
".": "1.45.0"
}
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 46
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-46f433f34d440aa1dfcc48cc8d822c598571b68be2f723ec99e1b4fba6c13b1e.yml
openapi_spec_hash: 5b5cd728776723ac773900f7e8a32c05
config_hash: 0892e2e0eeb0343a022afa62e9080dd1
config_hash: ccdf6a5b4aaa2a0897c89ac8685d8eb0
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
# Changelog

## 1.45.0 (2026-02-12)

Full Changelog: [v1.44.1...v1.45.0](https://github.com/Finch-API/finch-api-python/compare/v1.44.1...v1.45.0)

### Features

* **api:** add per endpoint security ([686b27e](https://github.com/Finch-API/finch-api-python/commit/686b27e6d19cc5858b420e2b1bb265f50791c7ea))
* **client:** add custom JSON encoder for extended type support ([02cb5a0](https://github.com/Finch-API/finch-api-python/commit/02cb5a0bdcdbd8b4652937928ca7d0b336f6c53c))


### Bug Fixes

* **docs:** fix mcp installation instructions for remote servers ([298ddec](https://github.com/Finch-API/finch-api-python/commit/298ddec8fded9a72146800253d644cb96227cbde))
* **tests:** skip broken date validation test ([e22eb0f](https://github.com/Finch-API/finch-api-python/commit/e22eb0ffed3e42143600c931f2ab5b342160230c))


### Chores

* **ci:** upgrade `actions/github-script` ([f342729](https://github.com/Finch-API/finch-api-python/commit/f3427295a99f7aa4a45412f699ec6b3cc41b16c2))
* format all `api.md` files ([8555964](https://github.com/Finch-API/finch-api-python/commit/8555964275d168e400ef190422baee5a1983eeb1))
* **internal:** bump dependencies ([0b67a64](https://github.com/Finch-API/finch-api-python/commit/0b67a64b36f6824c1000d126e5ed707e495c3c59))
* **internal:** codegen related update ([b746d12](https://github.com/Finch-API/finch-api-python/commit/b746d12f98b1fcb287bf1b7844fc8a2d864a7d86))
* **internal:** fix lint error on Python 3.14 ([b0f5ba3](https://github.com/Finch-API/finch-api-python/commit/b0f5ba3c117a989524c31e6c62ab9215f98fccd2))

## 1.44.1 (2026-01-16)

Full Changelog: [v1.44.0...v1.44.1](https://github.com/Finch-API/finch-api-python/compare/v1.44.0...v1.44.1)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ It is generated with [Stainless](https://www.stainless.com/).

Use the Finch MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.

[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40tryfinch%2Ffinch-api-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkB0cnlmaW5jaC9maW5jaC1hcGktbWNwIl19)
[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40tryfinch%2Ffinch-api-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40tryfinch%2Ffinch-api-mcp%22%5D%7D)
[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40tryfinch%2Ffinch-api-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkB0cnlmaW5jaC9maW5jaC1hcGktbWNwIl0sImVudiI6eyJGSU5DSF9BQ0NFU1NfVE9LRU4iOiJNeSBBY2Nlc3MgVG9rZW4iLCJGSU5DSF9DTElF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3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40tryfinch%2Ffinch-api-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40tryfinch%2Ffinch-api-mcp%22%5D%2C%22env%22%3A%7B%22FINCH_ACCESS_TOKEN%22%3A%22My%20Access%20Token%22%2C%22FINCH_CLIENT_ID%22%3A%224ab15e51-11ad-49f4-acae-f343b7794375%22%2C%22FINCH_CLIENT_SECRET%22%3A%22My%20Client%20Secret%22%2C%22FINCH_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)

> Note: You may need to set environment variables in your MCP client.

Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "finch-api"
version = "1.44.1"
version = "1.45.0"
description = "The official Python library for the Finch API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand Down Expand Up @@ -69,7 +69,7 @@ format = { chain = [
# run formatting again to fix any inconsistencies when imports are stripped
"format:ruff",
]}
"format:docs" = "python scripts/utils/ruffen-docs.py README.md api.md"
"format:docs" = "bash -c 'python scripts/utils/ruffen-docs.py README.md $(find . -type f -name api.md)'"
"format:ruff" = "ruff format"

"lint" = { chain = [
Expand Down
20 changes: 10 additions & 10 deletions requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
-e file:.
aiohappyeyeballs==2.6.1
# via aiohttp
aiohttp==3.13.2
aiohttp==3.13.3
# via finch-api
# via httpx-aiohttp
aiosignal==1.4.0
# via aiohttp
annotated-types==0.7.0
# via pydantic
anyio==4.12.0
anyio==4.12.1
# via finch-api
# via httpx
argcomplete==3.6.3
Expand All @@ -31,7 +31,7 @@ attrs==25.4.0
# via nox
backports-asyncio-runner==1.2.0
# via pytest-asyncio
certifi==2025.11.12
certifi==2026.1.4
# via httpcore
# via httpx
colorlog==6.10.1
Expand Down Expand Up @@ -61,15 +61,15 @@ httpx==0.28.1
# via finch-api
# via httpx-aiohttp
# via respx
httpx-aiohttp==0.1.9
httpx-aiohttp==0.1.12
# via finch-api
humanize==4.13.0
# via nox
idna==3.11
# via anyio
# via httpx
# via yarl
importlib-metadata==8.7.0
importlib-metadata==8.7.1
iniconfig==2.1.0
# via pytest
markdown-it-py==3.0.0
Expand All @@ -82,14 +82,14 @@ multidict==6.7.0
mypy==1.17.0
mypy-extensions==1.1.0
# via mypy
nodeenv==1.9.1
nodeenv==1.10.0
# via pyright
nox==2025.11.12
packaging==25.0
# via dependency-groups
# via nox
# via pytest
pathspec==0.12.1
pathspec==1.0.3
# via mypy
platformdirs==4.4.0
# via virtualenv
Expand All @@ -115,13 +115,13 @@ python-dateutil==2.9.0.post0
# via time-machine
respx==0.22.0
rich==14.2.0
ruff==0.14.7
ruff==0.14.13
six==1.17.0
# via python-dateutil
sniffio==1.3.1
# via finch-api
time-machine==2.19.0
tomli==2.3.0
tomli==2.4.0
# via dependency-groups
# via mypy
# via nox
Expand All @@ -141,7 +141,7 @@ typing-extensions==4.15.0
# via virtualenv
typing-inspection==0.4.2
# via pydantic
virtualenv==20.35.4
virtualenv==20.36.1
# via nox
yarl==1.22.0
# via aiohttp
Expand Down
8 changes: 4 additions & 4 deletions requirements.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@
-e file:.
aiohappyeyeballs==2.6.1
# via aiohttp
aiohttp==3.13.2
aiohttp==3.13.3
# via finch-api
# via httpx-aiohttp
aiosignal==1.4.0
# via aiohttp
annotated-types==0.7.0
# via pydantic
anyio==4.12.0
anyio==4.12.1
# via finch-api
# via httpx
async-timeout==5.0.1
# via aiohttp
attrs==25.4.0
# via aiohttp
certifi==2025.11.12
certifi==2026.1.4
# via httpcore
# via httpx
distro==1.9.0
Expand All @@ -43,7 +43,7 @@ httpcore==1.0.9
httpx==0.28.1
# via finch-api
# via httpx-aiohttp
httpx-aiohttp==0.1.9
httpx-aiohttp==0.1.12
# via finch-api
idna==3.11
# via anyio
Expand Down
7 changes: 5 additions & 2 deletions src/finch/_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
APIConnectionError,
APIResponseValidationError,
)
from ._utils._json import openapi_dumps
from ._legacy_response import LegacyAPIResponse

log: logging.Logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -555,8 +556,10 @@ def _build_request(
kwargs["content"] = options.content
elif isinstance(json_data, bytes):
kwargs["content"] = json_data
else:
kwargs["json"] = json_data if is_given(json_data) else None
elif not files:
# Don't set content when JSON is sent as multipart/form-data,
# since httpx's content param overrides other body arguments
kwargs["content"] = openapi_dumps(json_data) if is_given(json_data) and json_data is not None else None
kwargs["files"] = files
else:
headers.pop("Content-Type", None)
Expand Down
6 changes: 3 additions & 3 deletions src/finch/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ def model_dump(
exclude_defaults: bool = False,
warnings: bool = True,
mode: Literal["json", "python"] = "python",
by_alias: bool | None = None,
) -> dict[str, Any]:
if (not PYDANTIC_V1) or hasattr(model, "model_dump"):
return model.model_dump(
Expand All @@ -148,13 +149,12 @@ def model_dump(
exclude_defaults=exclude_defaults,
# warnings are not supported in Pydantic v1
warnings=True if PYDANTIC_V1 else warnings,
by_alias=by_alias,
)
return cast(
"dict[str, Any]",
model.dict( # pyright: ignore[reportDeprecated, reportUnnecessaryCast]
exclude=exclude,
exclude_unset=exclude_unset,
exclude_defaults=exclude_defaults,
exclude=exclude, exclude_unset=exclude_unset, exclude_defaults=exclude_defaults, by_alias=bool(by_alias)
),
)

Expand Down
2 changes: 1 addition & 1 deletion src/finch/_utils/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def is_union(tp: Optional[Type[Any]]) -> bool:
else:
import types

return tp is Union or tp is types.UnionType
return tp is Union or tp is types.UnionType # type: ignore[comparison-overlap]


def is_typeddict(tp: Type[Any]) -> bool:
Expand Down
35 changes: 35 additions & 0 deletions src/finch/_utils/_json.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import json
from typing import Any
from datetime import datetime
from typing_extensions import override

import pydantic

from .._compat import model_dump


def openapi_dumps(obj: Any) -> bytes:
"""
Serialize an object to UTF-8 encoded JSON bytes.
Extends the standard json.dumps with support for additional types
commonly used in the SDK, such as `datetime`, `pydantic.BaseModel`, etc.
"""
return json.dumps(
obj,
cls=_CustomEncoder,
# Uses the same defaults as httpx's JSON serialization
ensure_ascii=False,
separators=(",", ":"),
allow_nan=False,
).encode()


class _CustomEncoder(json.JSONEncoder):
@override
def default(self, o: Any) -> Any:
if isinstance(o, datetime):
return o.isoformat()
if isinstance(o, pydantic.BaseModel):
return model_dump(o, exclude_unset=True, mode="json", by_alias=True)
return super().default(o)
2 changes: 1 addition & 1 deletion src/finch/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

__title__ = "finch"
__version__ = "1.44.1" # x-release-please-version
__version__ = "1.45.0" # x-release-please-version
4 changes: 4 additions & 0 deletions src/finch/resources/access_tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ def create(

timeout: Override the client-level default timeout for this request, in seconds
"""
extra_headers = {"Authorization": omit, **(extra_headers or {})}

if not is_given(client_id):
if self._client.client_id is None:
raise ValueError(
Expand Down Expand Up @@ -157,6 +159,8 @@ async def create(

timeout: Override the client-level default timeout for this request, in seconds
"""
extra_headers = {"Authorization": omit, **(extra_headers or {})}

if not is_given(client_id):
if self._client.client_id is None:
raise ValueError(
Expand Down
4 changes: 4 additions & 0 deletions src/finch/resources/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def disconnect(
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> DisconnectResponse:
"""Disconnect one or more `access_token`s from your application."""
extra_headers = {**self._client._bearer_auth, **(extra_headers or {})}
return self._post(
"/disconnect",
options=make_request_options(
Expand All @@ -66,6 +67,7 @@ def introspect(
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> Introspection:
"""Read account information associated with an `access_token`"""
extra_headers = {**self._client._bearer_auth, **(extra_headers or {})}
return self._get(
"/introspect",
options=make_request_options(
Expand Down Expand Up @@ -106,6 +108,7 @@ async def disconnect(
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> DisconnectResponse:
"""Disconnect one or more `access_token`s from your application."""
extra_headers = {**self._client._bearer_auth, **(extra_headers or {})}
return await self._post(
"/disconnect",
options=make_request_options(
Expand All @@ -125,6 +128,7 @@ async def introspect(
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> Introspection:
"""Read account information associated with an `access_token`"""
extra_headers = {**self._client._bearer_auth, **(extra_headers or {})}
return await self._get(
"/introspect",
options=make_request_options(
Expand Down
4 changes: 4 additions & 0 deletions src/finch/resources/connect/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ def new(

timeout: Override the client-level default timeout for this request, in seconds
"""
extra_headers = {**self._client._basic_auth, **(extra_headers or {})}
return self._post(
"/connect/sessions",
body=maybe_transform(
Expand Down Expand Up @@ -177,6 +178,7 @@ def reauthenticate(

timeout: Override the client-level default timeout for this request, in seconds
"""
extra_headers = {**self._client._basic_auth, **(extra_headers or {})}
return self._post(
"/connect/sessions/reauthenticate",
body=maybe_transform(
Expand Down Expand Up @@ -278,6 +280,7 @@ async def new(

timeout: Override the client-level default timeout for this request, in seconds
"""
extra_headers = {**self._client._basic_auth, **(extra_headers or {})}
return await self._post(
"/connect/sessions",
body=await async_maybe_transform(
Expand Down Expand Up @@ -351,6 +354,7 @@ async def reauthenticate(

timeout: Override the client-level default timeout for this request, in seconds
"""
extra_headers = {**self._client._basic_auth, **(extra_headers or {})}
return await self._post(
"/connect/sessions/reauthenticate",
body=await async_maybe_transform(
Expand Down
Loading
Loading