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

How to scrape stock fundamentals with Go

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

The examples use only the standard library (net/http, encoding/json) and decode into a struct that names just the fields they read.

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 Gogo mod init example

Call Stock fundamentals API from Go

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

main.go
package main

import (
	"encoding/json"
	"fmt"
	"log"
	"net/http"
	"net/url"
	"os"
	"time"
)

// The fields this program reads, as the recorded response has them.
type Page struct {
	Earnings []map[string]any `json:"earnings"`
}

var client = &http.Client{Timeout: 60 * time.Second}

func fetch(q url.Values) (*Page, error) {
	req, err := http.NewRequest("GET", "https://api.groundsocial.dev/v1/finance/fundamentals"+"?"+q.Encode(), nil)
	if err != nil {
		return nil, err
	}
	req.Header.Set("Authorization", "Bearer "+os.Getenv("GROUNDSOCIAL_API_KEY"))
	res, err := client.Do(req)
	if err != nil {
		return nil, err
	}
	defer res.Body.Close()
	if res.StatusCode != http.StatusOK {
		var e struct {
			Error struct {
				Code      string `json:"code"`
				Hint      string `json:"hint"`
				Retryable bool   `json:"retryable"`
			} `json:"error"`
		}
		json.NewDecoder(res.Body).Decode(&e)
		return nil, fmt.Errorf("%s: %s", e.Error.Code, e.Error.Hint)
	}
	var page Page
	if err := json.NewDecoder(res.Body).Decode(&page); err != nil {
		return nil, err
	}
	return &page, nil
}

func main() {
	q := url.Values{}
	q.Set("keyword", "NVDA")
	q.Set("period", "quarterly")
	page, err := fetch(q)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", page)
}

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
// fetch returns the API error as "code: hint". To retry the retryable ones
// (rate_limited, upstream_timeout), wait for Retry-After and call again:
for attempt := 0; attempt < 3; attempt++ {
	page, err = fetch(q)
	if err == nil {
		break
	}
	time.Sleep(2 * time.Second)
}
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.