Skip to main content

kFinance

The kFinance Python library provides a simple interface for the LLM-ready API, streamlining API requests and response handling. It can be used on its own, with LLMs, or integrated into applications.

For a complete overview of the functions, usage, and features of the kFinance Python library, please refer to documentation here.

Any questions or suggestions can be sent to the kFinance Maintainers.

Setup

You can install kFinance on PyPI via

pip install kensho-kfinance

Getting started

To receive access, please email S&P Global Market Intelligence for information on free trials and pricing.

Once access is obtained, get started using the Authentication Guide and Usage Guide.

To get started, we provide some notebooks:

  • The LLM-ready API Basic Usage notebook demonstrates how fetch data with the kFinance client.
  • The tool_calling notebooks show how the kFinance library can be used for tool calling. We provide notebooks for OpenAI (GPT), Anthropic (Claude), and Google (Gemini). Each of these integrations comes in a langchain version, which uses langchain as a wrapper to simplify the integration, and as a lower level non-langchain version.

We also provide an interactive notebook that demonstrates some usage examples.

MCP (Model Context Protocol)

To run the kFinance MCP server use:

python -m kfinance.mcp

This function initializes and starts an MCP server that exposes the kFinance tools. The server supports multiple authentication methods and transport protocols to accommodate different deployment scenarios.

The server's full signature is as follows:

kfinance.mcp [--stdio|-s|--sse|--streamable-http] --refresh-token <refresh-token> --client-id <client-id> --private-key <private-key>

Authentication Methods (in order of precedence):

  1. Refresh Token: Uses an existing refresh token for authentication. The --refresh-token <refresh-token> argument must be provided.
  2. Key Pair: Uses client ID and private key for authentication. Both the --client-id <client-id> and --private-key <private-key> arguments must be provided.
  3. Browser: Falls back to browser-based authentication flow. This occurs if no auth arguments are provided.

Transport Layers:

  • --stdio / -s: Standard input/output transport (use with MCP Inspector)
  • --sse: Server-Sent Events transport (default)
  • --streamable-http: HTTP transport

Examples:

# Using stdio with MCP Inspector
npx @modelcontextprotocol/inspector python -m kfinance.mcp --stdio --refresh-token <token>

# Using SSE (default)
python -m kfinance.mcp --refresh-token <token>

# Using streamable-http
python -m kfinance.mcp --streamable-http --refresh-token <token>

MCP Proxy

The kFinance MCP proxy is a skeleton server that forwards requests to a remote kfinance MCP backend, injecting authentication tokens into every outgoing request. It is intended as a starting point for building a full production MCP proxy service.

# Using a refresh token (for experimentation)
AUTH_REFRESH_TOKEN=<token> python -m kfinance.proxy_mcp

# Using a key pair (for production)
AUTH_CLIENT_ID=<client-id> AUTH_PRIVATE_KEY=<private-key> python -m kfinance.proxy_mcp

The server starts on http://127.0.0.1:8000/mcp by default. Use --host and --port to configure binding.

For full documentation including configuration options, authentication methods, and production considerations, see kfinance/integrations/proxy_mcp/README.md.

Development

Working with Local Package Version

If you need to develop using a local version of the kFinance package in another project that uses poetry for package and dependency management, follow these steps:

  1. In your dependent project's pyproject.toml, replace the kFinance package version specification:

    # Replace this:
    # kensho-kfinance = "~2.0.1"
    # With this:
    kensho-kfinance = { path = "/absolute/path/to/kfinance", develop = true }
    

    The develop = true flag ensures that the package always matches your local version without requiring reinstallation after changes.

  2. Update your project's dependencies:

    poetry update    # Update poetry.lock with new changes
    poetry install   # Install dependencies with updated configuration
    

    If you encounter the error "your pyproject.toml file has significantly changed", run:

    poetry lock     # Sync the changes to poetry.lock
    

Versioning

The kFinance uses semantic versioning (major, minor, patch). To bump the version, add a new entry in CHANGELOG.md. This will generate a new version of the library as part of the release process.

License

Licensed under the Apache 2.0 License. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2025-present Kensho Technologies, LLC. The present date is determined by the timestamp of the most recent commit in the repository.

Release files for kensho-kfinance 8.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kensho-kfinance 8.0.0
File Size Uploaded
kensho_kfinance-8.0.0.tar.gz 474.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for kensho-kfinance 8.0.0
File Interpreter ABI Platform
kensho_kfinance-8.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 719.9 kB

Release files / kensho_kfinance-8.0.0.tar.gz

Download URL kensho_kfinance-8.0.0.tar.gz
Size 474.3 kB
Tags Source
SHA-256 checksum
How to use checksums
b036012630eebf6bd110740dba8a1729f71e1b6806017fcc5e67661a47ae3d7e
BLAKE2b-256 checksum
How to use checksums
2df07117e43a3babaffbb313e0183045f8f22bd886db50611c39693e9ae5ce9d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.

Transparency log

Release files / kensho_kfinance-8.0.0-py3-none-any.whl

Download URL kensho_kfinance-8.0.0-py3-none-any.whl
Size 245.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8705bba4689a4ecc0478fcdfb7980089223976328640c0b0980dc6f79d1ada1a
BLAKE2b-256 checksum
How to use checksums
ef777e44449f7f81afa32b8b92db2e361ae425b1a8b1726b12ecf290a9d78689
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

8.0.0 This release

2 release files

7.2.3

2 release files

7.2.2

2 release files

7.2.1

2 release files

7.2.0

2 release files

7.1.1

2 release files

7.1.0

2 release files

7.0.2

2 release files

7.0.1

2 release files

7.0.0

2 release files

6.7.0

2 release files

6.6.3

2 release files

6.6.2

2 release files

6.6.1

2 release files

6.6.0

2 release files

6.5.2

2 release files

6.5.1

2 release files

6.4.1

2 release files

6.3.0

2 release files

6.2.1

2 release files

6.2.0

2 release files

6.1.3

2 release files

6.1.2

2 release files

6.1.1

2 release files

6.1.0

2 release files

6.0.1

2 release files

6.0.0

2 release files

5.1.4

2 release files

5.1.3

2 release files

5.1.2

2 release files

5.1.1

2 release files

5.1.0

2 release files

5.0.0

2 release files

4.1.4

2 release files

4.1.3

2 release files

4.1.2

2 release files

4.1.1

2 release files

4.1.0

2 release files

4.0.0

2 release files

3.2.18

2 release files

3.2.17

2 release files

3.2.16

2 release files

3.2.15

2 release files

3.2.13

2 release files

3.2.12

2 release files

3.2.11

2 release files

3.2.10

2 release files

3.2.9

2 release files

3.2.8

2 release files

3.2.7

2 release files

3.2.6

2 release files

3.2.5

2 release files

3.2.4

2 release files

3.2.3

2 release files

3.2.2

2 release files

3.2.1

2 release files

3.2.0

2 release files

3.1.1

2 release files

3.1.0

2 release files

3.0.3

2 release files

3.0.2

2 release files

3.0.1

2 release files

3.0.0

2 release files

2.9.0

2 release files

2.8.0

2 release files

2.7.0

2 release files

2.6.5

2 release files

2.6.3

2 release files

2.6.2

2 release files

2.6.1

2 release files

2.4.3

2 release files

2.4.2

2 release files

2.4.1

2 release files

2.4.0

2 release files

2.3.0

2 release files

2.2.5

2 release files

2.2.4

2 release files

2.2.2

2 release files

2.1.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.2.2

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page