Package Exports
- chrome-store-api
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (chrome-store-api) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Chrome store api
Chrome webstore Api for Node.js
install
npm install chrome-store-apiusage
var WebstoreApi = require('chrome-store-api').Webstore;
var TokenManager = require('chrome-store-api').TokenManager;
var code = 'app-code';
var clientId = 'your-client-id';
var clientSecret = 'your-client-secret';
var tokenManager = new TokenManager(code, clientId, clientSecret);
var api = new WebstoreApi(tokenManager);Storage
You can use storage for save token data between sessions.
var WebstoreApi = require('chrome-store-api').Webstore;
var TokenManager = require('chrome-store-api').TokenManager;
var FileStorage = require('chrome-store-api').FileStorage;
var code = 'app-code';
var clientId = 'your-client-id';
var clientSecret = 'your-client-secret';
var storage = new FileStorage('data.json');
// you can use every storage module, which implements IStorage interface
var tokenManager = new TokenManager(code, clientId, clientSecret, storage);
var api = new WebstoreApi(tokenManager);get item info
api.get('extensiond-id')
.then(function (data) {
console.log(data);
})
.catch(function (err) {
console.log(err);
});insert new item
var fs = require('q-io/fs');
fs.read('path/to/extension.zip', 'b')
.then(function (blob) {
return api.insert(blob);
})
.then(function (data) {
console.log(data); // new item info
})
.catch(function (err) {
console.log(err);
});update existing item
var fs = require('q-io/fs');
fs.read('path/to/extension.zip', 'b')
.then(function (blob) {
return api.update('extension-id', blob);
})
.then(function (data) {
console.log(data); // item info
})
.catch(function (err) {
console.log(err);
});publish item
api.publish('extension-id')
.then(function (data) {
console.log(data);
})
.catch(function (err) {
console.log(err);
});publish for trusted users only
api.publish('extension-id', 'trusted')
.then(function (data) {
console.log(data);
})
.catch(function (err) {
console.log(err);
});