Skip to main content

Python client for the Financial Modeling Prep API with DuckDB caching

Project description

jaymd96-fmp

Python client for the Financial Modeling Prep API with automatic DuckDB caching.

Features

  • 150+ endpoints covering quotes, financials, charts, news, SEC filings, insider trades, and more
  • DuckDB cache with configurable TTLs per endpoint category — avoid redundant API calls
  • Concurrent fetchingfetch_many() pulls data for hundreds of symbols in parallel
  • Auto-paginationpaginate_all() walks through paginated endpoints automatically
  • Rate limiting — built-in token-bucket rate limiter, thread-safe for concurrent use
  • Context manager support for clean resource cleanup

Installation

pip install jaymd96-fmp

Quick Start

from fmp import FMPClient

# API key from argument or FMP_API_KEY env var
client = FMPClient(api_key="your-api-key")

# Real-time quote
client.quote("AAPL")

# Financial statements
client.income_statement("AAPL", period="quarter", limit=4)

# Historical prices
client.historical_price_eod_full("AAPL", from_date="2024-01-01", to_date="2024-12-31")

# Stock screener
client.screener(sector="Technology", market_cap_more_than=1_000_000_000)

# Technical indicators
client.sma("AAPL", period_length=20, timeframe="1day")

Concurrent Fetching

# Fetch quotes for many symbols in parallel
results = client.fetch_many(client.quote, ["AAPL", "MSFT", "GOOG", "AMZN"], max_workers=10)
# Returns: {"AAPL": [...], "MSFT": [...], ...}

Auto-Pagination

# Fetch all pages of stock news
all_news = client.paginate_all(client.stock_news_latest, limit=100, max_pages=50)

Cache

All responses are cached in a local DuckDB database (~/.fmp/cache.db by default). TTLs are set per endpoint category (e.g., 60s for quotes, 7 days for financial statements).

# In-memory cache (no persistence)
client = FMPClient(api_key="...", cache_path=None)

# Custom TTLs
client = FMPClient(api_key="...", ttl_overrides={"realtime_quotes": 30})

# Force refresh (bypass cache)
client.quote("AAPL", force_refresh=True)

# Run SQL queries on cached data
client.sql("SELECT * FROM _raw_cache WHERE endpoint = 'quote'")

# Clear cache
client.clear_cache()
client.clear_cache(endpoint="quote")

Rate Limiting

# Limit to 5 requests per second (for free-tier plans)
client = FMPClient(api_key="...", rate_limit=5)

Context Manager

with FMPClient(api_key="...") as client:
    data = client.quote("AAPL")
# Connections closed automatically

Configuration

Parameter Default Description
api_key FMP_API_KEY env var Your FMP API key
cache_path ~/.fmp/cache.db DuckDB file path, None for in-memory
ttl_overrides {} Override TTLs by category name
timeout 30.0 HTTP timeout in seconds
max_retries 3 Retry count on 429 responses
rate_limit None Max requests/second

License

MIT

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

jaymd96_fmp-0.3.2.tar.gz (59.1 kB view details)

Uploaded Source

Built Distribution

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

jaymd96_fmp-0.3.2-py3-none-any.whl (63.7 kB view details)

Uploaded Python 3

File details

Details for the file jaymd96_fmp-0.3.2.tar.gz.

File metadata

  • Download URL: jaymd96_fmp-0.3.2.tar.gz
  • Upload date:
  • Size: 59.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.16.3 cpython/3.13.0 HTTPX/0.28.1

File hashes

Hashes for jaymd96_fmp-0.3.2.tar.gz
Algorithm Hash digest
SHA256 fad597867c42c0f87beb9c74466d2eea8da7a51c10429d8a3b5933af6c616b4b
MD5 eaabb5c104c6225428c9ef43c3926c33
BLAKE2b-256 dced63e097d0576b6f4045a8de43dbd4e1677f45b33662eeb2eb2addf04d3198

See more details on using hashes here.

File details

Details for the file jaymd96_fmp-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: jaymd96_fmp-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 63.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.16.3 cpython/3.13.0 HTTPX/0.28.1

File hashes

Hashes for jaymd96_fmp-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 59b70a8b60c59d01698a91a17b8943e9f292cf680cb28f3ed4d8e1bb346d1698
MD5 45fe2758978d8109b5598852fb7a2a3f
BLAKE2b-256 bab22c1c6772b380bcdd93f0f21d8b8543942a795793a555e9e6ac16d76f5955

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