Skip to main content

A Stab at maintaining a Utility wrapper for the Financial Modeling Prep API. Uses the 'Stable' API. This is a cloned branch of fmp-stable-api

Project description

Important Note

This is a clone of fmp-stable that is lightly modified for a personal project. It's reorganized for use with uv as a package / project manager. This should (eventually) work... but you'll probably want to access the real source.

FMP Client Library

A Python client library for the Financial Modeling Prep (FMP) API. This library provides both synchronous REST API and asynchronous WebSocket support, all in a modular, easy-to-use package.

The client is built to work with the Stable version of the Financial Modeling Prep (FMP) API. All endpoints are configured to use the stable base URL:

https://financialmodelingprep.com/stable/

The endpoints available in this stable version are defined in the fmpstab_endpoints.json file

Features

  • Unified API Client:
    Dynamically access FMP endpoints using Pythonic method names.

  • Rate-Limited HTTP Session:
    Built-in rate limiting using the ratelimit library and robust error handling with logging.

  • Dynamic Endpoint Methods:
    Automatically attaches methods based on your configuration file (fmpstab_endpoints.json).

  • Asynchronous WebSocket Clients:
    Separate clients for stocks, crypto, and forex data available in the fmpstab_websockets subpackage.

  • Flexible Configuration and Logging:
    Easily configure your endpoints with a JSON file and log messages to a file in the same directory as your main script.

Installation

Using pip

pip install fmpstab

Clone the repository and install the dependencies:

FIXME:: git clone https://github.com/Vimal-Seshadri-Raguraman/FMP.git
FIXME:: cd FMP
FIXME:: pip install -r requirements.txt
FIXME:: python setup.py install

Alternatively, install directly from Github:

FIXME:: pip install git+https://github.com/Vimal-Seshadri-Raguraman/FMP.git

Usage

API Client

Initialize the client with your API Key and call any endpoint dynmically:

from fmpstab import FMPStab

# Initialize client with your API Key
client = fmpstab(api_key = "YOUR_API_KEY")

# Call an endpoint (e.g., "Profile")
response = client.profile(symbol = "AAPL")
print("Status Code:", response.status_code)
print("Profile Data:", response.json())

Dynmic Methods and Help

The client automatically attaches methods based on the JSON configuration. To see available endpoints and their parameters:

# General help for all endpoints
print(client.help())

# Detailed help for a specific endpoint (e.g., "profile")
print(client.help("profile"))

# Generate a manual page of endpoints
man_doc = client.man_page() # Create a text file
print(man_doc)

WebSocket Clients

The library includes asynchronous WebSocket clients for real-time data.

Stock WebSocket Example

import asyncio
from fmpstab import StockWebsockets

async def run_stock_ws():
    stock_ws = StockWebsockets(tickers=["AAPL", "MSFT"], api_key="YOUR_API_KEY")
    async for message in stock_ws.run():
        print("Stock WebSocket Message:", message)

asyncio.run(run_stock_ws())

Crypto and Forex WebSocket Example

import asyncio
from fmpstab import CryptoWebsockets, ForexWebsockets

async def run_crypto_ws():
    crypto_ws = CryptoWebsockets(tickers=["BTCUSD", "ETHUSD"], api_key="YOUR_API_KEY")
    async for message in crypto_ws.run():
        print("Crypto WebSocket Message:", message)

async def run_forex_ws():
    forex_ws = ForexWebsockets(pairs=["EURUSD", "GBPUSD"], api_key="YOUR_API_KEY")
    async for message in forex_ws.run():
        print("Forex WebSocket Message:", message)

# Run one example at a time:
asyncio.run(run_crypto_ws())
# asyncio.run(run_forex_ws())

Configuration

By default, the client loads endpoint configuration from fmpstab_endpoints.json located in the same directory as fmpstab_client.py. To use a custom configuration file:

client = FMPStab(api_key="YOUR_API_KEY", config_file="path/to/your_config.json")

If you update the configuration file during runtime, force a reload with:

client.config_manager.reload()

Logging

Logging is enabled by default and creates a log file (fmpstab.log) in the directory where your main script is located. To disable logging:

client = FMP(api_key="YOUR_API_KEY", log_enabled=False)

Contributing

Contributions, bug reports, and feature requests are welcome. Please open an issue or submit a pull request.

License

This project is licensed under the MIT License. See the FIXME LICENSE.md file for details.

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

fmpstab-0.1.0.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

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

fmpstab-0.1.0-py3-none-any.whl (15.1 kB view details)

Uploaded Python 3

File details

Details for the file fmpstab-0.1.0.tar.gz.

File metadata

  • Download URL: fmpstab-0.1.0.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for fmpstab-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e3eba80439595fb638337806006cc61a4ed352ead5868940288e7e773f7e501d
MD5 5fd08f8061dd75176f40cdb09d5fb8e6
BLAKE2b-256 c8114016f41290cfe47804f0c0967a1e75a8fe0043e5527d06423d1e744e9b4e

See more details on using hashes here.

File details

Details for the file fmpstab-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: fmpstab-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for fmpstab-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 df94db5b80fc51791b5b54edd755fc5348727d1f2affb624d57ec666c40463af
MD5 beb43f0a42559aca55930621ec10727f
BLAKE2b-256 8e34983671df370259d225523f12e90e9908beec422038c3decc5603896fa997

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