npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

jpx-pdf-parser

v0.1.0

Published

JPX(日本取引所グループ)公式PDF「株式相場表」「銘柄別信用取引残高」のパーサ

Readme

jpx-pdf-parser

JPXが公開している PDFをパースして、構造化されたデータとして取り出すライブラリです。

| 対象 | PDF の URL 例 | 関数 | | --- | --- | --- | | 株式相場表(立会市場 普通取引・発行日決済取引) | https://www.jpx.co.jp/automation/markets/statistics-equities/daily/files/YYYYMM/stq_YYYYMMDD.pdf | parseStockQuotesPdf | | 銘柄別信用取引残高 | https://www.jpx.co.jp/markets/statistics-equities/margin/tvdivq0000001rnl-att/YYYYMMDD_mtall.pdf | parseMarginBalancesPdf |

インストール

  • Node.js 20 以上
  • poppler の pdftotext コマンド
# Debian / Ubuntu
sudo apt install poppler-utils
# macOS
brew install poppler
npm install jpx-pdf-parser

使い方

PDF のダウンロードは行いません。取得した PDF のバイト列(Uint8Array / Buffer)を渡してください。

import { parseMarginBalancesPdf, parseStockQuotesPdf } from 'jpx-pdf-parser';

const res = await fetch('https://www.jpx.co.jp/automation/markets/statistics-equities/daily/files/202610/stq_20261015.pdf');
const pages = await parseStockQuotesPdf(new Uint8Array(await res.arrayBuffer()));

for (const page of pages) {
  console.log(page.tradeDate, page.section, page.pageNumber);
  for (const quote of page.quotes) {
    console.log(quote.code, quote.name, quote.afternoonClose);
  }
}
import { readFile } from 'node:fs/promises';

const pages = await parseMarginBalancesPdf(await readFile('20261015_mtall.pdf'));
const balances = pages.flatMap((page) => page.balances);
console.log(pages[0]?.applicationDate, balances.length);

pdftotext のパスを指定する

PATH 上にない pdftotext を使う場合は、第2引数で指定します。

await parseStockQuotesPdf(pdf, { pdftotextPath: '/opt/poppler/bin/pdftotext' });

抽出済みのテキストをパースする

pdftotext の出力をすでに持っている場合は、テキスト版の関数を使えます(同期関数)。 株式相場表は pdftotext -layout、信用取引残高は pdftotext -raw の出力を渡してください。

import { parseMarginBalancesText, parseStockQuotesText } from 'jpx-pdf-parser';

parseStockQuotesText(layoutText);
parseMarginBalancesText(rawText);

エラー

このライブラリが投げるエラーは isJpxPdfParseError で判定でき、code で種別を見分けられます。

| code | 意味 | | --- | --- | | PDFTOTEXT_NOT_FOUND | pdftotext コマンドが見つからない | | PDFTOTEXT_FAILED | pdftotext の実行に失敗した(PDF として読めない など) | | PARSE_FAILED | 抽出したテキストを想定どおりに解釈できなかった(PDF のレイアウト変更など) |

開発

npm install
npm run lint
npm run typecheck
npm test
npm run build

fixtures/ に JPX の PDF と、同じ日付の softhompo 配信 zip(stq_YYYYMMDD.pdf と stq_YYYYMMDD.zip、YYYYMMDD_mtall.pdf と syumatsuYYYYMMDD00.zip)を置くと、 パース結果を softhompo 形式の CSV に組み立て、md5 が配信 CSV と一致するかを検証するテストが動きます(fixtures/ は git 管理外)。

サンプルコード実行

node --import tsx src/example/parseStockPdf.ts --file fixtures/stq_20261015.pdf

node --import tsx src/example/parseMarginPdf.ts --file fixtures/20261015_mtall.pdf

リリース

# 初回のみ(ログイン済みかは npm whoami で確認)
npm login

# バージョンを上げる(package.json の更新・コミット・タグ作成まで行われる)
npm version patch # または minor / major

# 公開 or npm publish --dry-run
npm publish

git push --follow-tags

ライセンス

MIT