J-Quants CLI

A guide to using the CLI tool jquants for retrieving Japanese stock market data via J-Quants API V2.

Prerequisites

  • Account Registration: An account registration is required to use J-Quants API V2.
  • Plan Selection: Choose one of the following plans to access data: Free, Light, Standard, or Premium. Note that accessible endpoints vary by plan.

Installation

Homebrew (macOS / Linux)

brew install J-Quants/tap/jquants

GitHub Releases

Download the pre-built binary for your platform from the Releases page and place it in a directory on your PATH.

OSArchitectureFile
macOSIntel (x86_64)jquants-{version}-x86_64-apple-darwin.tar.gz
macOSApple Silicon (ARM64)jquants-{version}-aarch64-apple-darwin.tar.gz
Linuxx86_64 (musl)jquants-{version}-x86_64-unknown-linux-musl.tar.gz
LinuxARM64 (musl)jquants-{version}-aarch64-unknown-linux-musl.tar.gz
Windowsx86_64jquants-{version}-x86_64-pc-windows-msvc.zip

Authentication

Recommended: OAuth2 Browser Login

jquants login

Running this command automatically opens a browser. After logging in with your J-Quants account, the API Key is saved to ~/.config/jquants/credentials.json. You do not need to specify the API Key explicitly after this step.

Direct API Key (Alternative)

You can configure the API Key via an environment variable or a .env file.

export JQUANTS_API_KEY=your_api_key_here

Obtain your API Key from the J-Quants Dashboard.

Authentication priority: api_key in ~/.config/jquants/credentials.jsonJQUANTS_API_KEY environment variable → error

Logout

jquants logout

Clears the browser login session and removes ~/.config/jquants/credentials.json.

AI Agent Integration

This tool includes a Skills file for AI Agents (e.g., Claude Code). Install it with one of the following commands.

npx skills add J-Quants/j-quants-cli

Basic Usage

Global Option Placement

--output, --save, and --fields must all be specified before the subcommand.

# ✅ Correct
jquants --output csv eq daily --code 86970
jquants --output json --save out.json eq master

Output Format

Use the --output (-o) flag to select the output format.

FormatDescription
tableTable format (default). Column names are abbreviated.
jsonJSON format. All fields output with full names.
csvCSV format. Also switches automatically when piping.
parquetApache Parquet format. Requires --save.
jquants eq daily --code 86970                       # Table display (default)
jquants --output json eq daily --code 86970         # JSON output (all fields)
jquants --output csv eq master                      # CSV output
jquants --output parquet --save out.parquet eq daily --code 86970  # Save as Parquet

Field Selection

Use --fields (-f) to narrow down the fields to retrieve. Field names use the JSON/CSV key names (API field names), which differ from the abbreviated column names in table display.

# Retrieve only issue code, date, and adjusted close price
jquants -f Date,Code,AdjC eq daily --code 86970

# Save multiple fields as CSV
jquants --output csv --save prices.csv -f Date,Code,Open,High,Low,Close,Volume eq daily --code 86970

How to Check Field Names

Use jquants schema <endpoint> to view the list of available fields (e.g., jquants schema eq.daily). If you specify a field name that does not exist with -f, an error message will list the available fields.

Saving to File

Use --save <PATH> to save output to a file. Combine with --output.

jquants --output csv --save master.csv eq master
jquants --output json --save daily.json eq daily --code 86970
jquants --output parquet --save daily.parquet eq daily --code 86970

Automatic CSV Switch When Piping

When stdout is connected to a pipe (non-TTY detected), output is automatically switched to CSV format even with --output table.

jquants eq master | head -5
jquants eq master | awk -F, '{print $3}'
jquants eq daily --code 86970 | python3 script.py

Command Reference

eq — Equities

Retrieves stock prices, listed issue information, and investor trading data.

SubcommandDescription
masterListed issue information (name, market, sector, etc.)
dailyDaily stock prices (OHLCV, adjusted)
amMorning session OHLCV
minuteMinute-by-minute OHLCV
earnings-calendarScheduled earnings announcement dates
investor-typesTrading by investor type
tradesTick data (trade-by-trade, bulk retrieval)

mkt — Market

Retrieves market data including trading breakdown, margin trading, short selling, and trading calendar.

SubcommandDescription
breakdownTrading breakdown
margin-alertDaily disclosed margin trading balance
margin-interestWeekly margin trading balance
calendarTrading calendar (business days and holidays)
short-ratioShort selling ratio by sector (filter by 33-sector code --s33)
short-sale-reportShort sale balance report (by disclosure date --disc-date, etc.)

fins — Financials

Retrieves financial statements, dividend information, and financial summaries.

SubcommandDescription
detailsFinancial statements (BS / PL / CF). Use --output json for all fields.
dividendDividend information
summaryFinancial summary

idx — Indices

Retrieves daily data for TOPIX and other indices.

SubcommandDescription
daily-topixTOPIX daily bars
dailyDaily bars by index code

deriv — Derivatives

Retrieves daily data for futures and options.

SubcommandDescription
futuresFutures OHLCV
optionsOptions OHLCV
options-225Nikkei 225 options OHLCV

bulk — Bulk Download

Downloads data for multiple issues or long date ranges as GZ-compressed CSV files.

SubcommandDescription
listList of available files for download
getDisplay download URLs or retrieve files

Shell Completion

Use jquants completions to generate shell completion scripts.

jquants completions bash > ~/.config/bash/completions/jquants.bash
# Add to ~/.bashrc
source ~/.config/bash/completions/jquants.bash

Common Mistakes and Solutions

MistakeCorrect UsageReason
jquants eq daily --code 86970 --output csvjquants --output csv eq daily --code 86970--output must come before the subcommand
jquants --save out.csv eq daily --code 86970jquants --output csv --save out.csv eq daily --code 86970--save requires --output csv or json
jquants --output table --save out.txt eq dailyjquants --output csv --save out.csv eq daily--output table cannot be combined with --save
jquants --output parquet eq daily --code 86970jquants --output parquet --save out.parquet eq daily --code 86970Parquet requires --save
Data appears truncated with jquants fins details --code 86970jquants --output json fins details --code 86970Financial statement fields are abbreviated as 'N items' in table format; use JSON to get all data
Looping eq daily --code X for all issuesjquants bulk get --endpoint /equities/bars/daily --date YYYY-MM --downloadUse bulk download for large data sets
Trying to read GZ bulk files directlyDecompress after download with gunzip *.gzBulk files are GZ-compressed
Running API commands without jquants login firstRun jquants login firstMissing credentials will result in an API error

Was this page helpful?