100 free credits. No credit card required. Get a key

How to scrape stock fundamentals with Python

Key statistics, financial data, analyst targets and recent revenue, earnings and EPS against estimates.

The examples use requests with a timeout and raise_for_status(), and read the JSON as plain dicts.

GET /v1/finance/fundamentals1 credit per callRefunded on failure

Before you start

  1. Get an API keySign up for 100 free credits, no card. Keys start with gs_live_.
  2. Put it in the environmentEvery example reads it from GROUNDSOCIAL_API_KEY: export GROUNDSOCIAL_API_KEY=gs_live_…
  3. Set up Pythonpip install requests

Call Stock fundamentals API from Python

GET /v1/finance/fundamentals. Save this as main.py and run python main.py.

main.py
import os

import requests

API = "https://api.groundsocial.dev"
HEADERS = {"Authorization": f"Bearer {os.environ['GROUNDSOCIAL_API_KEY']}"}

res = requests.get(
    f"{API}/v1/finance/fundamentals",
    params={"keyword": "NVDA", "period": "quarterly"},
    headers=HEADERS,
    timeout=60,
)
res.raise_for_status()
data = res.json()

print(data)

print("credits charged:", res.headers["x-credits-charged"])

The response

A real Finance response to this call, recorded from the live API on 27 Nov 2026 and shortened for display: arrays keep their first items and … marks every cut. The recorded page had 4 items in earnings. Live calls return current data in the same shape.

200 OK
{
  "symbol": "NVDA",
  "summaryDetail": {
    "maxAge": 1,
    "priceHint": {
      "raw": 2,
      "fmt": "2",
      "longFmt": "2"
    },
    "previousClose": {
      "raw": 155.38,
      "fmt": "155.38"
    },
    "open": {
      "raw": 144.02,
      "fmt": "144.02"
    },
    "dayLow": {
      "raw": 141.17,
      "fmt": "141.17"
    },
    "dayHigh": {
      "raw": 150.37,
      "fmt": "150.37"
    },
    "regularMarketPreviousClose": {
      "raw": 155.38,
      "fmt": "155.38"
    },
    "regularMarketOpen": {
      "raw": 144.02,
      "fmt": "144.02"
    },
    "regularMarketDayLow": {
      "raw": 141.17,
      "fmt": "141.17"
    },
    "regularMarketDayHigh": {
      "raw": 150.37,
      "fmt": "150.37"
    },
    "…": "54 more fields"
  },
  "defaultKeyStatistics": {
    "maxAge": 1,
    "priceHint": {
      "raw": 2,
      "fmt": "2",
      "longFmt": "2"
    },
    "enterpriseValue": {
      "raw": 3539442860032,
      "fmt": "3.54T",
      "longFmt": "3,539,442,860,032"
    },
    "forwardPE": {
      "raw": 8.991117,
      "fmt": "8.99"
    },
    "profitMargins": {
      "raw": 0.62535,
      "fmt": "62.53%"
    },
    "floatShares": {
      "raw": 23138626220,
      "fmt": "23.14B",
      "longFmt": "23,138,626,220"
    },
    "sharesOutstanding": {
      "raw": 24147000000,
      "fmt": "24.15B",
      "longFmt": "24,147,000,000"
    },
    "sharesShort": {
      "raw": 305326286,
      "fmt": "305.33M",
      "longFmt": "305,326,286"
    },
    "sharesShortPriorMonth": {
      "raw": 301622687,
      "fmt": "301.62M",
      "longFmt": "301,622,687"
    },
    "sharesShortPreviousMonthDate": {
      "raw": 1792022400,
      "fmt": "2026-10-15"
    },
    "…": "51 more fields"
  },
  "financialData": {
    "maxAge": 86400,
    "currentPrice": {
      "raw": 149.3,
      "fmt": "149.30"
    },
    "targetHighPrice": {
      "raw": 425,
      "fmt": "425.00"
    },
    "targetLowPrice": {
      "raw": 130,
      "fmt": "130.00"
    },
    "targetMeanPrice": {
      "raw": 242.4278,
      "fmt": "242.43"
    },
    "targetMedianPrice": {
      "raw": 240,
      "fmt": "240.00"
    },
    "recommendationMean": {
      "raw": 1.66667,
      "fmt": "1.67"
    },
    "recommendationKey": "buy",
    "numberOfAnalystOpinions": {
      "raw": 59,
      "fmt": "59",
      "longFmt": "59"
    },
    "totalCash": {
      "raw": 97731002368,
      "fmt": "97.73B",
      "longFmt": "97,731,002,368"
    },
    "…": "20 more fields"
  },
  "earnings": [
    {
      "date": "4Q2025",
      "fiscalQuarter": "4Q2026",
      "revenue": {
        "raw": 68127000000,
        "fmt": "68.13B",
        "longFmt": "68,127,000,000"
      },
      "earnings": {
        "raw": 42960000000,
        "fmt": "42.96B",
        "longFmt": "42,960,000,000"
      },
      "profitMargin": {
        "raw": 0.630587,
        "fmt": "63.06%"
      }
    },
    "… 3 more"
  ],
  "earningsHistory": [
    {
      "maxAge": 1,
      "epsActual": {
        "raw": 1.62,
        "fmt": "1.62"
      },
      "epsEstimate": {
        "raw": 1.53812,
        "fmt": "1.54"
      },
      "epsDifference": {
        "raw": 0.08,
        "fmt": "0.08"
      },
      "surprisePercent": {
        "raw": 0.053200003,
        "fmt": "5.32%"
      },
      "quarter": {
        "raw": 1769817600,
        "fmt": "2026-01-31"
      },
      "currency": "USD",
      "period": "-4q"
    },
    "… 3 more"
  ]
}

Top-level fields

FieldTypeDescription
symbolstring–
summaryDetailobject–
defaultKeyStatisticsobject–
financialDataobject–
earningsobject[]Revenue and earnings per period, newest last.
earningsHistoryobject[]EPS actual against estimate, last quarters.

Parameters

NameInTypeDescription
keyword (required)querystringA ticker (AAPL, ^GSPC, EURUSD=X, BTC-USD) or a company name. Example: AAPL.
periodquery"quarterly" | "annual"One of quarterly, annual.
limitqueryintegerPeriods per page, 1 to 20. Defaults to 4.

Errors and retries

Every error is JSON with error.code (stable: branch on it), message, hint (what to do next), docs_url and retryable. A failed call is never charged. Retry only when retryable is true, after the Retry-After header.

Errors
import os, time

import requests

def call(url, **kwargs):
    headers = {"Authorization": f"Bearer {os.environ['GROUNDSOCIAL_API_KEY']}"}
    for attempt in range(3):
        res = requests.get(url, headers=headers, timeout=60, **kwargs)
        if res.ok:
            return res.json()
        err = res.json()["error"]
        # Branch on the stable code; the hint says what to do next.
        if err["retryable"] and attempt < 2:
            time.sleep(int(res.headers.get("Retry-After", 2)))
            continue
        raise RuntimeError(f"{err['code']}: {err.get('hint', err['message'])}")


data = call("https://api.groundsocial.dev/v1/finance/fundamentals", params={"keyword": "NVDA", "period": "quarterly"})
StatusMeaning
200The fundamentals.
400Invalid input. Nothing was charged.
401Missing or invalid API key.
402Not enough credits, a spend cap was reached, or payment is required.
403The target is private, or the account is suspended.
404No ticker or data matches.
429Too many requests. Wait for Retry-After seconds.
503Finance is temporarily unavailable. Retryable; nothing was charged.

Every error code and what to do about it.

Pricing

Cost
Per call1 credit per call
1,000 calls$1.00 on the starter pack, $0.40 at volume
No key (MPP or x402)$0.01 per call
Failed callRefunded, never charged

Every response has x-credits-charged and x-credits-remaining headers. Credits never expire. Packs and calculator.

From an AI agent (MCP)

The same call is the finance_fundamentals_get tool on the hosted MCP server, so Claude, Cursor or any MCP client can make it without code. Add the server once:

bash
claude mcp add --transport http groundsocial https://api.groundsocial.dev/mcp

Then ask for it in words (“Key statistics, financial data and earnings history”), or call the tool directly:

json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "finance_fundamentals_get",
    "arguments": {
      "keyword": "NVDA",
      "period": "quarterly"
    }
  }
}

MCP setup for Claude Desktop, Cursor, VS Code and ChatGPT.

Screen on valuation

Compare forwardPE and profitMargins across tickers.

Questions

Quarterly or annual?

Both: pass period.

Keep going

Run it on your own data

One key for Finance and 76 more platforms, over REST or MCP. Free credits on signup, no card.

Finance is a trademark of Yahoo Inc. We are not affiliated with or endorsed by Yahoo Inc.