With our SDKs
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:
Core SDK
Node SDK
Python SDK
HTTP
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);
});
// The Node SDK, although similar to the Core SDK, is intended for server-to-server communication.
const BuiltOn = require('@builton.dev/node-sdk');
const builton = new BuiltOn({
apiKey: '<builton-api-key>'
});
builton.products.get({ size: 5 }).then((page) => {
const firstProduct = page.current[0];
console.log(firstProduct);
});
# The Python is intended for server-to-server communication.
from builton_sdk import Builton
builton = Builton(api_key="<builton-api-key>")
builton.product().get_all(size=5)
GET /products HTTP/1.1
Content-Type: application/json
X-Builton-Api-Key: <builton-api-key>
Host: api.builton.dev
Most resources require an authenticated user to be accessible. This is the case of order for example.
To authenticate a user, do the following:
Core SDK
HTTP
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: '[email protected]'
};
builton.users.authenticate(userData).then((user) => {
console.log(user);
});
POST /users HTTP/1.1
Content-Type: application/json
Authorization: Bearer <jwt>
X-Builton-Api-Key: <builton-api-key>
Host: api.builton.dev
{
"first_name": "foo",
"last_name": "bar",
"email": "[email protected]",
}
Last modified 2yr ago