{"id":22907900,"url":"https://github.com/bynder/bynder-js-sdk","last_synced_at":"2026-05-04T22:02:56.892Z","repository":{"id":22193709,"uuid":"92926095","full_name":"Bynder/bynder-js-sdk","owner":"Bynder","description":"SDK in JavaScript (Node.js) for integration with Bynder","archived":false,"fork":false,"pushed_at":"2025-02-27T16:42:49.000Z","size":2926,"stargazers_count":37,"open_issues_count":12,"forks_count":42,"subscribers_count":63,"default_branch":"master","last_synced_at":"2025-03-28T06:09:35.039Z","etag":null,"topics":["api","integration","javascript","sdk"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Bynder.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-05-31T08:56:39.000Z","updated_at":"2025-02-27T16:00:06.000Z","dependencies_parsed_at":"2024-02-07T12:44:54.423Z","dependency_job_id":"bf1688d8-32f9-485f-8b10-cfed37ba78bb","html_url":"https://github.com/Bynder/bynder-js-sdk","commit_stats":{"total_commits":132,"total_committers":26,"mean_commits":5.076923076923077,"dds":0.696969696969697,"last_synced_commit":"2def77645bd7af6645cf3bbaa77b294b0b56a5bf"},"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bynder%2Fbynder-js-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bynder%2Fbynder-js-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bynder%2Fbynder-js-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bynder%2Fbynder-js-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Bynder","download_url":"https://codeload.github.com/Bynder/bynder-js-sdk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247135144,"owners_count":20889421,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","integration","javascript","sdk"],"created_at":"2024-12-14T03:18:35.152Z","updated_at":"2026-05-04T22:02:56.885Z","avatar_url":"https://github.com/Bynder.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bynder JavaScript SDK\n\n![Tests](https://github.com/Bynder/bynder-js-sdk/workflows/Tests/badge.svg)\n![Publish](https://github.com/Bynder/bynder-js-sdk/workflows/Publish/badge.svg)\n\nThis SDK aims to help the development of integrations with\n[Bynder](https://www.bynder.com/en/) that use JavaScript, providing an easy\ninterface to communicate with\n[Bynder's REST API](https://developer-docs.bynder.com/API/).\n\n## Requirements\n\nTo use this SDK, you will need:\n\n- [Node.js **v12 or above**](https://nodejs.org/) (SDK Version 2.5.0 and above)\n\nNode installation will include [NPM](https://www.npmjs.com/), which is\nresponsible for dependency management.\n\n## Installation\n\n### Node.js\n\n`npm install @bynder/bynder-js-sdk`\n\n`import Bynder from '@bynder/bynder-js-sdk';`\n\n## Usage\n\nThis SDK relies heavily on [Promises](https://developers.google.com/web/fundamentals/getting-started/primers/promises),\nmaking it easier to handle the asynchronous requests made to the API. The SDK\nprovides a `Bynder` object containing several methods which map to the\ncalls and parameters described in\n[Bynder's API documentation](http://docs.bynder.apiary.io/).\n\nThe following snippet is a generic example of how to use the SDK. If you need\ndetails for a specific module, refer to the\n[samples folder](https://github.com/Bynder/bynder-js-sdk/tree/master/samples).\n\nBefore executing any request, you need to authorize the calls to the API:\n\n\n#### Using a permanent token\n```js\nconst bynder = new Bynder({\n  baseURL: \"https//portal.getbynder.com/api/\",\n  permanentToken: \"\u003ctoken\u003e\",\n});\n```\n\n#### Using OAuth2\n\n1. Call the constructor with your configuration\n\n```js\nconst bynder = new Bynder({\n  baseURL: \"https://portal.getbynder.com/api/\",\n  clientId: \"\u003cyour OAuth2 client id\u003e\",\n  clientSecret: \"\u003cyour OAuth2 client secret\u003e\",\n  redirectUri: \"\u003curl where user will be redirected after authenticating\u003e\"\n});\n```\n\n2. Create an authorization URL, login and get one-time authorization code\n\n```js\nconst authorizationURL = bynder.makeAuthorizationURL();\n```\n\n3. Exchange code for an access token\n\n```js\nbynder.getToken(code);\n```\n\nIf you already have an access token, you can also initialize Bynder with the\ntoken directly:\n\n```js\nconst bynder = new Bynder({\n  baseURL: \"http://api-url.bynder.io/api/\",\n  clientId: \"\u003cyour OAuth2 client id\u003e\",\n  clientSecret: \"\u003cyour OAuth2 client secret\u003e\",\n  redirectUri: \"\u003curl where user will be redirected after authenticating\u003e\",\n  token: \"\u003cOAuth2 access token\u003e\"\n});\n```\n\n#### OAuth2 Client Credentials\n\nOAuth application within Bynder needs client credentials grant type. Bynder object can be instantiated without redirectUri provided:\n\n```js\nconst bynder = new Bynder({\n  baseURL: \"http://api-url.bynder.io/api/\",\n  clientId: \"\u003cyour OAuth2 client id\u003e\",\n  clientSecret: \"\u003cyour OAuth2 client secret\u003e\"\n});\n```\n\nTo get a token via client credentials, make a call to `getTokenClientCredentials()`:\n\n```js\nconst bynder = new Bynder({\n  baseURL: \"http://api-url.bynder.io/api/\",\n  clientId: \"\u003cyour OAuth2 client id\u003e\",\n  clientSecret: \"\u003cyour OAuth2 client secret\u003e\"\n});\nconst token = await bynder.getTokenClientCredentials();\n```\n\nSample call can be found within `samples/oauth_client_credentials.js`.\n\n#### Making requests\n\nYou can now use the various methods from the SDK to fetch media, metaproperties\nand other data. Following the Promises notation, you should use\n`.then()`/`.catch()` to handle the successful and failed requests,\nrespectively.\n\nMost of the calls take an object as the only parameter but please refer to the\nAPI documentation to tune the query as intended.\n\n```js\nbynder\n  .getMediaList({\n    type: \"image\",\n    limit: 9,\n    page: 1\n  })\n  .then(data =\u003e {\n    // TODO Handle data\n  })\n  .catch(error =\u003e {\n    // TODO Handle the error\n  });\n```\n\n## Available methods\n\n### Authentication\n\n- `makeAuthorizationURL()`\n- `getToken()`\n- `getTokenClientCredentials()`\n\n### Media\n\n- `getMediaList(queryObject)`\n- `getMediaInfo(queryObject)`\n- `getAllMediaItems(queryObject)`\n- `getMediaTotal(queryObject)`\n- `editMedia(object)`\n- `deleteMedia(id)`\n\n### Media usage\n\n- `getAssetUsage(queryObject)`\n- `saveNewAssetUsage(queryObject)`\n- `deleteAssetUsage(queryObject)`\n\n### Metaproperties\n\n- `getMetaproperties(queryObject)`\n- `getMetaproperty(queryObject)`\n- `saveNewMetaproperty(object)`\n- `editMetaproperty(object)`\n- `deleteMetaproperty(object)`\n- `saveNewMetapropertyOption(object)`\n- `editMetapropertyOption(object)`\n- `deleteMetapropertyOption(object)`\n\n### Collections\n\n- `getCollections(queryObject)`\n- `getCollection(queryObject)`\n- `saveNewCollection(queryObject)`\n- `shareCollection(queryObject)`\n- `addMediaToCollection(queryObject)`\n- `deleteMediaFromCollection(queryObject)`\n\n### Tags\n\n- `getTags(queryObject)`\n\n### Smartfilters\n\n- `getSmartfilters(queryObject)`\n\n### Brands\n\n- `getBrands()`\n\n### Upload\n\n- `uploadFile(fileObject)`\n\n## Contribute to the SDK\n\nIf you wish to contribute to this repository and further extend the API coverage in the SDK, here\nare the steps necessary to prepare your environment:\n\n1. Clone the repository\n2. In the root folder, run `yarn install` to install all of the dependencies.\n3. Create a `secret.json` file with the following structure:\n\n```json\n{\n  \"baseURL\": \"http://api-url.bynder.io/api/\",\n  \"clientId\": \"\u003cyour OAuth2 client id\u003e\",\n  \"clientSecret\": \"\u003cyour OAuth2 client secret\u003e\",\n  \"redirectUri\": \"\u003curl where user will be redirected after authenticating\u003e\"\n}\n```\n\n4. The following gulp tasks are available:\n\n- `gulp lint` - Run ESlint and check the code.\n- `gulp build` - Run webpack to bundle the code in order to run in a browser.\n- `gulp babel` - Run Babel to create a folder 'dist' with ES2015 compatible code.\n- `gulp doc` - Run JSDoc to create a 'doc' folder with automatically generated documentation for the source code.\n- `gulp webserver` - Deploy a web server from the root folder at\n  `localhost:8080` to run the html samples (in order to avoid CORS problems).\n\n## Docker Setup\n\n\nJavaScript files can be executed within a Docker container with corresponding dependencies installed.\n\n### Initial Setup\n\nFrom the root directory create a `secret.json` file. \n\n```json\n{\n  \"baseURL\": \"http://api-url.bynder.io/api/\",\n  \"clientId\": \"\u003cyour OAuth2 client id\u003e\",\n  \"clientSecret\": \"\u003cyour OAuth2 client secret\u003e\"\n}\n```\n\nRun the command `make run-docker` to start up Docker container.\n\nWith the container running, execute the command:\n\n`make executeSdkSample sample-file-name=oauth_client_credentials.js` where sample-file-name is the name of the file within `samples/`. This command will execute the JavaScript file within the container.\n\n### Sample Files\n\nThe `samples/` folder contains various example files demonstrating different SDK functionalities:\n\n#### Upload Examples\n- `upload_client_credentials.js` - Upload a new asset\n- `upload_version_client_credentials.js` - Upload a new version to an existing asset (uses `data.mediaId`)\n- `upload_additional_client_credentials.js` - Upload an additional file to an existing asset (uses `additional: true` and `data.id`)\n\nQA - Run in Docker Container\n\n```sh\n# Build the image (only needed once or after code changes outside samples/ and secret.json)\ndocker build -t jssdk .\n\n# Run a sample with local samples/ and secret.json mounted into the container\ndocker run --rm \\\n  --network=host \\\n  -v $(pwd)/samples:/app/samples \\\n  -v $(pwd)/secret.json:/app/secret.json \\\n  jssdk node samples/tags_client_credentials.js\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbynder%2Fbynder-js-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbynder%2Fbynder-js-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbynder%2Fbynder-js-sdk/lists"}