All Projects → KKBOX → Openapi Javascript

KKBOX / Openapi Javascript

Licence: apache-2.0
KKBOX Open API SDK for JavaScript.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Openapi Javascript

Tinvest
Тинькофф Инвестиции, tinkoff, python, aiohttp, requests, pydantic
Stars: ✭ 115 (+79.69%)
Mutual labels:  openapi, sdk
Openapi Generator
OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
Stars: ✭ 10,634 (+16515.63%)
Mutual labels:  openapi, sdk
Connect Api Specification
This repository contains the OpenAPI specification as well as templates for generating SDKs for Square's APIs
Stars: ✭ 56 (-12.5%)
Mutual labels:  openapi, sdk
Aliyun Sdk Js
阿里云 SDK for Javascript,支持在浏览器和 Nodejs 环境使用,支持大部分阿里云服务。
Stars: ✭ 727 (+1035.94%)
Mutual labels:  openapi, sdk
Invest Openapi Go Sdk
Stars: ✭ 101 (+57.81%)
Mutual labels:  openapi, sdk
Waliyun
阿里云Node.js Open API SDK(完整版)
Stars: ✭ 40 (-37.5%)
Mutual labels:  openapi, sdk
Openapi Connected Service
Visual Studio extension to generate OpenAPI (Swagger) web service reference.
Stars: ✭ 57 (-10.94%)
Mutual labels:  openapi
Voucherify.js
JavaScript SDK for Voucherify - coupons, vouchers, promo codes
Stars: ✭ 59 (-7.81%)
Mutual labels:  sdk
Oav
Tools for validating OpenAPI (Swagger) files.
Stars: ✭ 55 (-14.06%)
Mutual labels:  openapi
Http To Cq
Communicate with CoolQ through HTTP.
Stars: ✭ 62 (-3.12%)
Mutual labels:  sdk
Parse Sdk Arduino
The Arduino SDK for the Parse Platform
Stars: ✭ 59 (-7.81%)
Mutual labels:  sdk
Intellij Swagger
A plugin to help you easily edit Swagger and OpenAPI specification files inside IntelliJ IDEA
Stars: ✭ 1,073 (+1576.56%)
Mutual labels:  openapi
Azure Rest Api Specs
The source for REST API specifications for Microsoft Azure.
Stars: ✭ 1,104 (+1625%)
Mutual labels:  openapi
Wxjava
Wechat-Group/WxJava的备份,有问题请到对应项目下讨论
Stars: ✭ 56 (-12.5%)
Mutual labels:  sdk
Springdoc Openapi
Library for OpenAPI 3 with spring-boot
Stars: ✭ 1,113 (+1639.06%)
Mutual labels:  openapi
Abstract Sdk
Universal JavaScript bindings for the Abstract API and CLI
Stars: ✭ 55 (-14.06%)
Mutual labels:  sdk
Nestia
Automatic SDK and Document generator for the NestJS
Stars: ✭ 57 (-10.94%)
Mutual labels:  sdk
Mailchimp Api 3.0 Php
A feature rich object-oriented PHP library for interacting with MailChimp's API v3 💌🐵
Stars: ✭ 61 (-4.69%)
Mutual labels:  sdk
Javascript Sdk Design
JavaScript SDK Design Guide extracted from work and personal experience
Stars: ✭ 1,091 (+1604.69%)
Mutual labels:  sdk
React Native Midtrans
Midtrans Mobile SDK for React Native
Stars: ✭ 57 (-10.94%)
Mutual labels:  sdk

KKBOX Open API Developer SDK for JavaScript

npm (scoped) Build Status License Apache

The SDK helps you to access various metadata from KKBOX, including tracks, albums, artists, playlists and stations.

Getting Started

Install the SDK using npm

$ npm install @kkbox/kkbox-js-sdk

Usage example

import { Auth, Api } from '@kkbox/kkbox-js-sdk';

// Create an auth object with client id and secret
const auth = new Auth(client_id, client_secret);

// Fetch your access token
auth.clientCredentialsFlow
  .fetchAccessToken()
  .then(response => {
    const access_token = response.data.access_token;

    // Create an API object with your access token
    const api = new Api(access_token);

    // Fetch content with various fetchers
    api.searchFetcher
      .setSearchCriteria('五月天 派對動物', 'track')
      .fetchSearchResult()
      .then(response => {

        // Content from the KKBOX Open API
        console.log(response.data);

        // Continue to the next page
        api.searchFetcher.fetchNextPage(response).then(response => {
          console.log(response.data);
        });

      });
  });

Test

To test the SDK, a valid client ID and client secret are required.

Please visit https://developer.kkbox.com/, create a new developer account, and obtain the client ID and client secret of your app.

Then, create a file named client_secrets.json, put it into the test directory, and fill your client ID and client secret into it.

It may look like

{
  "kkbox_sdk": {
    "client_id": "YOUR CLIENT ID",
    "client_secret": "YOUR CLIENT SECRET"
  }
}

Run the test:

$ npm test

Documentation

See https://kkbox.github.io/OpenAPI-JavaScript/ for full documentation.

Use the SDK in Web Browsers

The SDK plays fine with Node.js, but works partially in web browsers.

You can use the SDK in your Web and Electron 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), but the Auth server does not.

In 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.

When 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.

mainWindow = new BrowserWindow({
  width: 500,
  height: 500,
  useContentSize: true,
  webPreferences: {
    webSecurity: false
  }
});

License

Copyright 2018 KKBOX Technologies Limited

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].