Core package for SMAPI Skills Kit SDK
npm install ask-smapi-sdkask-smapi-sdk is a library for Alexa Skills Kit's Skill Management APIs (SMAPI).
Learn more about SMAPI by reviewing the SMAPI documentation.
1. Install NPM using the instructions provided here. This is needed to get started with the ASK CLI, which will be used to generate Login with Amazon tokens you will need to access SMAPI.
2. Install ask-cli.
1. Create a new security profile for your Amazon Developer account by following the instructions provided here.
This will generate Client ID and Client Secret keys.
2. Using the ASK CLI, run: ask util generate-lwa-tokens --client-id . Replace the and with the Client ID and Client Secret keys from the previous step.
This will return the following JSON with a Refresh Token:
`` sh`
{
"access_token": "ACCESS_TOKEN",
"refresh_token": "REFRESH_TOKEN",
"token_type": "bearer",
"expires_in": 3600,
"expires_at": "2019-11-19T20:25:06.584Z"
}
` sh`
$ npm install ask-smapi-sdk
, Client Secret and Refresh Token retrieved in the previous step to configure a new SMAPI client:#### For Node.js
`js
const Alexa = require('ask-smapi-sdk');// specify the refreshTokenConfig with clientId, clientSecret and refreshToken generated in the previous step
const refreshTokenConfig = {
clientId,
clientSecret,
refreshToken
}
const smapiClient = new Alexa.StandardSmapiClientBuilder()
.withRefreshTokenConfig(refreshTokenConfig)
.client();
`#### For typescript
`ts
import * as Alexa from 'ask-smapi-sdk';// specify the refreshTokenConfig with clientId, clientSecret and refreshToken generated in the previous step
const refreshTokenConfig : Alexa.RefreshTokenConfig = {
clientId,
clientSecret,
refreshToken
}
const smapiClient = new Alexa.StandardSmapiClientBuilder()
.withRefreshTokenConfig(refreshTokenConfig)
.client();
`$3
` js
To only retrieve response body
smapiClient.listSkillsForVendorV1(vendorId)
.then((response) => {
console.log(JSON.stringify(response));
})
.catch((err) => {
console.log(err.message);
console.log(JSON.stringify(err.response));
});
To include response header and status code
smapiClient.callListSkillsForVendorV1(vendorId)
.then((response) => {
console.log(response.header);
})
.catch((err) => {
console.log(err.message);
console.log(JSON.stringify(err.response));
});
`$3
` js
smapiClient.getSkillManifestV1(skillId, stage)
.then((response) => {
console.log(JSON.stringify(response));
})
.catch((err) => {
console.log(err.message);
console.log(JSON.stringify(err.response));
});
``For the complete list of functions, please see the SMAPI SDK reference documentation.
* SMAPI SDK API Reference Documentation
* SMAPI Documentation