{"id":14986731,"url":"https://github.com/kkbox/openapi-javascript","last_synced_at":"2025-06-23T17:09:28.753Z","repository":{"id":26486372,"uuid":"108073130","full_name":"KKBOX/OpenAPI-JavaScript","owner":"KKBOX","description":"KKBOX Open API SDK for JavaScript.","archived":false,"fork":false,"pushed_at":"2022-12-07T17:31:22.000Z","size":2985,"stargazers_count":68,"open_issues_count":4,"forks_count":8,"subscribers_count":48,"default_branch":"master","last_synced_at":"2025-06-13T23:36:03.647Z","etag":null,"topics":["kkbox","openapi","sdk"],"latest_commit_sha":null,"homepage":"https://developer.kkbox.com/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KKBOX.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-24T03:40:50.000Z","updated_at":"2025-02-06T04:00:23.000Z","dependencies_parsed_at":"2023-01-14T04:45:57.179Z","dependency_job_id":null,"html_url":"https://github.com/KKBOX/OpenAPI-JavaScript","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/KKBOX/OpenAPI-JavaScript","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KKBOX%2FOpenAPI-JavaScript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KKBOX%2FOpenAPI-JavaScript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KKBOX%2FOpenAPI-JavaScript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KKBOX%2FOpenAPI-JavaScript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KKBOX","download_url":"https://codeload.github.com/KKBOX/OpenAPI-JavaScript/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KKBOX%2FOpenAPI-JavaScript/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261519039,"owners_count":23171228,"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":["kkbox","openapi","sdk"],"created_at":"2024-09-24T14:13:25.963Z","updated_at":"2025-06-23T17:09:28.722Z","avatar_url":"https://github.com/KKBOX.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# KKBOX Open API Developer SDK for JavaScript\n\n[![npm (scoped)](https://img.shields.io/npm/v/@kkbox/kkbox-js-sdk.svg)](https://www.npmjs.com/package/@kkbox/kkbox-js-sdk)\n[![Build Status](https://travis-ci.org/KKBOX/OpenAPI-JavaScript.svg?branch=master)](https://travis-ci.org/KKBOX/OpenAPI-JavaScript)\n[![License Apache](https://img.shields.io/badge/license-Apache-green.svg?style=flat)](https://raw.githubusercontent.com/KKBOX/OpenAPI-JavaScript/master/LICENSE.txt)\n\nThe SDK helps you to access various metadata from KKBOX, including tracks, albums, artists, playlists and stations.\n\n## Getting Started\n\nInstall the SDK using npm\n\n```bash\n$ npm install @kkbox/kkbox-js-sdk\n```\n\n## Usage example\n```js\nimport { Auth, Api } from '@kkbox/kkbox-js-sdk';\n\n// Create an auth object with client id and secret\nconst auth = new Auth(client_id, client_secret);\n\n// Fetch your access token\nauth.clientCredentialsFlow\n  .fetchAccessToken()\n  .then(response =\u003e {\n    const access_token = response.data.access_token;\n\n    // Create an API object with your access token\n    const api = new Api(access_token);\n\n    // Fetch content with various fetchers\n    api.searchFetcher\n      .setSearchCriteria('五月天 派對動物', 'track')\n      .fetchSearchResult()\n      .then(response =\u003e {\n\n        // Content from the KKBOX Open API\n        console.log(response.data);\n\n        // Continue to the next page\n        api.searchFetcher.fetchNextPage(response).then(response =\u003e {\n          console.log(response.data);\n        });\n\n      });\n  });\n```\n\n## Test\n\nTo test the SDK, a valid client ID and client secret are required.\n\nPlease visit [https://developer.kkbox.com/](https://developer.kkbox.com/), create a new developer account, and obtain the client ID and client secret of your app.\n\nThen, create a file named `client_secrets.json`, put it into the `test` directory, and fill your client ID and client secret into it.\n\nIt may look like\n\n```json\n{\n  \"kkbox_sdk\": {\n    \"client_id\": \"YOUR CLIENT ID\",\n    \"client_secret\": \"YOUR CLIENT SECRET\"\n  }\n}\n```\n\nRun the test:\n``` bash\n$ npm test\n```\n\n## Documentation\n\nSee [https://kkbox.github.io/OpenAPI-JavaScript/](https://kkbox.github.io/OpenAPI-JavaScript/) for full documentation.\n\n## Use the SDK in Web Browsers\n\nThe SDK plays fine with Node.js, but works partially in web browsers.\n\nYou can use the SDK in your Web and [Electron](https://electronjs.org) apps, but you need to prepare a middle man server to help you to obtain access tokens. That's because KKBOX's Open API server supports [Cross-Origin Resource Sharing (CORS)](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS), but the Auth server does not.\n\nIn other words, your JavaScript code hosted on your own website could access data from KKBOX, but direct access to the Auth server is forbidden by the security policy of modern web browsers.\n\nWhen developing an Electron app, you can choose to turn web security off to make you app able to fetch access tokens. You can do this while creating browser windows.\n\n```js\nmainWindow = new BrowserWindow({\n  width: 500,\n  height: 500,\n  useContentSize: true,\n  webPreferences: {\n    webSecurity: false\n  }\n});\n```\n\n## License\n\nCopyright 2018 KKBOX Technologies Limited\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkkbox%2Fopenapi-javascript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkkbox%2Fopenapi-javascript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkkbox%2Fopenapi-javascript/lists"}