jpskill.com
🛠️ 開発・MCP コミュニティ

finnhub-api

FinnHubの金融データAPIを活用し、株、為替、仮想通貨などのリアルタイム相場、企業情報、財務諸表、インサイダー取引、決算カレンダー、市場ニュースといった情報を取得するSkill。

📜 元の英語説明(参考)

FinnHub financial data API integration for stocks, forex, crypto, news, and fundamentals. Use when fetching real-time quotes, company profiles, financial statements, insider trading, earnings calendars, or market news.

🇯🇵 日本人クリエイター向け解説

一言でいうと

FinnHubの金融データAPIを活用し、株、為替、仮想通貨などのリアルタイム相場、企業情報、財務諸表、インサイダー取引、決算カレンダー、市場ニュースといった情報を取得するSkill。

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o finnhub-api.zip https://jpskill.com/download/9424.zip && unzip -o finnhub-api.zip && rm finnhub-api.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/9424.zip -OutFile "$d\finnhub-api.zip"; Expand-Archive "$d\finnhub-api.zip" -DestinationPath $d -Force; ri "$d\finnhub-api.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して finnhub-api.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → finnhub-api フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
1

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

FinnHub API 連携

FinnHub の金融データ API との完全な連携により、株式、外国為替、暗号通貨、企業のファンダメンタルズ、ニュース、リアルタイムの市場データへのアクセスを提供します。

クイックスタート

認証

# 環境変数 (推奨)
export FINNHUB_API_KEY="your_api_key"

# または .env ファイルで
FINNHUB_API_KEY=your_api_key

基本的な使い方 (Python)

import requests
import os

API_KEY = os.getenv("FINNHUB_API_KEY")
BASE_URL = "https://finnhub.io/api/v1"

def get_quote(symbol: str) -> dict:
    """指定された銘柄のリアルタイムの株価を取得します。"""
    response = requests.get(
        f"{BASE_URL}/quote",
        params={"symbol": symbol, "token": API_KEY}
    )
    return response.json()

# 例
quote = get_quote("AAPL")
print(f"AAPL: ${quote['c']:.2f} ({quote['dp']:+.2f}%)")

公式 SDK の使用

import finnhub

client = finnhub.Client(api_key="your_api_key")

# 株価の取得
quote = client.quote("AAPL")

# 会社概要の取得
profile = client.company_profile2(symbol="AAPL")

# 財務情報の取得
financials = client.company_basic_financials("AAPL", "all")

API エンドポイントリファレンス

株式市場データ

Endpoint Description Free
/quote リアルタイム株価
/stock/candle 過去の OHLCV
/stock/profile2 会社概要
/stock/peers 類似企業
/company-news 企業ニュース
/stock/metric 基本的な財務情報
/stock/financials 財務諸表
/stock/insider-transactions インサイダー取引 ⚠️ Premium
/stock/insider-sentiment インサイダーセンチメント ⚠️ Premium

ファンダメンタルデータ

Endpoint Description Free
/stock/financials-reported SEC 報告
/stock/earnings 過去の収益
/stock/recommendation アナリスト評価
/stock/price-target 目標株価
/stock/revenue-estimate 収益予測 ⚠️ Premium
/stock/eps-estimate EPS 予測 ⚠️ Premium

外国為替 & 暗号通貨

Endpoint Description Free
/forex/rates 為替レート
/forex/candle 外国為替 OHLCV
/crypto/candle 暗号通貨 OHLCV
/crypto/exchanges 暗号通貨取引所
/crypto/symbol 暗号通貨シンボル

ニュース & センチメント

Endpoint Description Free
/company-news 企業ニュース
/news 市場ニュース
/press-releases プレスリリース ⚠️ Premium
/news-sentiment ニュースセンチメント ⚠️ Premium

カレンダーイベント

Endpoint Description Free
/calendar/earnings 収益カレンダー
/calendar/ipo IPO カレンダー
/stock/dividends 配当履歴
/stock/splits 株式分割

レート制限

Tier Calls/Minute Notes
Free 60 米国株、外国為替、暗号通貨
Paid 300+ 市場ごとの価格設定

レート制限ヘッダー:

  • X-Ratelimit-Limit: 1分あたりの最大呼び出し数
  • X-Ratelimit-Remaining: 残りの呼び出し数
  • X-Ratelimit-Reset: リセットタイムスタンプ

一般的なタスク

タスク: 変化率付きの株価を取得する

def get_stock_info(symbol: str) -> dict:
    """包括的な株式情報を取得します。"""
    quote = requests.get(
        f"{BASE_URL}/quote",
        params={"symbol": symbol, "token": API_KEY}
    ).json()

    profile = requests.get(
        f"{BASE_URL}/stock/profile2",
        params={"symbol": symbol, "token": API_KEY}
    ).json()

    return {
        "symbol": symbol,
        "name": profile.get("name"),
        "price": quote["c"],
        "change": quote["d"],
        "change_percent": quote["dp"],
        "high": quote["h"],
        "low": quote["l"],
        "market_cap": profile.get("marketCapitalization"),
        "industry": profile.get("finnhubIndustry")
    }

タスク: 過去のローソク足を取得する

import time

def get_candles(symbol: str, resolution: str = "D", days: int = 30) -> dict:
    """
    過去の OHLCV データを取得します。

    解像度: 1, 5, 15, 30, 60, D, W, M
    """
    end = int(time.time())
    start = end - (days * 24 * 60 * 60)

    response = requests.get(
        f"{BASE_URL}/stock/candle",
        params={
            "symbol": symbol,
            "resolution": resolution,
            "from": start,
            "to": end,
            "token": API_KEY
        }
    )
    return response.json()

タスク: 収益カレンダーを取得する

def get_earnings_calendar(from_date: str, to_date: str) -> list:
    """今後の収益発表を取得します。"""
    response = requests.get(
        f"{BASE_URL}/calendar/earnings",
        params={
            "from": from_date,
            "to": to_date,
            "token": API_KEY
        }
    )
    return response.json().get("earningsCalendar", [])

# 例: 来週の収益を取得する
earnings = get_earnings_calendar("2025-12-05", "2025-12-12")

タスク: 企業ニュースを取得する

def get_company_news(symbol: str, days: int = 7) -> list:
    """最近の企業ニュースを取得します。"""
    from datetime import datetime, timedelta

    end = datetime.now()
    start = end - timedelta(days=days)

    response = requests.get(
        f"{BASE_URL}/company-news",
        params={
            "symbol": symbol,
            "from": start.strftime("%Y-%m-%d"),
            "to": end.strftime("%Y-%m-%d"),
            "token": API_KEY
        }
    )
    return response.json()

タスク: 財務指標を取得する


def get_financials(symbol: str) -> dict:
    """主要な財務指標を取得します。"""
    response = requests.get(
        f"{BASE_URL}/stock/metric",
        params={
            "symbol": symbol,
            "metric": "all",
            "token": API_KEY
        }
    )
    data = response.json()

    metrics = data.get("metric", {})
    return {
        "pe_ratio": metrics.get("peBasicExclExtraTTM"),
        "pb_ratio": metrics.get("p
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

FinnHub API Integration

Complete integration with FinnHub's financial data API providing access to stocks, forex, crypto, company fundamentals, news, and real-time market data.

Quick Start

Authentication

# Environment variable (recommended)
export FINNHUB_API_KEY="your_api_key"

# Or in .env file
FINNHUB_API_KEY=your_api_key

Basic Usage (Python)

import requests
import os

API_KEY = os.getenv("FINNHUB_API_KEY")
BASE_URL = "https://finnhub.io/api/v1"

def get_quote(symbol: str) -> dict:
    """Get real-time quote for a symbol."""
    response = requests.get(
        f"{BASE_URL}/quote",
        params={"symbol": symbol, "token": API_KEY}
    )
    return response.json()

# Example
quote = get_quote("AAPL")
print(f"AAPL: ${quote['c']:.2f} ({quote['dp']:+.2f}%)")

Using Official SDK

import finnhub

client = finnhub.Client(api_key="your_api_key")

# Get quote
quote = client.quote("AAPL")

# Get company profile
profile = client.company_profile2(symbol="AAPL")

# Get financials
financials = client.company_basic_financials("AAPL", "all")

API Endpoints Reference

Stock Market Data

Endpoint Description Free
/quote Real-time quote
/stock/candle Historical OHLCV
/stock/profile2 Company profile
/stock/peers Similar companies
/company-news Company news
/stock/metric Basic financials
/stock/financials Financial statements
/stock/insider-transactions Insider trades ⚠️ Premium
/stock/insider-sentiment Insider sentiment ⚠️ Premium

Fundamental Data

Endpoint Description Free
/stock/financials-reported SEC reported
/stock/earnings Earnings history
/stock/recommendation Analyst ratings
/stock/price-target Price targets
/stock/revenue-estimate Revenue estimates ⚠️ Premium
/stock/eps-estimate EPS estimates ⚠️ Premium

Forex & Crypto

Endpoint Description Free
/forex/rates Exchange rates
/forex/candle Forex OHLCV
/crypto/candle Crypto OHLCV
/crypto/exchanges Crypto exchanges
/crypto/symbol Crypto symbols

News & Sentiment

Endpoint Description Free
/company-news Company news
/news Market news
/press-releases Press releases ⚠️ Premium
/news-sentiment News sentiment ⚠️ Premium

Calendar Events

Endpoint Description Free
/calendar/earnings Earnings calendar
/calendar/ipo IPO calendar
/stock/dividends Dividend history
/stock/splits Stock splits

Rate Limits

Tier Calls/Minute Notes
Free 60 US stocks, forex, crypto
Paid 300+ Per-market pricing

Rate limit headers:

  • X-Ratelimit-Limit: Max calls per minute
  • X-Ratelimit-Remaining: Calls remaining
  • X-Ratelimit-Reset: Reset timestamp

Common Tasks

Task: Get Stock Quote with Change

def get_stock_info(symbol: str) -> dict:
    """Get comprehensive stock info."""
    quote = requests.get(
        f"{BASE_URL}/quote",
        params={"symbol": symbol, "token": API_KEY}
    ).json()

    profile = requests.get(
        f"{BASE_URL}/stock/profile2",
        params={"symbol": symbol, "token": API_KEY}
    ).json()

    return {
        "symbol": symbol,
        "name": profile.get("name"),
        "price": quote["c"],
        "change": quote["d"],
        "change_percent": quote["dp"],
        "high": quote["h"],
        "low": quote["l"],
        "market_cap": profile.get("marketCapitalization"),
        "industry": profile.get("finnhubIndustry")
    }

Task: Get Historical Candles

import time

def get_candles(symbol: str, resolution: str = "D", days: int = 30) -> dict:
    """
    Get historical OHLCV data.

    Resolutions: 1, 5, 15, 30, 60, D, W, M
    """
    end = int(time.time())
    start = end - (days * 24 * 60 * 60)

    response = requests.get(
        f"{BASE_URL}/stock/candle",
        params={
            "symbol": symbol,
            "resolution": resolution,
            "from": start,
            "to": end,
            "token": API_KEY
        }
    )
    return response.json()

Task: Get Earnings Calendar

def get_earnings_calendar(from_date: str, to_date: str) -> list:
    """Get upcoming earnings releases."""
    response = requests.get(
        f"{BASE_URL}/calendar/earnings",
        params={
            "from": from_date,
            "to": to_date,
            "token": API_KEY
        }
    )
    return response.json().get("earningsCalendar", [])

# Example: Get next week's earnings
earnings = get_earnings_calendar("2025-12-05", "2025-12-12")

Task: Get Company News

def get_company_news(symbol: str, days: int = 7) -> list:
    """Get recent company news."""
    from datetime import datetime, timedelta

    end = datetime.now()
    start = end - timedelta(days=days)

    response = requests.get(
        f"{BASE_URL}/company-news",
        params={
            "symbol": symbol,
            "from": start.strftime("%Y-%m-%d"),
            "to": end.strftime("%Y-%m-%d"),
            "token": API_KEY
        }
    )
    return response.json()

Task: Get Financial Metrics

def get_financials(symbol: str) -> dict:
    """Get key financial metrics."""
    response = requests.get(
        f"{BASE_URL}/stock/metric",
        params={
            "symbol": symbol,
            "metric": "all",
            "token": API_KEY
        }
    )
    data = response.json()

    metrics = data.get("metric", {})
    return {
        "pe_ratio": metrics.get("peBasicExclExtraTTM"),
        "pb_ratio": metrics.get("pbQuarterly"),
        "ps_ratio": metrics.get("psAnnual"),
        "roe": metrics.get("roeTTM"),
        "roa": metrics.get("roaTTM"),
        "debt_equity": metrics.get("totalDebt/totalEquityQuarterly"),
        "current_ratio": metrics.get("currentRatioQuarterly"),
        "gross_margin": metrics.get("grossMarginTTM"),
        "operating_margin": metrics.get("operatingMarginTTM"),
        "52w_high": metrics.get("52WeekHigh"),
        "52w_low": metrics.get("52WeekLow"),
        "beta": metrics.get("beta")
    }

WebSocket Real-Time Data

import websocket
import json

def on_message(ws, message):
    data = json.loads(message)
    if data["type"] == "trade":
        for trade in data["data"]:
            print(f"{trade['s']}: ${trade['p']:.2f} x {trade['v']}")

def on_open(ws):
    # Subscribe to symbols
    ws.send(json.dumps({"type": "subscribe", "symbol": "AAPL"}))
    ws.send(json.dumps({"type": "subscribe", "symbol": "MSFT"}))

ws = websocket.WebSocketApp(
    f"wss://ws.finnhub.io?token={API_KEY}",
    on_message=on_message,
    on_open=on_open
)
ws.run_forever()

Error Handling

def safe_api_call(endpoint: str, params: dict) -> dict:
    """Make API call with error handling."""
    params["token"] = API_KEY

    try:
        response = requests.get(f"{BASE_URL}/{endpoint}", params=params)
        response.raise_for_status()

        # Check for rate limit
        remaining = response.headers.get("X-Ratelimit-Remaining")
        if remaining and int(remaining) < 5:
            print(f"Warning: Only {remaining} API calls remaining")

        return response.json()

    except requests.exceptions.HTTPError as e:
        if response.status_code == 429:
            print("Rate limit exceeded. Waiting 60 seconds...")
            time.sleep(60)
            return safe_api_call(endpoint, params)
        raise
    except Exception as e:
        print(f"API error: {e}")
        return {}

Free vs Premium Features

Free Tier Includes

  • Real-time US stock quotes
  • Historical data (1 year)
  • Company profiles & peers
  • Basic financials & metrics
  • Earnings calendar
  • Company news
  • Forex & crypto data
  • WebSocket (US stocks, forex, crypto)

Premium Required

  • Insider transactions & sentiment
  • SEC filings
  • ESG scores
  • Patent data
  • Congressional trading
  • International markets
  • Revenue/EPS estimates
  • Lobbying data
  • Extended historical data

Best Practices

  1. Cache static data - Company profiles, metrics rarely change
  2. Use WebSocket - For real-time quotes instead of polling
  3. Batch where possible - Reduce API calls
  4. Handle rate limits - Implement exponential backoff
  5. Store API key securely - Use environment variables

Installation

# Python SDK
pip install finnhub-python

# JavaScript SDK
npm install finnhub

Related Skills

  • twelvedata-api - Alternative market data source
  • alphavantage-api - Technical indicators focus
  • fmp-api - Fundamental analysis focus

References