This client is a thin wrapper for the Encephalon API to use in Node.js and the browser.
npm install @encephalon/sdk
encephalon
exposes a single function that takes a single options
object for configuration and returns the client
options
The access token. You can find or create one in your dashboard
Allows custom cache implementation, defaults to memory
A cache entry's time to live in ms, defaults to 3600000
Number of attempts to retry a request if an error occurs, defaults to 2
How long before the request aborts in ms, defaults to 5000
Max concurrent requests, defaults to 3
Duration of delay between requests to avoid API rate limits, defaults to 16
Example
// require encephalon
import encephalon from '@encephalon/sdk';
// create a client with your access token
const client = encephalon({
token: '{YOUR_ACCESS_TOKEN}',
});
// make requests
await client.get(`experiences/${id}`);
await client.post(`experiences/${id}`)
.send({ name: 'hello' });
await client.delete(`experiences/${id}`);
All requests take a string for the API path and return a thenable superagent object. See the Example section above.
await client.all(`experiences`);
await client.get(`experiences/${id}`);
await client.post(`experiences/${id}`)
.send({ name: 'hello' });
await client.delete(`experiences/${id}`);
Ignores the cache and cachebusts the URL
await client.get(`experiences/${id}`)
.cachebust();
For pagination, sets the page number
await client.all(`experiences`)
.page(2);
For pagination, sets quantity per page
await client.all(`experiences`)
.perPage(5);
Sets the token with the passed value. Can also be used as a getter.
client.token('{TOKEN}'); // sets token
const tkn = client.token(); // gets token
Documentation is a WIP
To run the test suite:
- Open a terminal and navigate to the project
- run
npm install
- run
npm test
Please see the package.json engines
for supported environments