Skip to main content

Flexible Client for the 'Financial Modeling Prep' API

Project description

py-fmpapi

PyPI PyPI Downloads python-package.yml codecov.yml License: MIT

Provides a flexible Polars-based interface to the 'Financial Modeling Prep' API. The package supports all available endpoints and parameters, enabling Python users to interact with a wide range of financial data.

[!TIP] This package is developed by Christoph Scheuch and not sponsored by or affiliated with FMP. However, you can get 15% off your FMP subscription by using this affiliate link. By signing up through this link, you also support the development of this package at no extra cost to you.

For an R implementation, please consider the r-fmpapi package.

Installation

You can install the release version from PyPI:

pip install fmpapi

If you want to use the package with pandas, then install via:

pip install fmpapi[pandas]

You can install the development version from GitHub:

pip install "git+https://github.com/tidy-finance/py-fmpapi"

Setup

Before using the package, you need to set your Financial Modeling Prep API key. You can set it using the fmp_set_api_key() function, which saves the key to your .env file for future use (either in your project or home folder).

from fmpapi import fmp_set_api_key

fmp_set_api_key()

Usage

Since the FMP API has a myriad of endpoints and parameters, the package provides a single function to handle requests: fmp_get().

You can retrieve a company’s profile by providing its stock symbol to the profile endpoint:

from fmpapi import fmp_get

fmp_get(resource = "profile", symbol = "AAPL")

To retrieve the balance sheet statements for a company, use the balance-sheet-statement endpoint. You can specify whether to retrieve annual or quarterly data using the period parameter and the number of records via limit. Note that you need a paid account for quarterly data.

fmp_get(resource = "balance-sheet-statement", symbol = "AAPL", params = {"period": "annual", "limit": 5})

The income-statement endpoint allows you to retrieve income statements for a specific stock symbol.

fmp_get(resource = "income-statement", symbol = "AAPL")

You can fetch cash flow statements using the cash-flow-statement endpoint.

fmp_get(resource = "cash-flow-statement", symbol = "AAPL")

Most free endpoints live under API version 3, but you can also control the api version in fmp_get(), which you need for some paid endpoints. For instance, the symbol_change endpoint:

fmp_get(resource = "symbol_change", api_version = "v4")

If you want to get a pandas data frame instead of polars, you can use the to_pandas option (note that pandas and pyarrow must be installed):

fmp_get(resource = "cash-flow-statement", symbol = "AAPL", to_pandas = True)

Relation to Existing Libraries

There is an existing Python module that also provide an interface to the FMP API. However, the module lacks flexibility because it provides dedicated functions for specific endpoints, which means that users need to study both the FMP API docs and the package documentation and developers have to create new functions for each new endpoint.

Contributing

Feel free to open issues or submit pull requests to improve the package. Contributions are welcome!

License

This package is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fmpapi-1.0.0.tar.gz (22.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fmpapi-1.0.0-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file fmpapi-1.0.0.tar.gz.

File metadata

  • Download URL: fmpapi-1.0.0.tar.gz
  • Upload date:
  • Size: 22.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.10

File hashes

Hashes for fmpapi-1.0.0.tar.gz
Algorithm Hash digest
SHA256 07e6dd3de593a4c97078fbca9716a92c17980788c7a3f512a62e2b7bc549699b
MD5 fc9ede466248b3586073de2c35d6de75
BLAKE2b-256 15d57357e6ddeab60d00ef095d18f1a0e1a88d3440d21af8a4927063fdaabd1d

See more details on using hashes here.

File details

Details for the file fmpapi-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: fmpapi-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.10

File hashes

Hashes for fmpapi-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 502eeb949b4bc5e602a390ff073145657c1c5d7fb35363daaeed5ca459687c38
MD5 f2298e53131b41d25020660e85c6cda3
BLAKE2b-256 c9200d67af90105e0a3f2dea9cd63c7cf39bfaece2ece4d6313ef37d213dcea2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page