bkper-js library is a simple and secure way to access the Bkper REST API on Node.js and modern browsers.
It provides a set of classes and functions to interact with the Bkper API, including authentication, authorization, and data manipulation.
npm i -S bkper-js
or
yarn add bkper-js
or
bun add bkper-js
import { Bkper } from 'bkper-js';
// Set global configuration
Bkper.setConfig({
apiKeyProvider: () => process.env.BKPER_API_KEY,
oauthTokenProvider: () => process.env.BKPER_OAUTH_TOKEN
});
// Create Bkper instance (uses global config)
const bkper = new Bkper();
// Get a book and work with it
const book = await bkper.getBook('your-book-id');
console.log(`Book: ${book.getName()}`);
// List all books
const books = await bkper.getBooks();
console.log(`You have ${books.length} books`);
// Get current user
const user = await bkper.getUser();
console.log(`Logged in as: ${user.getName()}`);