fmp-api について
fmp-apiは、Financial Modeling Prepの安定版APIを利用するための統合ガイドです。Pythonで企業の基礎データや市場データを取得する開発者向けに、財務諸表、評価額、SEC提出書類、取引データ、カレンダーと利用区分を説明します。
主な機能
- 01リアルタイム株価と過去価格の取得
- 02財務諸表、指標、比率の照会
- 03DCF評価額と企業プロフィールの取得
- 04SEC提出書類や保有・取引データの取得
- 05決算、IPO、経済カレンダーの照会
活用シーン
- 01企業の財務諸表と評価額の分析
- 02株価と過去の価格データの確認
- 03SEC提出書類や機関投資家の保有情報の検索
- 04決算発表や経済イベントの日程確認
インストール
コマンドをコピーしてターミナルで実行します。
$
npx skills add https:/ / github.com/ adaptationio/ skrillz --skill fmp-apiインストール後、Claude Code で/fmp-apiを入力して読み込まれたか確認します。
同梱ファイルreferences/ENDPOINTS.mdscripts/fmp_client.py
詳細
Financial Modeling Prep (FMP) API 連携
ファンダメンタル分析、SEC 提出書類、機関投資家の保有状況(13F)、議会議員の取引データ、事前計算済みの評価額に特化した包括的な金融データ API です。
クイックスタート
認証
# Environment variable (recommended)
export FMP_API_KEY="your_api_key"
# Or in .env file
FMP_API_KEY=your_api_key
基本的な使い方(Python)
import requests
import os
API_KEY = os.getenv("FMP_API_KEY")
BASE_URL = "https://financialmodelingprep.com/stable"
def get_quote(symbol: str) -> dict:
"""Get real-time quote for a symbol."""
response = requests.get(
f"{BASE_URL}/quote",
params={"symbol": symbol, "apikey": API_KEY}
)
data = response.json()
return data[0] if data else {}
# Example
quote = get_quote("AAPL")
print(f"AAPL: ${quote['price']:.2f} ({quote['changePercentage']:+.2f}%)")
重要:新しいエンドポイント形式
FMP は /stable/ エンドポイントに移行しました。従来の /api/v3/ エンドポイントを利用するには、既存のサブスクリプションが必要です。
# NEW format (use this)
BASE_URL = "https://financialmodelingprep.com/stable"
# OLD format (legacy only)
# BASE_URL = "https://financialmodelingprep.com/api/v3"
API エンドポイントのリファレンス
株価の気配値と価格
| エンドポイント | 説明 | 無料 |
|---|---|---|
/quote | リアルタイムの気配値 | ✅ |
/quote-short | 簡易的な価格 | ✅ |
/historical-price-eod/full | 過去の終値データ | ✅ |
/historical-price-intraday | 日中価格 | ⚠️ 有料 |
/pre-post-market-quote | 時間外取引 | ⚠️ 有料 |
財務諸表
| エンドポイント | 説明 | 無料 |
|---|---|---|
/income-statement | 損益計算書 | ✅ |
/balance-sheet-statement | 貸借対照表 | ✅ |
/cash-flow-statement | キャッシュフロー | ✅ |
/income-statement-growth | 売上高の成長率 | ✅ |
/key-metrics | 主要指標 | ✅ |
/financial-ratios | 財務比率 | ✅ |
/enterprise-values | 企業価値 | ✅ |
バリュエーションと分析
| エンドポイント | 説明 | 無料 |
|---|---|---|
/discounted-cash-flow | DCF バリュエーション | ✅ |
/historical-discounted-cash-flow | 過去の DCF | ✅ |
/rating | 企業格付け | ✅ |
/historical-rating | 格付けの履歴 | ✅ |
/company-outlook | 企業の包括的なデータ | ✅ |
機関投資家とインサイダーのデータ
| エンドポイント | 説明 | 無料 |
|---|---|---|
/institutional-holder | 機関投資家の保有者 | ⚠️ 有料 |
/mutual-fund-holder | 投資信託の保有者 | ⚠️ 有料 |
/insider-trading | インサイダー取引 | ⚠️ 有料 |
/form-13f | 13F 提出書類 | ⚠️ 有料 |
/senate-trading | 上院議員の取引 | ⚠️ 有料 |
/house-trading | 下院議員の取引 | ⚠️ 有料 |
スクリーニングと検索
| エンドポイント | 説明 | 無料 |
|---|---|---|
/stock-screener | 株式をスクリーニング | ⚠️ 有料 |
/stock-grade | 株式の格付け | ✅ |
/search | ティッカーシンボルを検索 | ✅ |
/search-name | 名前で検索 | ✅ |
/profile | 企業プロフィール | ✅ |
カレンダーとイベント
| エンドポイント | 説明 | 無料 |
|---|---|---|
/earnings-calendar | 決算発表日 | ✅ |
/ipo-calendar | IPO 日程 | ✅ |
/stock-dividend-calendar | 配当 | ✅ |
/stock-split-calendar | 株式分割 | ✅ |
/economic-calendar | 経済イベント | ✅ |
SEC 提出書類
| エンドポイント | 説明 | 無料 |
|---|---|---|
/sec-filings | すべての SEC 提出書類 | ✅ |
/rss-feed-sec-filings | SEC の RSS フィード | ✅ |
レート制限
| ティア | 1 日あたりの呼び出し回数 | 1 分あたりの呼び出し回数 | 価格 |
|---|---|---|---|
| 無料 | 250 | N/A | $0 |
| Starter | 無制限 | 300 | $22/mo |
| Premium | 無制限 | 750 | $59/mo |
| Ultimate | 無制限 | 3,000 | $149/mo |
無料ティアの制限:
- 約100銘柄のサンプル(AAPL、TSLA、AMZN など)
- 終値データのみ
- 帯域幅 500MB(直近30日間のローリング期間)
よくあるタスク
タスク:財務諸表を取得する
def get_financials(symbol: str, period: str = "annual") -> dict:
"""Get comprehensive financial statements."""
income = requests.get(
f"{BASE_URL}/income-statement",
params={"symbol": symbol, "period": period, "apikey": API_KEY}
).json()
balance = requests.get(
f"{BASE_URL}/balance-sheet-statement",
params={"symbol": symbol, "period": period, "apikey": API_KEY}
).json()
cashflow = requests.get(
f"{BASE_URL}/cash-flow-statement",
params={"symbol": symbol, "period": period, "apikey": API_KEY}
).json()
return {
"income_statement": income[0] if income else {},
"balance_sheet": balance[0] if balance else {},
"cash_flow": cashflow[0] if cashflow else {}
}
# Example
financials = get_financials("AAPL")
print(f"Revenue: ${financials['income_statement'].get('revenue', 0):,.0f}")
タスク:主要指標と財務比率を取得する
def get_key_metrics(symbol: str) -> dict:
"""Get important financial metrics."""
metrics = requests.get(
f"{BASE_URL}/key-metrics",
params={"symbol": symbol, "period": "annual", "apikey": API_KEY}
).json()
ratios = requests.get(
f"{BASE_URL}/financial-ratios",
params={"symbol": symbol, "period": "annual", "apikey": API_KEY}
).json()
latest_metrics = metrics[0] if metrics else {}
latest_ratios = ratios[0] if ratios else {}
return {
"market_cap": latest_metrics.get("marketCap"),
"pe_ratio": latest_ratios.get("priceEarningsRatio"),
"pb_ratio": latest_ratios.get("priceToBookRatio"),
"roe": latest_ratios.get("returnOnEquity"),
"roa": latest_ratios.get("returnOnAssets"),
"debt_equity": latest_ratios.get("debtEquityRatio"),
"current_ratio": latest_ratios.get("currentRatio"),
"gross_margin": latest_ratios.get("grossProfitMargin"),
"operating_margin": latest_ratios.get("operatingProfitMargin"),
"net_margin": latest_ratios.get("netProfitMargin"),
"dividend_yield": latest_ratios.get("dividendYield"),
"payout_ratio": latest_ratios.get("payoutRatio")
}
タスク:DCF バリュエーションを取得する
def get_dcf_valuation(symbol: str) -> dict:
"""Get pre-computed DCF valuation."""
response = requests.get(
f"{BASE_URL}/discounted-cash-flow",
params={"symbol": symbol, "apikey": API_KEY}
)
data = response.json()
if data:
dcf = data[0]
return {
"symbol": dcf.get("symbol"),
"dcf_value": dcf.get("dcf"),
"stock_price": dcf.get("stockPrice"),
"upside": ((dcf.get("dcf", 0) / dcf.get("stockPrice", 1)) - 1) * 100
}
return {}
# Example
dcf = get_dcf_valuation("AAPL")
print(f"DCF Value: ${dcf['dcf_value']:.2f} ({dcf['upside']:+.1f}% upside)")
タスク:企業プロフィールを取得する
def get_company_profile(symbol: str) -> dict:
"""Get comprehensive company information."""
response = requests.get(
f"{BASE_URL}/profile",
params={"symbol": symbol, "apikey": API_KEY}
)
data = response.json()
if data:
profile = data[0]
return {
"name": profile.get("companyName"),
"symbol": profile.get("symbol"),
"sector": profile.get("sector"),
"industry": profile.get("industry"),
"market_cap": profile.get("mktCap"),
"price": profile.get("price"),
"beta": profile.get("beta"),
"ceo": profile.get("ceo"),
"website": profile.get("website"),
"description": profile.get("description"),
"employees": profile.get("fullTimeEmployees"),
"exchange": profile.get("exchange"),
"ipo_date": profile.get("ipoDate")
}
return {}
タスク:決算カレンダーを取得する
def get_earnings_calendar(from_date: str, to_date: str) -> list:
"""Get upcoming earnings announcements."""
response = requests.get(
f"{BASE_URL}/earnings-calendar",
params={
"from": from_date,
"to": to_date,
"apikey": API_KEY
}
)
return response.json()
# Example
from datetime import datetime, timedelta
today = datetime.now()
next_week = today + timedelta(days=7)
earnings = get_earnings_calendar(
today.strftime("%Y-%m-%d"),
next_week.strftime("%Y-%m-%d")
)
for e in earnings[:5]:
print(f"{e['symbol']}: {e['date']} ({e.get('time', 'N/A')})")
タスク:過去の価格を取得する
def get_historical_prices(symbol: str, start: str = None, end: str = None) -> list:
"""Get historical end-of-day prices."""
params = {"symbol": symbol, "apikey": API_KEY}
if start:
params["from"] = start
if end:
params["to"] = end
response = requests.get(
f"{BASE_URL}/historical-price-eod/full",
params=params
)
data = response.json()
return data.get("historical", [])
# Example
prices = get_historical_prices("AAPL", "2025-01-01", "2025-12-01")
print(f"Got {len(prices)} days of data")
タスク:企業を検索する
def search_companies(query: str, limit: int = 10) -> list:
"""Search for companies by name or symbol."""
response = requests.get(
f"{BASE_URL}/search",
params={
"query": query,
"limit": limit,
"apikey": API_KEY
}
)
return response.json()
# Example
results = search_companies("Apple")
for r in results[:5]:
print(f"{r['symbol']}: {r['name']} ({r['exchangeShortName']})")
タスク:SEC 提出書類を取得する
def get_sec_filings(symbol: str, filing_type: str = None) -> list:
"""Get SEC filings for a company."""
params = {"symbol": symbol, "apikey": API_KEY}
if filing_type:
params["type"] = filing_type # 10-K, 10-Q, 8-K, etc.
response = requests.get(
f"{BASE_URL}/sec-filings",
params=params
)
return response.json()
# Example: Get 10-K filings
filings = get_sec_filings("AAPL", "10-K")
for f in filings[:3]:
print(f"{f['type']}: {f['fillingDate']} - {f['link']}")
エラー処理
def safe_api_call(endpoint: str, params: dict) -> dict:
"""Make API call with error handling."""
params["apikey"] = API_KEY
try:
response = requests.get(f"{BASE_URL}/{endpoint}", params=params)
data = response.json()
# Check for error messages
if isinstance(data, dict) and "Error Message" in data:
print(f"API Error: {data['Error Message']}")
return {}
# Check for empty response
if not data:
print(f"No data returned for {endpoint}")
return {}
return data
except requests.exceptions.RequestException as e:
print(f"Request error: {e}")
return {}
except ValueError as e:
print(f"JSON decode error: {e}")
return {}
無料機能と有料機能
無料ティアに含まれる機能
- 1 日あたり 250 回の API 呼び出し
- 約100銘柄のサンプル
- 財務諸表
- 主要指標と財務比率
- DCF バリュエーション
- 企業プロフィール
- 決算カレンダー
- SEC 提出書類の一覧
- 基本的な過去データ
有料機能(Starter 以上)
- 銘柄数無制限
- 日中データ
- 株式スクリーナー
- 国際株式
- 機関投資家の保有状況
- 投資信託の保有状況
- ETF 保有銘柄の内訳
有料機能(Premium+)
- より高いレート制限
- 13F 提出書類
- インサイダー取引
- 議会議員の取引(上院/下院)
- アナリスト予想
- 決算説明会のトランスクリプト
- 時間外取引データ
FMP 独自の機能
- 事前計算済みの DCF - すぐに使える評価額
- 議会議員の取引 - 上院/下院の STOCK Act データ
- 13F 提出書類 - 機関投資家の保有状況の分析
- 標準化された財務データ - 正規化された項目
- 企業の概要 - すべてのデータを 1 つのエンドポイントで取得
- 格付けシステム - 独自の企業格付け
ベストプラクティス
- 安定版エンドポイントを使用する -
/api/v3/ではなく/stable/ - 静的データをキャッシュする - プロフィール、過去のデータ
- 1 日あたりの制限を監視する - 250 回の呼び出しはすぐに上限に達します
- シンボルの検索をまとめて行う - 対応している場合
- 財務データを保存する - 更新は四半期ごとのみです
- company-outlook を使用する - 1 回の呼び出しですべてのデータを取得
インストール
# Recommended Python wrapper
pip install --upgrade FinancialModelingPrep-Python
# Basic usage
from fmp_python.fmp import FMP
fmp = FMP(api_key="your_api_key")
profile = fmp.get_company_profile("AAPL")
関連スキル
finnhub-api- リアルタイムの株価とニュースtwelvedata-api- テクニカル指標alphavantage-api- 経済指標
参考資料
コメント
Markdown 対応