Searches the National Diet Library of Japan's union catalogue via OpenSearch and SRU APIs. Finds Japanese books, identifiers, library holdings, digitised copies, and IIIF manifests.
Ships in ndl-search. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
NDL Search is run by the National Diet Library, Japan (NDL). One search covers the NDL's own catalogue and many partner databases (NDL's API provider table had 118 rows on 2026-11-20; some rows are NDL's own sub-collections). The API is free and needs no key. It has two search doors:
title = "儒学年表" AND from = "1900"). The answer is the full record in DC-NDL (NDL's metadata format), including which libraries hold a copy and digitised copies.A third service, NDL Digital Collections (dl.ndl.go.jp), shows scans. A digitised book has a PID (persistent ID, a number such as 969133). Some PIDs have a IIIF manifest: a JSON file that image viewers (Mirador, Universal Viewer) can open.
Each statement below says whether we saw it live (dated, JST) or only read it in NDL's documents. references/api_reference.md marks every endpoint, field and filter this way.
000000583552), JP number (43036177), ISBN, CiNii NCID (NIIBibID).For Japanese university libraries (CiNii Books holdings by NCID) use cinii-research. For Chinese biographical data use cbdb-local.
Be gentle: one request at a time. NDL's API help §17-4 says: "We restrict the number of concurrent accesses to prevent server overload. When we receive a large amounts of requests from a particular IP address on a continuous basis, we might block access to the website." The Japanese help adds that no number can be given and asks users to avoid overlapping requests ("多重アクセスが生じないようご対応をお願いいたします"). On 2026-11-20 about one request in five got HTTP 429 ("同時アクセス数の上限に達した…", concurrent-access limit), even with 2.5 s between our requests. The 429s had no Retry-After header. Sometimes it cleared in 15 s; twice it lasted over a minute. Never send requests in parallel.
Only positions 1–500. Neither door gives records after position 500 (NDL spec; seen live for OpenSearch: idx=501 returned zero items). Narrow the search (add a year range, publisher, ndc) instead of paging.
Use SRU for holdings, not OpenSearch. OpenSearch lists catalogue links but does not say which library each link belongs to. SRU with recordSchema=dcndl_v3&recordPacking=xml gives one dcndl:Item per copy: library name, library code, call number(s), and availability when the library sends it.
Keep these apart:
R100000002 = NDL catalogue, R100000136 = CiNii Research. It decides the metadata reuse terms.dcndl:Item/dcndl:holdingAgent (e.g. 東京都立中央図書館, code 1311).dcndl:Item entries with no holding library (a CiNii record, another catalogue). They are not named holdings.REPOSITORY_NO, LIBRARY…) count the whole result set. They never tell you the provider or holder of one record.SRU zero results look like an error. No numberOfRecords; instead <diagnostics>…<message>Record does not exist</message>. Only that message means zero results; any other diagnostic is a real error.
Old and new character forms (學/学). title=儒學年表 and title=儒学年表 returned the same 15 records in the same order (full comparison, 2026-11-20). We tested only this pair; do not assume every variant is merged. If a search finds nothing, try the other form.
Kana readings are searchable (2026-11-20). Titles and names have readings (dcndl:titleTranscription, dcndl:creatorTranscription, katakana). title=ジュガク ネンピョウ found 17 records, title=儒学年表 15: readings match too, so the sets differ a little.
Keep IDs as text, and whole. 000000572864 loses its zeros as a number. An item number can end with an _ part, e.g. R100000092-I2324_418254; keep all of it.
A PID is not a IIIF promise. PID 969133 has a manifest (232 canvases). PID 957484 is "インターネット公開" (open on the internet) but its manifest URL gave 404 (spec reviewer's check, 2026-11-20). Check with the manifest command. Image reuse follows the item's own terms.
NDL counts concurrent requests, probably by network address. Twenty laptops on one Wi-Fi, each "one request at a time", can still be twenty requests at the same moment.
ndl-search/references/samples/ (real NDL responses recorded on 2026-11-20 JST: the search, the SRU record with holdings, the IIIF manifest, a zero result and a 429). They have the same fields as a live answer.Retry-After header, wait at least that long. If there is none, wait about a minute. Do not retry at the same moment as your neighbours.Any tool that can fetch a URL can do this. Send a descriptive User-Agent if your tool allows it (NDL answered without one too, but it is polite). -i shows the status line and headers so you can tell a 429 from zero results. Run one command at a time. Saved copies of all three answers are in ndl-search/references/samples/.
Step 1 — search (OpenSearch).
curl -sS -i -G --max-time 30 -A 'humanities-skills/ndl-search/1.0.0 (+https://github.com/kltng/humanities-skills)' \
'https://ndlsearch.ndl.go.jp/api/opensearch' \
--data-urlencode 'title=儒学年表' --data-urlencode 'publisher=斯文会' --data-urlencode 'cnt=2'
Ready-encoded, for a tool that only takes a URL:
https://ndlsearch.ndl.go.jp/api/opensearch?title=%E5%84%92%E5%AD%A6%E5%B9%B4%E8%A1%A8&publisher=%E6%96%AF%E6%96%87%E4%BC%9A&cnt=2
Read: <openSearch:totalResults> (2 on 2026-11-20). The first <item> was: <dc:title> 日本儒学年表, <guid> https://ndlsearch.ndl.go.jp/books/R100000002-I000000583552 (the end, R100000002-I000000583552, is the item number), <dc:identifier xsi:type="dcndl:JPNO"> 43036177, and <rdfs:seeAlso rdf:resource="https://dl.ndl.go.jp/pid/969133"/> (a scan). The second item is another 1922 edition (R100000002-I000000904179, JPNO 53008244, PID 1913738).
Step 2 — full record with holdings (SRU), using the item number.
curl -sS -i -G --max-time 30 -A 'humanities-skills/ndl-search/1.0.0 (+https://github.com/kltng/humanities-skills)' \
'https://ndlsearch.ndl.go.jp/api/sru' \
--data-urlencode 'operation=searchRetrieve' \
--data-urlencode 'query=itemno="R100000002-I000000583552"' \
--data-urlencode 'recordSchema=dcndl_v3' --data-urlencode 'recordPacking=xml' \
--data-urlencode 'maximumRecords=1'
Ready-encoded: https://ndlsearch.ndl.go.jp/api/sru?operation=searchRetrieve&query=itemno%3D%22R100000002-I000000583552%22&recordSchema=dcndl_v3&recordPacking=xml&maximumRecords=1
Read:
dcndl:BibAdminResource/dcndl:bibRecordCategory = R100000002, dcterms:provenance/…/foaf:name = 国立国会図書館蔵書, dcndl:rights = CC BY 4.0.<dcndl:Item> that has a <dcndl:holdingAgent>: foaf:name (5 on 2026-11-20: 東京都立中央図書館, 神奈川県立図書館, 大阪府立中央図書館, 福岡県立図書館, 国立国会図書館), library code, dcndl:callNumber (NDL also gave two dcndl:localCallNumbers), dcndl:availability (only some libraries send it), and rdfs:seeAlso = that library's catalogue.<dcndl:Item>s had no holding library: a CiNii Research record and a ディープライブラリー record, both with NIIBibID BN03966690. They are source records, not holdings.<dcndl:Item> whose rdfs:seeAlso is https://dl.ndl.go.jp/pid/969133, with dcterms:accessRights インターネット公開 and dcndl:rights PDM (public domain mark).Step 3 — check the scan's IIIF manifest.
curl -sS -i --max-time 30 -A 'humanities-skills/ndl-search/1.0.0 (+https://github.com/kltng/humanities-skills)' \
'https://dl.ndl.go.jp/api/iiif/969133/manifest.json'
Read: status 200, "@type": "sc:Manifest", "label" 日本儒学年表, "attribution" "国立国会図書館 National Diet Library, JAPAN", and the number of entries in sequences[0].canvases (232). A 404 with {"checkResult":"NG"} means no manifest: keep the viewer link https://dl.ndl.go.jp/pid/<PID>.
How to read the status (more in the reference, §1):
| You see | It means |
|---|---|
| 200 and items / records | results |
200, totalResults 0, or SRU Record does not exist | zero results |
429 and 同時アクセス数の上限… | rate-limited: check for a Retry-After header and wait at least that long; with none, wait about a minute; then one retry. In a workshop, see the section above. |
| 200 with an empty body | empty response, cause unknown: wait and retry once |
| 200 with an HTML page or another shape | not an API answer: report it, do not read it as zero results |
202 with x-amzn-waf-action | firewall challenge (not seen at NDL so far): no data; do not loop |
If your tool shows only the body, an empty body cannot tell you why. Report "empty response, cause unknown".
ndl-search/scripts/ndl_search.py — Python 3 standard library only. One request at a time in the whole Python process (all clients share one lock), 2 s apart (our choice, not an NDL number), User-Agent humanities-skills/ndl-search/1.0.0 (+https://github.com/kltng/humanities-skills). On 429 or 503 it retries up to 3 times: it waits Retry-After when given (whole seconds or an HTTP date), else 5, 15, 45 s, and stops when the total wait (including the 2 s spacing) would pass 90 s. Every wait for a host (the spacing, the server's Retry-After, our back-off) is decided and recorded while the client holds its lock, so another caller in the same Python process cannot send to that host in between, and no call waits more than 90 s in total. After the client gives up, it sends nothing more to that host until the wait has passed. When NDL gave no Retry-After, that pause is 60 s: our client's choice, not something NDL asked for. It cannot control other people on your network, who share the limit.
Command line, run from the repository root (--json for machine output, --raw adds the original XML/JSON text):
python3 ndl-search/scripts/ndl_search.py search 日本儒學年表
python3 ndl-search/scripts/ndl_search.py search --title 儒学年表 --publisher 斯文会 --from 1922 --until 1922
python3 ndl-search/scripts/ndl_search.py search --isbn 9784844702368
python3 ndl-search/scripts/ndl_search.py sru 'title="儒学年表" AND from="1900" AND until="1950"' --max 2 --only-bib
python3 ndl-search/scripts/ndl_search.py record R100000002-I000000583552
python3 ndl-search/scripts/ndl_search.py record --jpno 43036177
python3 ndl-search/scripts/ndl_search.py manifest 969133
python3 ndl-search/scripts/ndl_search.py provider R100000136
python3 ndl-search/scripts/ndl_search.py search 儒学 --cnt 1 --json
search uses OpenSearch (--title --creator --publisher --isbn --ndc --from --until --dpid --mediatype --cnt --idx). sru takes a CQL query (--start --max --schema dcndl_v3|dcndl --only-bib; with --only-bib holdings are "not requested", not zero). record takes a complete item number, a permalink (https://ndlsearch.ndl.go.jp/books/… or the English https://ndlsearch.ndl.go.jp/en/books/…), --jpno or --isbn and prints holdings, other source records and digitised copies. manifest checks a PID (a number, info:ndljp/pid/…, or a viewer URL such as https://dl.ndl.go.jp/pid/969133/1/15). provider looks up a repository number or dpid in the table copy, with the table's notes (no network). Exit code 0 = results or zero results; 1 = rate-limited, unavailable or error.
search with the title (try both 學 and 学 forms, or the kana reading if it fails). Pick the record by date and publisher; note the item number at the end of the permalink.record <item number>: read holdings (library, call numbers, availability if given), other source records, and digitised copies (PID, every access-rights value, item rights, call number). Read each copy's rights statements: a record can have CC0 metadata while its source says reuse of the material needs an application (九大コレクション R100000092-I2324_418254, seen 2026-11-20).manifest <PID>: if status ok, give the manifest URL; if not, give the viewer link.effective_terms from the record's provider. Read any provider-table note it shows: some notes add conditions (J-STAGE abstracts may not be reused; Kobe's terms vary by collection).dcndl_v3 + recordPacking=xml for SRU (the client's default). dcndl also works; v3 adds the provider name and a rights URI.dpid=ndl-dl filters results; it does not tell you who made a record.import sys
sys.path.insert(0, "ndl-search/scripts") # run from the repository root
import ndl_search # distinct name: works in one notebook with cinii_research
from ndl_search import NDLSearch
api = NDLSearch() # 2 s between requests, retries on 429/503
def usable(env):
"""Stop at the first answer that is not usable (rate-limited, unavailable, error)."""
if env["status"] not in ("ok", "zero"):
print("stopped:", env["status"], env.get("error"), "| retry at:", env.get("retry_at"))
sys.exit(1)
return env
env = usable(api.search(title="儒学年表", publisher="斯文会", from_="1922", until="1922", cnt=5))
print(env["status"], env["total"], env["next_start"]) # ok 2 None
if env["status"] == "zero":
sys.exit("nothing found")
for it in env["items"]:
print(it["source_id"], it["title"], it["date"], it["identifiers"])
recs = usable(api.record(env["items"][0]["source_id"])) # SRU, dcndl_v3
if not recs["items"]:
sys.exit("record not found")
rec = recs["items"][0]
for h in rec["holdings"]:
print(h["library"], h["library_code"], h["call_numbers"], h["availability"])
for s in rec["source_records"]:
print("source record:", s["repository_name"], s["item_id"], s["identifiers"])
print(rec["provider"]["name"], rec["provider"]["effective_terms"]["text"])
for d in rec["digital_copies"]:
print(d["pid"], d.get("access_rights"), d.get("rights"))
m = api.manifest(d["pid"])
if m["status"] != "ok" and m.get("http_status") != 404:
usable(m) # rate-limited, 503, error: stops here
# "unavailable" with HTTP 404 just means: no manifest for this PID; keep the viewer link
print(" manifest:", m["status"], m.get("title"), m.get("canvas_count"), m.get("error", ""))
Every result is a plain dict.
Search envelope (search, sru, record): always status (ok, zero, unavailable, rate_limited, error), total (None when unknown), start (1-based, also on failure), count (items returned), items, next_start, request_url. On failure also error. Conditional keys (use env.get(...)): http_status (only when an HTTP answer came back); retry_after (seconds, or None when unknown) and retry_at (UTC time or unknown) only for rate_limited/unavailable caused by a 429/503 or a hold — not, for example, for a manifest 404; raw only with raw=True; note, facets, facets_note only where they apply. manifest() returns status, pid, viewer, links, request_url, and title, canvas_count, iiif_version (plus attribution, license when present) only when status is ok.
Item fields from both doors (OpenSearch and SRU): source_id (complete item number), title, title_reading, creators, creator_readings, publishers, date, issued, extent, identifiers (list of {type, value}, all strings), links (list of {role, url}; roles: permalink, viewer, opac, source_record, authority; iiif_manifest only from manifest() after the JSON was checked), provider (repository_no, evidence, name, record_rights, table_terms, candidates, effective_terms with basis and notes), digital_copies, holdings, source_records, status.
Only SRU fills these (OpenSearch items have holdings and source_records set to None, and their digital_copies have only pid, viewer, manifest_to_try): holdings (library, library_code, call_numbers, local_call_numbers, availability (may be None), access_rights, rights_statements, links, identifiers), holdings_summary (or holdings_note when only-bib), source_records, the full digital_copies entries (access_rights — every value, rights (dcndl:rights URI), rights_statements (every dcterms:rights text or guidance URL, any language), call_numbers, doi, collection, item_id), date_display, language, descriptions, material_types, position, and provider.record_rights / provenance_name (v3). Per-copy rights_statements and access_rights are about the material or the copy; effective_terms is about the metadata. Keep them apart. Also SRU only: material_access_rights (access conditions given for the whole record, e.g. インターネット公開 on R100000039-I1000732, each with its source); the same list is copied onto the digital copy whose PID the record links. If min_interval is longer than wait_budget, a call returns status: rate_limited with limited_by: "client", retry_after and no request sent. api.sru_all(query) follows pages up to 500 records and marks partial: True if a later page fails.
Retry-After (see above). The client's 5/15/45 s backoff sometimes is not enough; then it reports rate_limited — wait a few minutes.error: network error ….any is loose. search 日本儒學年表 also found 日本漢学年表. Use --title for precision.isbn is always exact (NDL spec).andy) can break a query. NDL's spec writes such queries with spaces around = and the value in quotes: title = "andy". The client's cql() builder does this.dpid alone is not allowed (NDL spec); add a search field.R100000039 (NDL Digital Collections) has providers with different terms; the record's own dcndl:rights decides. R100000001 (public library holdings) is not in the provider table: terms unknown.dcterms:issued in OpenSearch can be 大正8; SRU gives both dcterms:issued (1919) and dcterms:date (大正8).references/api_reference.md — endpoints, parameters, field paths, paging, errors, evidence marks.references/samples/ — real NDL answers recorded 2026-11-20 JST, for offline work.scripts/ndl_search.py — client and command line; scripts/ndl_providers.json — copy of the provider table with its notes (2026-11-20 JST).Report a problem. This skill is part of the public repository kltng/humanities-skills. If it fails (an API changed, a script errors, or these instructions are wrong), report it as a GitHub issue:
gh issue list --repo kltng/humanities-skills --state all --search "ndl-search"gh issue create --repo kltng/humanities-skills --label bug --title "[ndl-search] <short summary>" --body "<details>". Without gh, give the user this link: https://github.com/kltng/humanities-skills/issues/new?template=skill-problem.ymlCredit the source. The data and the API come from NDL Search (国立国会図書館サーチ), run by the National Diet Library, Japan (https://ndlsearch.ndl.go.jp). NDL's API help says: "You must credit NDL Search API, on a website or application using the API. Also, you must credit the metadata providing database and institution in the case that credit is needed." (API help §17-4). For NDL's own bibliographic data, NDL's quick guide says it "営利・非営利の目的を問わず、どなたでも無償で利用することができます" (anyone may use it free, for profit or not), asks for a source note in the form "出典:国立国会図書館書誌データ(○年○月○日に取得)", and asks you to say so when you have edited or processed the data. For data made by others it says: "出典の表示方法も含めてその提供元の定める利用条件に従ってください" (follow the provider's own terms, including how to credit them); the terms of each provider, with notes, are in the provider table (for example, CiNii Research records need an application for commercial use). These terms cover metadata only; images in NDL Digital Collections follow each item's own terms (see reproduction and reuse). We found no prescribed scholarly citation sentence on the API help, quick guide or provider pages (checked 2026-11-20 JST); cite the record by its permalink and identifiers, and a scan by its PID.
Cite. If this skill helped work that is published, please cite it, together with the source credited above:
Tang, Kwok-leong. humanities-skills: ndl-search (version ). GitHub, . https://github.com/kltng/humanities-skills
When you help a user write up results that relied on this skill, remind them once about this citation and the credit above.
references/api_reference.md (opens in a new tab)references/samples/2026-11-20_http429_rate-limited.xml (opens in a new tab)references/samples/2026-11-20_http429_rate-limited.xml.headers.txt (opens in a new tab)references/samples/2026-11-20_iiif_manifest_969133.json (opens in a new tab)references/samples/2026-11-20_iiif_manifest_969133.json.headers.txt (opens in a new tab)references/samples/2026-11-20_opensearch_title-jugaku-nenpyo_publisher-shibunkai.xml (opens in a new tab)references/samples/2026-11-20_opensearch_title-jugaku-nenpyo_publisher-shibunkai.xml.headers.txt (opens in a new tab)references/samples/2026-11-20_opensearch_zero-results.xml (opens in a new tab)references/samples/2026-11-20_sru_itemno-R100000002-I000000583552_dcndl_v3.xml (opens in a new tab)references/samples/2026-11-20_sru_itemno-R100000002-I000000583552_dcndl_v3.xml.headers.txt (opens in a new tab)references/samples/2026-11-20_sru_zero-results.xml (opens in a new tab)scripts/__init__.py (opens in a new tab)scripts/ndl_providers.json (opens in a new tab)scripts/ndl_search.py (opens in a new tab)tests/fixtures/2026-11-20_opensearch_dpid-ARinternet_title-jugaku-nenpyo_cnt-2.xml (opens in a new tab)tests/fixtures/2026-11-20_sru_isbn-400430105X_dcndl_v3.xml (opens in a new tab)tests/fixtures/2026-11-20_sru_itemno-R100000002-I000000583552_dcndl_v3_string.xml (opens in a new tab)tests/fixtures/2026-11-20_sru_itemno-R100000039-I1000732_dcndl.xml (opens in a new tab)tests/fixtures/2026-11-20_sru_itemno-R100000092-I2324_418254_dcndl_v3.xml (opens in a new tab)tests/fixtures/2026-11-20_sru_title-jugaku-nenpyo_dcndl_string.xml (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
japanese-library, national-diet-library, bibliographic-search, iiif, cql
/ndl-search:ndl-searchfrom ndl-search
npx claudepluginhub kltng/humanities-skills --plugin ndl-searchOther plugins' skills for the same job