https://github.com/p1atdev/ndl
National Diet Library, Japan API Client for Deno
https://github.com/p1atdev/ndl
book deno library ndl
Last synced: 5 months ago
JSON representation
National Diet Library, Japan API Client for Deno
- Host: GitHub
- URL: https://github.com/p1atdev/ndl
- Owner: p1atdev
- License: mit
- Created: 2022-06-03T23:13:35.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-08-17T13:42:24.000Z (almost 3 years ago)
- Last Synced: 2024-12-31T09:39:12.016Z (7 months ago)
- Topics: book, deno, library, ndl
- Language: TypeScript
- Homepage: https://deno.land/x/ndl
- Size: 57.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# NDL API Client for Deno
[](https://deno.land/x/ndl)

[](https://velociraptor.run)

[](https://codecov.io/gh/p1atdev/ndl)
[](https://nest.land/package/ndl)Deno 用の国立国会図書館の検索 API クライアント
API 仕様書: https://iss.ndl.go.jp/information/api/riyou/
# Features
- OpenSearch エンドポイント対応
## Usage
### Import
- deno.land: https://deno.land/x/[email protected]/mod.ts
- nest.land: https://x.nest.land/[email protected]/mod.ts### フリーワード検索
```ts
import { OpenSearch } from "https://deno.land/[email protected]/mod.ts";const client = OpenSearch();
const result = await client.search("タコピーの原罪");
console.log(result.count); // 3
const book = result.items[0];
console.log(book.title.value); // "タコピーの原罪"
console.log(book.title.pronounciation); // "タコピー ノ ゲンザイ"console.log(book.volume); // "上"
console.log(book.identifier.find((id) => id.type == "ISBN")?.id); // "9784088830490"
console.log(book.price); // "630円"
```### パラメーター指定検索
一部のパラメーターは配列にして AND 検索することができます。
```ts
const client = OpenSearch();const result = await client.search({
cnt: 5,
title: ["ダンジョン", "飯"],
creator: "九井諒子",
});console.log(result.items.length); // 5
const book = result.items[0];
console.log(book.title.value); // "ダンジョン飯 = DELICIOUS IN DUNGEON"
console.log(book.title.pronounciation); // "ダンジョンメシ"console.log(book.genre); // "漫画"
console.log(book.volume); // "1"
console.log(book.identifier.find((id) => id.type == "ISBN")?.id); // "9784047301535"
console.log(book.price); // "620円"
```資料種を指定することもできます。
```ts
const client = OpenSearch();const result = await client.search({
cnt: 3,
title: "キノの旅",
mediatype: "children", // 児童書
});console.log(result.items.length); // 3
const book = result.items[0];
console.log(book.title.value); // "キノの旅"
console.log(book.title.pronounciation); // "キノ ノ タビ"console.log(book.category); // "児童書"
console.log(book.identifier.find((id) => id.type == "ISBN")?.id); // "4840215855"
console.log(book.price); // "530円"
```指定できるパラメーターの役割については、型定義や
[仕様書](https://iss.ndl.go.jp/information/wp-content/uploads/2022/05/ndlsearch_api_20220520_jp.pdf)
を参考にしてください。## TODO
- プロバイダ型定義
([参考](https://iss.ndl.go.jp/information/wp-content/uploads/2021/12/ndlsearch_api_ap1_20211220_jp.pdf))
- 未対応の返り値パラメーターの対応
([参考](https://www.ndl.go.jp/jp/dlib/standards/meta/2020/12/terms-list.pdf))
- 国会議事録検索
- メタデータ API