Docs menuexpand_more
travel_exploreTry in the API Viewer

Guides

Reference

Other pages

Endpoints

search
appsAll APIs
functionHow metrics are calculated

Cookbook · Basics

Build a watchlist of prices and dividend yields

Write the securities codes and your watchlist of prices and dividend yields refreshes every morning. High yields turn green and big drops turn red, so you can see them at a glance.

Key points

  • check_circleIn Google Sheets, paste the Apps Script and choose Set up. The script creates the sheets and the color rules.
  • check_circleOne call covers up to 50 stocks. Prices and metrics take two calls, 20 tokens in total, so the Free plan can refresh it every day.
  • check_circleYour API key is kept in the script's per-user storage, not in the sheet.
A watchlist of price, 1-day change, dividend yield, PER and PBR, with high yields in green and big drops in red (fictional companies and values)
What you will build (fictional companies and values)

Endpoints to use

Code

Replace YOUR_API_KEY with a key issued in your dashboard. Switch languages with the tabs.

Code example
import pandas as pd
import requests

CODES = ["7203", "8306", "9432"]  # up to 50 per call
HEADERS = {"x-api-key": "YOUR_API_KEY"}


def get(path):
    res = requests.get(f"https://api.zenithcode.net/stable/{path}", params={"symbols": ",".join(CODES)}, headers=HEADERS)
    res.raise_for_status()
    return pd.DataFrame(res.json())


quote = get("batch-quote")[["symbol", "found", "price", "changePct1d", "priceDate"]]
metrics = get("batch-key-metrics-latest")[["symbol", "dividendYield", "per", "pbr", "annualDividend"]]
df = quote.merge(metrics, on="symbol", how="left")

# Highlight rows: yield >= 3.5% in green, 1-day change <= -3% in red (pip install openpyxl jinja2)
styled = df.style.map(lambda v: "background-color: #dff3e6" if pd.notna(v) and v >= 0.035 else "", subset=["dividendYield"]) \
    .map(lambda v: "background-color: #fde4e1" if pd.notna(v) and v <= -0.03 else "", subset=["changePct1d"])
styled.to_excel("watchlist.xlsx", index=False)

How the code works

  1. 1Create a Google spreadsheet and open Extensions > Apps Script. Paste the code from the Google Sheets tab, save, and reload the spreadsheet.
  2. 2Choose ZENITH > Set up in the menu. Allow the Google permission prompt the first time, then paste your API key. The Symbols, Watchlist and Settings sheets are created.
  3. 3Write securities codes in the Symbols sheet (the name column is a free memo). Choose ZENITH > Refresh now to fill the Watchlist sheet.
  4. 4Change the color thresholds in the Settings sheet. Choose ZENITH > Refresh every morning to start the daily refresh.
  5. 5In Excel (Microsoft 365), create a table named Symbols with a column called code and a cell named ApiKey, then paste the code from the Excel tab into a blank query. Add colors with conditional formatting.

Things to note

  • error1-day change and dividend yield come as decimals (0.03 = 3%). The sheet formats them as percentages.
  • errorPrices are the previous trading day's close. Intraday moves are not included.
  • errorIf Excel asks for privacy levels, choose Organizational or Ignore for the data in this workbook.
  • errorSharing the sheet with others counts as providing data to third parties, which the Free and Pro plans do not allow.

FAQ for investors and developers

How many stocks can I list?expand_more

Any number. The script splits calls into groups of 50, so 100 stocks take four calls (prices and metrics), 40 tokens.

Can I add ETFs?expand_more

Yes. Some metrics such as dividend yield can be empty for ETFs.

FAQ for AI builders and researchers

Which endpoints does it use?expand_more

Prices for multiple stocks (/stable/batch-quote) and latest key metrics for multiple stocks (/stable/batch-key-metrics-latest). Both take up to 50 comma-separated securities codes.

What happens with an unknown code?expand_more

It comes back as a row with found set to false. The template shows Not found.

gavel

Disclaimer

This page explains how to use a Japanese equity data API and how its data is defined. It is not a solicitation to invest or a recommendation to buy or sell any security. The content reflects information at the time of writing and is not guaranteed to be accurate or complete. Investment decisions are your own responsibility.

What you may show or provide to third parties depends on your plan and Article 8 of the Terms. Exchange data such as stock prices may not be shown to third parties on any plan. Edited or processed information from which the original stock prices or similar market data can be readily reconstructed is treated as exchange data and may not be displayed or redistributed to third parties. No plan or separate agreement with us overrides this restriction. Terms, Article 8 · Data sources and terms of use