Tutorial for the Image API SDK

The SDK (Software Development Kit) simplifies using the image API by wrapping the request state machine. To optimize an image, all you need is a valid API token. Here we have created a tutorial in three steps to get it up and running!


  • A token and domain to make requests to the API, see the quick start guide
  • Latest versions of npm and nodejs installed. Check here for installation


Note that you can also check out the repo at https://gitlab.zunzun.se/public-items/toilmore-sdk/tree/develop/javascript

Step 1. Create a directory

$ mkdir toilmore
$ cd toilmore

Step 2. Install

npm install --save-dev @shimmercat/toilmore-sdk

This will create a directory which looks similar to:

├── node_modules
│   └── @shimmercat
│       └── toilmore-sdk
│           ├── index.js
│           ├── lib
│           │   ├── api_config.js
│           │   ├── http_requester.js
│           │   ├── stream_helpers.js
│           │   └── submit_machine.js
│           ├── package.json
│           └── README.md
└── package-lock.json

4 directories, 8 files
$ cd node_modules/@shimmercat/toilmore-sdk/
$ npm link 
$ npm install . 
$ npm link '@shimmercat/toilmore-sdk'

Ready to take it for a spin!

Depending on the preferred API (Light or Lux), create a .js file to process any image that you want. Just make sure to provide a valid authentication token as the api_token and its related domain as the ‘domain’.

  • Light API

If you plan to use the Light API, open the file light.js using for example vim.

$ vim light.js
  • Lux API

If you plan to use the Lux API, open the file lux.js using for example vim.

$ vim lux.js

Before running the js-file, check the documentation for examples on how to configure it according to your needs, and then simply run it with:

$ node <file_name>.js