Kontenbase API Node.js Client

This is the Official Node JS API client/library for Kontenbase API. Visit https://kontenbase.com. More information about the product and see documentation at http://kontenbase.com/api for more technical details.

API Documentation
Please check Kontenbase API Reference.
Installation
Node.js
To install kontenbase in a node project:
npm install --save kontenbase
Kontenbase is compatible with Node 10 and above.
Usage
Configure package with your account's API key obtained from your Kontenbase Dashboard.
const { KontenBaseClient } = require('kontenbase')
const kontenbase = new KontenBaseClient({
apiKey: '*******************',
})
Authentication
Use kontenbase auth services for manage your user/customer.
Register
await kontenbase.register({
firstName: 'lucky',
lastName: 'axl',
email: 'luckyaxl@gmail.com',
password: 'strongpasswd',
role: 'authenticated',
})
Response 200 OK:
{ "token": "8868bcf9826f0****" }
Login
await kontenbase.login({
email: 'luckyaxl@gmail.com',
password: 'strongpasswd',
})
Response 200 OK:
{ "token": "8868bcf9826f0****" }
Initiate token with kontenbase.login
for global use, or you can set token on CRUD
operation. see examples.
User Services
Add User To Role
await kontenbase.user.addToRole({
userId: '605a2115a1cedf3fxxxxxxxx',
roleName: 'authenticated',
})
Remove User From Role
await kontenbase.user.removeFromRole({
userId: '605a2115a1cedf3fxxxxxxxx',
})
Get Profile
await kontenbase.user.getProfile()
CRUD Operations
Initiate Record service using table prototype that has been injected with your Table Name.
await kontenbase.login({
email: 'luckyaxl@gmail.com',
password: 'strongpasswd',
})
Create Record
await kontenbase.table('My Table').create({
Name: 'Axl',
Notes: 'I Love You'
})
await kontenbase.table('My Table').create(
{
Name: 'Axl',
Notes: 'I Love You',
},
{
token: '35e7ed2da6b473ec1bc602**********',
},
)
Response 200 OK:
{
Name: 'Axl',
Notes: 'I Love You'
}
Get Record
await kontenbase.table('My Table').find()
Response 200 OK: [
{
_id: '605a151e409d123bf33be5a9',
Name: 'John',
Notes: 'No Code',
},
{
_id: '605a251d7b8678bf681f284e',
Name: 'Jenny',
Notes: 'Ready',
},
]
Get Record by Id
await kontenbase.table('My Table').find({
id: "606d275fd70a65d030b36547"
})
Response 200 OK: [
{
_id: '605a151e409d123bf33be5a9',
Name: 'John',
Notes: 'No Code',
},
{
_id: '605a251d7b8678bf681f284e',
Name: 'Jenny',
Notes: 'Ready',
},
]
Update Record
await kontenbase.table('My Table').update(recordId, {
Name: 'Axl',
Notes: 'Cool'
})
Response 200 OK:
{ Name: 'Axl', Notes: 'Cool' }
Delete Record
await kontenbase.table('My Table').delete('605a251d7b8678bf681f284e')
Response 200 OK:
Interactive documentation
Go to https://kontenbase.com/api to see the interactive API documentation for your Kontenbase project. Once you select a project, click the "JavaScript" tab to see code snippets using Kontenbase. It'll have examples for all operations you can perform against your project using this library.