With our SDKs

Unauthenticated requests

Some resources do not require an authenticated request to be accessible, which means you can access them solely with a BuiltOn API Key.

If you were to list products, here is how you could do it:

const BuiltOn = require('@builton.dev/core-sdk');
const builton = new BuiltOn({
    apiKey: '<builton-api-key>'
});

builton.products.get({ size: 5 }).then((page) => {
    const firstProduct = page.current[0];
    console.log(firstProduct);
});

For more information about the pagination, please visit the Pagination page.

Authenticated requests

Most resources require an authenticated user to be accessible. This is the case of order for example.

To authenticate a user, do the following:

const BuiltOn = require('@builton.dev/core-sdk');

const builton = new BuiltOn({
  bearerToken: '<jwt>',
  apiKey: '<builton-api-key>'
});

const userData = {
  first_name: 'foo',
  last_name: 'bar',
  email: 'foo@bar.com'
};

builton.users.authenticate(userData).then((user) => {
  console.log(user);
});

For more information about the service accounts, please visit the Service account page.

Last updated