Bkper
This is the main entry point of the bkper-js library.
You can configure the library in two ways:
- Using static configuration (traditional approach):
Bkper.setConfig({ apiKeyProvider: () => process.env.BKPER_API_KEY, oauthTokenProvider: () => process.env.BKPER_OAUTH_TOKEN});
const bkper = new Bkper();const book = await bkper.getBook('bookId');- Using per-instance configuration (recommended for Cloudflare Workers):
const bkper = new Bkper({ apiKeyProvider: () => process.env.BKPER_API_KEY, oauthTokenProvider: () => process.env.BKPER_OAUTH_TOKEN});
const book = await bkper.getBook('bookId');Constructors
Constructor
new Bkper(config?): Bkper;Creates a new Bkper instance with the provided configuration.
Parameters
| Parameter | Type | Description |
|---|---|---|
config? | Config | The Config object containing API key and OAuth token providers. If not provided, uses the global configuration set via setConfig(). |
Returns
Bkper
Methods
getApp()
getApp(id): Promise<App>;Gets the [[App]] with the specified id.
Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | The App id (agentId) |
Returns
Promise<App>
The retrieved App
getApps()
getApps(): Promise<App[]>;Gets all [[Apps]] available for the user.
Returns
Promise<App[]>
The retrieved list of Apps
getBook()
getBook( id, includeAccounts?,includeGroups?): Promise<Book>;Gets the [[Book]] with the specified bookId from url param.
Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | The universal book id - The same bookId param of URL you access at app.bkper.com |
includeAccounts? | boolean | Optional parameter to include accounts in the retrieved Book |
includeGroups? | boolean | Optional parameter to include groups in the retrieved Book If both includeAccounts and includeGroups are false, the Book will be returned with only the basic information. If includeAccounts is true, the Book will be returned with the accounts and groups. If includeGroups is true, the Book will be returned with the groups. |
Returns
Promise<Book>
The retrieved Book
getBooks()
getBooks(query?): Promise<Book[]>;Gets all [[Books]] the user has access to.
Parameters
| Parameter | Type | Description |
|---|---|---|
query? | string | Optional search term to filter books |
Returns
Promise<Book[]>
The retrieved list of Books
getCollections()
getCollections(): Promise<Collection[]>;Gets all [[Collections]] the user has access to.
Returns
Promise<Collection[]>
The retrieved list of Collections
getConfig()
getConfig(): Config;Gets the current instance configuration.
Returns
The Config object for this Bkper instance
getTemplates()
getTemplates(): Promise<Template[]>;Gets all [[Templates]] available for the user.
Returns
Promise<Template[]>
The retrieved list of Templates
getUser()
getUser(): Promise<User>;Gets the current logged [[User]].
Returns
Promise<User>
The retrieved User
setConfig()
static setConfig(config): void;Sets the global API configuration for all Bkper operations.
WARNING: This configuration will be shared and should NOT be used on shared environments.
Parameters
| Parameter | Type | Description |
|---|---|---|
config | Config | The Config object containing API key and OAuth token providers |
Returns
void