npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@bynder/bynder-js-sdk

v2.3.9

Published

Bynder Javascript SDK

Downloads

7,482

Readme

Bynder JavaScript SDK

Tests Publish

This SDK aims to help the development of integrations with Bynder that use JavaScript, providing an easy interface to communicate with Bynder's REST API.

Requirements

To use this SDK, you will need:

Node installation will include NPM, which is responsible for dependency management.

Installation

Node.js

npm install @bynder/bynder-js-sdk

import Bynder from '@bynder/bynder-js-sdk';

Usage

This SDK relies heavily on Promises, making it easier to handle the asynchronous requests made to the API. The SDK provides a Bynder object containing several methods which map to the calls and parameters described in Bynder's API documentation.

The following snippet is a generic example of how to use the SDK. If you need details for a specific module, refer to the samples folder.

Before executing any request, you need to authorize the calls to the API:

Using a permanent token

const bynder = new Bynder({
  baseURL: "https//portal.getbynder.com/api/",
  permanentToken: "<token>",
});

Using OAuth2

  1. Call the constructor with your configuration
const bynder = new Bynder({
  baseURL: "https://portal.getbynder.com/api/",
  clientId: "<your OAuth2 client id>",
  clientSecret: "<your OAuth2 client secret>",
  redirectUri: "<url where user will be redirected after authenticating>"
});
  1. Create an authorization URL, login and get one-time authorization code
const authorizationURL = bynder.makeAuthorizationURL();
  1. Exchange code for an access token
bynder.getToken(code);

If you already have an access token, you can also initialize Bynder with the token directly:

const bynder = new Bynder({
  baseURL: "http://api-url.bynder.io/api/",
  clientId: "<your OAuth2 client id>",
  clientSecret: "<your OAuth2 client secret>",
  redirectUri: "<url where user will be redirected after authenticating>",
  token: "<OAuth2 access token>"
});

Making requests

You can now use the various methods from the SDK to fetch media, metaproperties and other data. Following the Promises notation, you should use .then()/.catch() to handle the successful and failed requests, respectively.

Most of the calls take an object as the only parameter but please refer to the API documentation to tune the query as intended.

bynder
  .getMediaList({
    type: "image",
    limit: 9,
    page: 1
  })
  .then(data => {
    // TODO Handle data
  })
  .catch(error => {
    // TODO Handle the error
  });

Available methods

Authentication

  • makeAuthorizationURL()
  • getToken()

Media

  • getMediaList(queryObject)
  • getMediaInfo(queryObject)
  • getAllMediaItems(queryObject)
  • getMediaTotal(queryObject)
  • editMedia(object)
  • deleteMedia(id)

Media usage

  • getAssetUsage(queryObject)
  • saveNewAssetUsage(queryObject)
  • deleteAssetUsage(queryObject)

Metaproperties

  • getMetaproperties(queryObject)
  • getMetaproperty(queryObject)
  • saveNewMetaproperty(object)
  • editMetaproperty(object)
  • deleteMetaproperty(object)
  • saveNewMetapropertyOption(object)
  • editMetapropertyOption(object)
  • deleteMetapropertyOption(object)

Collections

  • getCollections(queryObject)
  • getCollection(queryObject)
  • saveNewCollection(queryObject)
  • shareCollection(queryObject)
  • addMediaToCollection(queryObject)
  • deleteMediaFromCollection(queryObject)

Tags

  • getTags(queryObject)

Smartfilters

  • getSmartfilters(queryObject)

Brands

  • getBrands()

Upload

  • uploadFile(fileObject)

Contribute to the SDK

If you wish to contribute to this repository and further extend the API coverage in the SDK, here are the steps necessary to prepare your environment:

  1. Clone the repository
  2. In the root folder, run yarn install to install all of the dependencies.
  3. Create a secret.json file with the following structure:
{
  "baseURL": "http://api-url.bynder.io/api/",
  "clientId": "<your OAuth2 client id>",
  "clientSecret": "<your OAuth2 client secret>",
  "redirectUri": "<url where user will be redirected after authenticating>"
}
  1. The following gulp tasks are available:
  • 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 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:8080 to run the html samples (in order to avoid CORS problems).