1.1.16 • Published 2 years ago
@showell-labs/api-client v1.1.16
Showell Api Client
Showell Api Client is a library for connecting to Showell HTTP APIs. The Api Client provides actually multiple clients, including a generic Service client and Service-specific clients.
Using Api Client
The Service Client provides an exec
method that accepts arguments endpoint
and params
.
import initialize from 'showell-api-client';
// Initialize API with valid Access Token
const api = initialize({ accessToken: 'ad1b...' });
api
.client('service')
.exec('file-system/find', {
query: "[name='HelloWorld.pdf']",
specs: { name: true },
})
.then(file => console.log(file.name));
Using Service-specific Client
The Service-specific Clients often provide a more developer-friendly access to the service APIs.
api
.client('file-system')
.find({
query: "[name='HelloWorld.pdf']",
specs: { name: true },
})
.then(file => console.log(file.name));
Service-specific clients are not available for all services.
Alternative authentication using username/password
const api = initialize();
await api.authenticate({ username: 'my-user', password: 'adxG...' });
Other features
If you have a need to do a direct call to Showell services and there's no client available, you can also import fetchApi implementation from package. It will set correct headers based on crrect params.
//