Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/acvetkov/chrome-store-api
Chrome Webstore API
https://github.com/acvetkov/chrome-store-api
Last synced: 6 days ago
JSON representation
Chrome Webstore API
- Host: GitHub
- URL: https://github.com/acvetkov/chrome-store-api
- Owner: acvetkov
- Created: 2015-12-02T10:33:37.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2021-02-12T15:25:58.000Z (almost 4 years ago)
- Last Synced: 2024-12-04T09:38:44.045Z (10 days ago)
- Language: JavaScript
- Size: 40 KB
- Stars: 31
- Watchers: 4
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
- awesome-browser-extensions-and-apps - chrome-store-api - Chrome Webstore [API](https://developer.chrome.com/webstore/using_webstore_api) for Node.js. (Tools / Publishing)
- Awesome-WebExtensions - chrome-store-api - Chrome Web Store API wrapper. (Tools)
README
[![Build Status](https://travis-ci.org/acvetkov/chrome-store-api.svg?branch=master)](https://travis-ci.org/acvetkov/chrome-store-api)
## Chrome store api
Chrome webstore [Api](https://developer.chrome.com/webstore/using_webstore_api) for Node.js
### install
```bash
npm install chrome-store-api
```### usage
```js
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.
```js
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
```js
api.get('extensiond-id')
.then(function (data) {
console.log(data);
})
.catch(function (err) {
console.log(err);
});
```#### insert new item
```js
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
```js
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
```js
api.publish('extension-id')
.then(function (data) {
console.log(data);
})
.catch(function (err) {
console.log(err);
});
```#### publish for trusted users only
```js
api.publish('extension-id', 'trusted')
.then(function (data) {
console.log(data);
})
.catch(function (err) {
console.log(err);
});
```