1.0.1 • Published 1 year ago

kuaishou-merchant-open-api v1.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

快手电商开放平台openAPI

Doc

open.kwaixiaodian.com

Install

npm i kuaishou-merchant-open-api -S

Usage

import KsMerchantClient, { SignMethod } from 'kuaishou-merchant-open-api';

(async () => {
  const client = new KsMerchantClient({
    appKey: 'appKey',
    signSecret: 'signSecret',
    appSecret: 'appSecret'
    signMethod: SignMethod.MD5,
  });

  // getAccessToken
  await client.getAccessTokenByCode({ code: 'authCode' });
  console.log(client.accessToken);
  console.log(client.refreshToken);
  console.log(client.openId);

  // refreshAccessToken
  await client.getAccessTokenByRefreshToken();
  console.log(client.accessToken);

  // request
  client.execute({ api: 'open.item.get' }, { kwaiItemId: 123456 })
  .then((res) => {
    console.log(res);
  });

  // upload
  client.execute({ api: 'open.item.image.upload' }, {
    imgUrl: 'imgUrl',
    imgBytes: fs.createReadStream(path.join(__dirname, './img.jpeg')),
    uploadType: 1,
  }).then((res) => {
    console.log(res);
  });
})()

https://open.kwaixiaodian.com/docs/dev?pageSign=e1d9e229332f4f233a04b44833a5dfe71614263940720#section-9

API

constructor

PropertyDescriptionTypeRequiredDefault
appKeyappIdstringtrue-
appSecretapp secretstringtrue-
signSecretsign secretstringtrue-
accessToken授权说明stringfalse-
urldomainstringfalsehttps://openapi.kwaixiaodian.com
signMethodcryptoSignMethodfalseSignMethod.MD5

execute

system params

PropertyDescriptionTypeRequiredDefault
apiapi pathstringtrue-
methodrequest modestringfalseGET / POST
versionapi versionnumberfalse1
accessTokenaccessTokenstringfalse-

License

Licensed under the MIT License.

1.0.1

1 year ago

1.0.0

1 year ago

0.0.3

3 years ago

0.0.2-alpha

3 years ago

0.0.2

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.1-alpha

3 years ago

0.0.2-beta

3 years ago

0.0.1-beta2

3 years ago

0.0.1-beta

3 years ago