nlb-ts
v0.0.8
Published
This project is a TypeScript interface with the National Library Board (NLB) Open API.
Maintainers
Readme
NLB Open API Client
This project is a TypeScript interface with the National Library Board (NLB) Open API.
Disclaimer
This project is not affiliated with or endorsed by the National Library Board (NLB) of Singapore.
Client Methods
Catalogue
- getSearchTitles: Searches for titles in the catalogue.
- getTitles: Fetches titles from the catalogue.
- getTitleDetails: Fetches details of a specific title.
- getAvailabilityInfo: Fetches availability information for a title.
- getNewTitles: Fetches new titles.
- getMostCheckoutsTrendsTitles: Fetches titles with the most checkouts trends.
EResource
- searchResources: Searches for e-resources.
- getAvailabilityInfo: Fetches availability information for an e-resource.
Recommendation
- getRecommendationsForTitles: Fetches recommendations for titles.
Library
- getBranches: Fetches library branches.
How to Get the API Key
To use the NLB Open API, you need to obtain an API key. Follow these steps:
- Visit the NLB Labs page.
- Fill in the API key request form with the necessary details.
- Submit the form.
- Once approved, you will receive your API key via email.
Examples
Fetch Catalogue Items
import { NLBClient } from "nlb-ts";
import { env } from "../env";
const client = new NLBClient({
apiKey: env.NLB_API_KEY,
appCode: env.NLB_APP_CODE
});
async function fetchCatalogueItems() {
const data = await client.catalogue.getTitles({
Keywords: "Harry Potter",
});
console.log("Catalogue Items:", data);
}Fetch E-Resources
import { NLBClient } from "nlb-ts";
import { env } from "../env";
const client = new NLBClient({
apiKey: env.NLB_API_KEY,
appCode: env.NLB_APP_CODE
});
async function fetchEResources() {
const data = await client.eresource.searchResources({
Keywords: "E-Book",
});
console.log("E-Resources:", data);
}Fetch Recommendations
import { NLBClient } from "nlb-ts";
import { env } from "../env";
const client = new NLBClient({
apiKey: env.NLB_API_KEY,
appCode: env.NLB_APP_CODE
});
async function fetchRecommendations() {
const data = await client.recommendation.getRecommendationsForTitles({
TitleIds: ["12345"],
});
console.log("Recommendations:", data);
}Fetch Libraries
import { NLBClient } from "nlb-ts";
import { env } from "../env";
const client = new NLBClient({
apiKey: env.NLB_API_KEY,
appCode: env.NLB_APP_CODE
});
async function fetchLibraries() {
const data = await client.library.getBranches({});
console.log("Libraries:", data);
}References
- https://openweb.nlb.gov.sg/api/swagger/Catalogue/swagger.json
- https://openweb.nlb.gov.sg/api/swagger/EResource/swagger.json
- https://openweb.nlb.gov.sg/api/swagger/Recommendation/swagger.json
- https://openweb.nlb.gov.sg/api/swagger/Library/swagger.json
- https://www.nlb.gov.sg/main/partner-us/contribute-and-create-with-us/NLBLabs
