Google Finance API Python API Docs | dltHub
Build a Google Finance API-to-database pipeline in Python using dlt with AI Workbench support for Claude Code, Cursor, and Codex.
Last updated:
Google Finance API is a set of third-party REST endpoints (wrappers around Google Finance pages) that return parsed Google Finance data (quotes, indices, market summaries, news, financials, graphs). The REST API base URL is Common provider base URLs (choose provider): https://www.searchapi.io/api/v1/search (SearchAPI.io); https://api.scrapingdog.com/google_finance (Scrapingdog); https://serpapi.webscrapingapi.com/v1 (WebScrapingAPI/SerpApi wrapper). Note: Google does not publish an official JSON finance REST API — these are wrappers that scrape Google Finance pages. and All requests require an API key (query parameter or Bearer token), provider-specific..
dlt is an open-source Python library that handles authentication, pagination, and schema evolution automatically. dlthub provides AI context files that enable code assistants to generate production-ready pipelines. Install with uv pip install "dlt[workspace]" and start loading Google Finance API data in under 10 minutes.
What data can I load from Google Finance API?
Here are some of the endpoints you can load from Google Finance API:
| Resource | Endpoint | Method | Data selector | Description |
|---|---|---|---|---|
| search_google_finance | https://www.searchapi.io/api/v1/search?engine=google_finance&q={query} | GET | top-level object; lists: markets (object with region keys containing arrays), graph (array), news (array), articles (array), financials.quarterly (array) | Full Google Finance search/quote response (summary, markets, graph, news, financials). |
| google_finance_scrapingdog | https://api.scrapingdog.com/google_finance?api_key={api_key}&query={query} | GET | top-level object; key arrays: market.US (array) in sample; market_news (array) | Scrapingdog wrapper endpoint returning parsed market, news and summary. |
| serpapi_google_finance | https://serpapi.webscrapingapi.com/v1?engine=google_finance&q={query} | GET | top-level object; example arrays: markets.us (array), graph (array), market_news (array), key_events (array) | SerpApi/WebScrapingAPI Google Finance engine returning structured results. |
| knowledge_graph | https://www.searchapi.io/api/v1/search?engine=google_finance&q={query} (with engine param) | GET | knowledge_graph (object) — tags (array), stats (array) | Company/instrument knowledge graph and stats. |
| graph | https://www.searchapi.io/api/v1/search?engine=google_finance&q={query}&window={window} | GET | graph (array) | Historical/graph price points for the queried instrument (window param important for key_events/graph). |
How do I authenticate with the Google Finance API API?
Providers accept an api_key either as a query parameter (api_key or access_key) or as an Authorization: Bearer <API_KEY> header; exact name may vary per provider (e.g., api_key for SearchAPI.io and Scrapingdog).
1. Get your credentials
- Sign up for the chosen provider (SearchAPI.io, Scrapingdog, or WebScrapingAPI/SerpApi). 2) In the dashboard, create or view your API key (labelled api_key or access_key). 3) Copy the key; use it either as ?api_key=YOUR_KEY or in the Authorization header as Bearer YOUR_KEY per provider docs.
2. Add them to .dlt/secrets.toml
[sources.google_finance_api_source] api_key = "YOUR_API_KEY"
dlt reads this automatically at runtime — never hardcode tokens in your pipeline script. For production environments, see setting up credentials with dlt for environment variable and vault-based options.
How do I set up and run the pipeline?
Set up a virtual environment and install dlt:
uv venv && source .venv/bin/activate uv pip install "dlt[workspace]"
1. Install the dlt AI Workbench:
dlt ai init --agent <your-agent> # <agent>: claude | cursor | codex
This installs project rules, a secrets management skill, appropriate ignore files, and configures the dlt MCP server for your agent. Learn more →
2. Install the rest-api-pipeline toolkit:
dlt ai toolkit rest-api-pipeline install
This loads the skills and context about dlt the agent uses to build the pipeline iteratively, efficiently, and safely. The agent uses MCP tools to inspect credentials — it never needs to read your secrets.toml directly. Learn more →
3. Start LLM-assisted coding:
Use /find-source to load data from the Google Finance API API into DuckDB.
The rest-api-pipeline toolkit takes over from here — it reads relevant API documentation, presents you with options for which endpoints to load, and follows a structured workflow to scaffold, debug, and validate the pipeline step by step.
4. Run the pipeline:
python google_finance_api_pipeline.py
If everything is configured correctly, you'll see output like this:
Pipeline google_finance_api_pipeline load step completed in 0.26 seconds 1 load package(s) were loaded to destination duckdb and into dataset google_finance_api_data The duckdb destination used duckdb:/google_finance_api.duckdb location to store data Load package 1749667187.541553 is LOADED and contains no failed jobs
Inspect your pipeline and data:
dlt pipeline google_finance_api_pipeline show
This opens the Pipeline Dashboard where you can verify pipeline state, load metrics, schema (tables, columns, types), and query the loaded data directly.
Python pipeline example
This example loads search_google_finance and graph from the Google Finance API API into DuckDB. It mirrors the endpoint and data selector configuration from the table above:
import dlt from dlt.sources.rest_api import RESTAPIConfig, rest_api_resources @dlt.source def google_finance_api_source(api_key=dlt.secrets.value): config: RESTAPIConfig = { "client": { "base_url": "Common provider base URLs (choose provider): https://www.searchapi.io/api/v1/search (SearchAPI.io); https://api.scrapingdog.com/google_finance (Scrapingdog); https://serpapi.webscrapingapi.com/v1 (WebScrapingAPI/SerpApi wrapper). Note: Google does not publish an official JSON finance REST API — these are wrappers that scrape Google Finance pages.", "auth": { "type": "api_key", "api_key": api_key, }, }, "resources": [ {"name": "search_google_finance", "endpoint": {"path": "api/v1/search"}}, {"name": "google_finance_scrapingdog", "endpoint": {"path": "google_finance"}} ], } yield from rest_api_resources(config) def get_data() -> None: pipeline = dlt.pipeline( pipeline_name="google_finance_api_pipeline", destination="duckdb", dataset_name="google_finance_api_data", ) load_info = pipeline.run(google_finance_api_source()) print(load_info)
To add more endpoints, append entries from the resource table to the "resources" list using the same name, path, and data_selector pattern.
How do I query the loaded data?
Once the pipeline runs, dlt creates one table per resource. You can query with Python or SQL.
Python (pandas DataFrame):
import dlt data = dlt.pipeline("google_finance_api_pipeline").dataset() sessions_df = data.search_google_finance.df() print(sessions_df.head())
SQL (DuckDB example):
SELECT * FROM google_finance_api_data.search_google_finance LIMIT 10;
In a marimo or Jupyter notebook:
import dlt data = dlt.pipeline("google_finance_api_pipeline").dataset() data.search_google_finance.df().head()
See how to explore your data in marimo Notebooks and how to query your data in Python with dataset.
What destinations can I load Google Finance API data to?
dlt supports loading into any of these destinations — only the destination parameter changes:
| Destination | Example value |
|---|---|
| DuckDB (local, default) | "duckdb" |
| PostgreSQL | "postgres" |
| BigQuery | "bigquery" |
| Snowflake | "snowflake" |
| Redshift | "redshift" |
| Databricks | "databricks" |
| Filesystem (S3, GCS, Azure) | "filesystem" |
Change the destination in dlt.pipeline(destination="snowflake") and add credentials in .dlt/secrets.toml. See the full destinations list.
Troubleshooting
Authentication failures
If you receive 401/403, verify you are using the provider API key and the correct header/query parameter (api_key or Authorization: Bearer ) for the chosen provider.
Rate limiting and 429 responses
Providers commonly rate limit scraping endpoints. On HTTP 429 or intermittent 403s implement exponential backoff, respect provider rate limits and consider paid plans or higher concurrency quotas.
Missing or changed JSON keys
These providers parse HTML pages — response JSON keys/structure can change if Google updates its pages. Always check the provider's example response and validate the data_selector (e.g., markets, graph, news). Use defensive parsing (existence checks) in your pipeline.
Pagination and historical windows
Graph/historical data often require a window parameter (e.g., window=MAX) to return full history; otherwise graph may be limited. There is no standard next_page token — use request parameters (date ranges/window) instead.
Ensure that the API key is valid to avoid 401 Unauthorized errors. Also, verify endpoint paths and parameters to avoid 404 Not Found errors.
Next steps
Continue your data engineering journey with the other toolkits of the dltHub AI Workbench:
data-exploration— Build custom notebooks, charts, and dashboards for deeper analysis with marimo notebooks.dlthub-runtime— Deploy, schedule, and monitor your pipeline in production.
dlt ai toolkit data-exploration install dlt ai toolkit dlthub-runtime install
Was this page helpful?
Community Hub
Need more dlt context for Google Finance API?
Request dlt skills, commands, AGENT.md files, and AI-native context.