npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

app-store-reviews

v0.0.6

Published

Download user reviews from the iTunes Store and the Mac App Store.

Downloads

31

Readme

About app-store-reviews

NPM version

Node.js module to download user reviews from the iTunes Store and the Mac App Store.

It supports:

  • All countries
  • All apps on the iTunes Store
  • All apps on the Mac App Store

This module uses the public feed to customer reviews

https://itunes.apple.com/rss/customerreviews/page=1/id=555731861/sortby=mostrecent/xml?l=en&cc=us

Installation

app-store-reviews is available via the npm packet manager.

$ npm install app-store-reviews

Usage

You can find all the following examples in the examples folder.

Example 1: single app and country

In this example we simply print the reviews of Tunes Notifier to the console from the US Store. The ID of the app is 555731861.

Code

var appStoreReviewsModule = require('app-store-reviews');
var appStoreReviews = new appStoreReviewsModule();

appStoreReviews.on('review', function(review) {
	console.log(review);
});

appStoreReviews.getReviews('555731861', 'us', 1);

Output

[ id: '676984080',
  app: '555731861',
  author: 'appwatching',
  version: '1.1',
  rate: '5',
  title: 'Very good',
  comment: 'Mucho mejor ahora. Ya se puede esconder el icono de la barra de menús.',
  vote: '0',
  updated: '2012-10-19T12:48:41-07:00',
  country: 'us' ]

Example 2: import to a database for all countries

In this example we store the reviews in a MySQL database.

You can find the structure of the database in examples/reviews-to-mysql.sql

Code

var appStoreReviewsModule = require('app-store-reviews');
var appStoreReviews = new appStoreReviewsModule();

var mysql = require('mysql');

function mysqlConnection()
{
	var db = mysql.createConnection ({
		user : 'root',
	    password : 'root',
	    host : "localhost",
	    database : "reviews",
	    port : "3306"
	});

	return db;
}

function insertReviewInDb(id, app, author, version, rate, title, comment, country, updated)
{
	var review = {
		id: id,
		app: app,
		author: author,
		version: version,
		rate: rate,
		title: title,
		comment: comment,
		country: country,
		review_date: updated,
	}

	var db = mysqlConnection();
	db.connect();
	db.query('INSERT IGNORE INTO reviews SET ?', review);
	db.end();
}

appStoreReviews.on('review', function(review) {
	insertReviewInDb(review['id'], review['app'], review['author'], review['version'], review['rate'], review['title'], review['comment'], review['country'], review['updated']);
});

appStoreReviews.on('nextPage', function(nextPage) {
	appStoreReviews.getReviews(nextPage['appId'], nextPage['country'], nextPage['nextPage']);
});


console.log("Starting reviews-to-mysql.js at " + Date());
var db = mysqlConnection();
db.connect();
db.query('SELECT * FROM apps WHERE enabled=1', function(err, rows, fields) {
	if (err) {
		console.log("DB error: " + err);
	} else {
		for (var index in rows) {
			console.log("App: " + rows[index].id + " - " + rows[index].name);
			
			var countries;
			if (rows[index].countries == null || rows[index].countries == "") {
				countries = appStoreReviews.allCountries();
			} else {
				countries = rows[index].countries.split(',');
				console.log(countries);
			}
			
			for (var countryIndex in countries) {
				appStoreReviews.getReviews(rows[index].id, countries[countryIndex], 1);
			}
		}
	}
});
db.end();

Example 3: automatically email new reviews

In this example we store the reviews in a MySQL database and send the new reviews by email periodically using Cron.

You can find the structure of the database in examples/reviews-to-mysql.sql.

$ npm install app-store-reviews
$ npm install mysql
$ npm install nodemailer
  • In reviews-to-mysql.js, configure your database connection details.

  • In mysql-to-email.js, configure your database connection details and email address and password.

  • In reviews-to-email.sh, set the path to the directory containing this file.

  • Make reviews-to-email.sh executable: chmod +x reviews-to-email.sh

  • Add reviews-to-email.sh to Cron

  • Edit the current crontab: $ crontab -e

  • Add the following line (run every day at 12): 0 12 * * * /EXAMPLE/PATH/reviews-to-email.sh