In order to use this SDK, the only thing needed is an updated version of Node.js:
Node installation will include NPM, which is responsible for the dependencies management.
npm install @bynder/bynder-js-sdk
import Bynder from '@bynder/bynder-js-sdk';
- Checkout the repository
git clone firstname.lastname@example.org:Bynder/bynder-js-sdk.git.
- Go to the
- Use the
bundle.jsfile generated in
distfolder to use the SDK in the browser.
- Include it in your page like this:
- Define the constructor like this:
const Bynder = Bynder.default;
As said before, this SDK relies heavily on Promises, making it easier to handle the asynchronous requests made to the API.
Besides that, it provides a
Bynder object containing several methods corresponding to the calls to be performed, which accept the parameters exactly according Bynder's API documentation.
This is a generic example of how to use the SDK, if you need specific details for a specific module, refer to samples folder.
Before executing any request, you need to call the constructor passing your credentials as parameters, making it possible to authorize the calls to the API:
const bynder =consumer:public: "<public_consumer_key>"secret: "<secret_consumer_key>"accessToken:public: "<public_access_key>"secret: "<secret_access_key>"baseURL: "";
From this point on, you just need to call the methods made available to call the API and retrieve the data your looking for. Following the Promises notation, you should use
.then()/.catch() to handle respectively the successful and failed requests.
Except for some special cases, most of the calls only take an object as parameter. After that, you'll need to refer to the API to tune the query as intended.
Here's a list of all the methods available, separated by module:
Contribute to the SDK
If you wish to contribute to this repository and further extend the API coverage of the SDK, here are the steps necessary to prepare your environment:
- Clone the repository
- In the root folder, run
npm installto install all the dependencies.
- Use the file named 'secret.json' for the tokens with this structure:
- Use any of these gulp tasks to:
gulp lint- Run ESlint and check the code.
gulp build- Run webpack to bundle the code in order to run in a browser.
gulp babel- Run Babel to create a folder 'dist' with ES2015 compatible code.
gulp jasmine- Run Jasmine for all the spec files inside 'tests'.
gulp doc- Run JSDoc to create a 'doc' folder with automatically generated documentation for the source code.
gulp webserver- Deploy a web server from the root folder at
localhost:8080to run the html samples (in order to avoid CORS problems).