Is it possible to get number of downloads of an application from Google Play?
Asked Answered
L

7

22

I am trying to get the number of downloads of an application that I have uploaded to Google Play.

I am searching for an API (or something similar) that retrieves to me the number of downloads with the authentification of the user. I do not want third party applications (like AppAnnie).

It would be great if it could be on PHP and I found that there is a library which I think it is the most closest API I could find to get data from Google applications.

Google APIs Client Library for PHP

but I cannot find any mention to Google Play applications.

Is there some way to get the downloads of an specific application having the authentification keys?

Thanks in advance!

Lawley answered 20/2, 2017 at 17:2 Comment(0)
M
8

Use the google-play-scraper library to get an app information as below:

Example:

$app = $scraper->getApp('com.mojang.minecraftpe');

Result:

array (
  'id' => 'com.mojang.minecraftpe',
  'url' => 'https://play.google.com/store/apps/details?id=com.mojang.minecraftpe',
  'image' => 'https://lh3.googleusercontent.com/30koN0eGl-LHqvUZrCj9HT4qVPQdvN508p2wuhaWUnqKeCp6nrs9QW8v6IVGvGNauA=w300',
  'title' => 'Minecraft: Pocket Edition',
  'author' => 'Mojang',
  'author_link' => 'https://play.google.com/store/apps/developer?id=Mojang',
  'categories' => array (
    'Arcade',
    'Creativity',
  ),
  'price' => '$6.99',
  'screenshots' => array (
    'https://lh3.googleusercontent.com/VkLE0e0EDuRID6jdTE97cC8BomcDReJtZOem9Jlb14jw9O7ytAGvE-2pLqvoSJ7w3IdK=h310',
    'https://lh3.googleusercontent.com/28b1vxJQe916wOaSVB4CmcnDujk8M2SNaCwqtQ4cUS0wYKYn9kCYeqxX0uyI2X-nQv0=h310',
    // [...]
  ),
  'description' => 'Our latest free update includes the Nether and all its inhabitants[...]',
  'description_html' => 'Our latest free update includes the Nether and all its inhabitants[...]',
  'rating' => 4.4726405143737793,
  'votes' => 1136962,
  'last_updated' => 'October 22, 2015',
  'size' => 'Varies with device',
  'downloads' => '10,000,000 - 50,000,000',
  'version' => 'Varies with device',
  'supported_os' => 'Varies with device',
  'content_rating' => 'Everyone 10+',
  'whatsnew' => 'Build, explore and survive on the go with Minecraft: Pocket Edition[...]',
  'video_link' => 'https://www.youtube.com/embed/D2Z9oKTzzrM?ps=play&vq=large&rel=0&autohide=1&showinfo=0&autoplay=1',
  'video_image' => 'https://i.ytimg.com/vi/D2Z9oKTzzrM/hqdefault.jpg',
)

EDIT: Easily get downloads count as below:

echo $app['downloads']; // Outputs: '10,000,000 - 50,000,000'

Or if you want the left value:

$matches = null;
$returnValue = preg_match('/.*(?= -)/', '10,000,000 - 50,000,000', $matches);
echo $matches[0]; // Outputs: '10,000,000'

Or if you want the right value:

$matches = null;
$returnValue = preg_match('/(?<=- ).*/', '10,000,000 - 50,000,000', $matches);
echo $matches[0]; // Outputs: '50,000,000'

Then easily convert it to integer using:

$count = null;
$returnValue = (int)preg_replace('/,/', '', $matches[0], -1, $count);
echo $returnValue; // Outputs: 10000000 or 50000000
Mcnamee answered 5/3, 2017 at 9:10 Comment(2)
I want to publish a app on playstore in which I want to use this. Is this a policy violation or Google can reject my appAuscultate
@Auscultate I'm not certain if that violates their policy or not, by the way, data scraping from websites mostly violates their terms, but the data that is being scraped is already publicly available for browsing there so I don't think there are any issues with that, maybe other experts can provide more details on this and I think it mostly depends on what you do with the data being scraped, not the act of scraping itself.Mcnamee
G
5

This is about meta data api. You can look at below.

https://developers.google.com/android-publisher/api-ref/reviews

Goldfarb answered 7/3, 2017 at 9:38 Comment(0)
G
3

You need to Scrape it. Generally speaking, & of course in this particular case, when the website(here: Google Play) does not provide an API to make your(client's) desired data accessible to him, Web scraping is one of the best methods to gather your required information.

Nearly every piece of information that you can see on a web page, can be scraped. Nowadays with great improvements of web scrapers, not only you are able to grab data from a target website, but also "crawling it like a user", "posting information to website via forms", "logging in as a user" & etc. has become a routine for any web scraper.

There are very strong scrapers out there, like Scrapy(likely the most reputed one, written in Python) almost for every language. AFAIK the best web scraper in PHP, is Goutte written by legendary @fabpot from FriendsOfPHP.

From the Data-Extraction POV, Goutte supports both "CSS Selectors" & XPath (Because it uses Symfony's DOM Crawler as Crawling engine). So you can crawl the document the way you want to extract every piece of information in any hidden corner of a web page!

You can go faraway in scraping with Goutte, But just as a tiny example for grabbing "number of installs" from an ordinary App page in a blink of an eye:

use Goutte\Client;

$Client = new Client();

/**
* @var \Symfony\Component\DomCrawler\Crawler 
*/
$Crawler = $Client->request('GET', "https://play.google.com/store/apps/details?id=com.somago.brainoperator&hl=en");

$numberOfInstalls = $Crawler->filter('div.details-section-contents div.meta-info')->eq(1)->filter('div.content')->eq(0)->text();

echo $numberOfInstalls;

It will simply print Brain Operator game's "number of downloads".

Glomerulonephritis answered 6/3, 2017 at 21:44 Comment(0)
F
2

In python you can use this.

from google_play_scraper import app #if not installed google_play_scraper then install by **pip install google-play-scraper**

playstore = app('test.example.com');

print(playstore):
Finnigan answered 23/1, 2022 at 17:38 Comment(0)
S
1

This project https://github.com/ArcadiaConsulting/appstorestats is a API in Java to get statistics from Google Play and AppStore

Scorpaenoid answered 1/3, 2017 at 16:6 Comment(1)
But I need something on PHP or similar to display on the web.Lawley
B
1

checkout this library 42 matters gives number of downloads , rating many more

Byandby answered 6/3, 2017 at 11:18 Comment(0)
M
0

With AppID you can get it from the GooglePlay API

Or if the app is yours you can export the statistics from Google Cloud (reference)

Mattson answered 28/2, 2017 at 14:2 Comment(1)
Since OP is asking for PHP, this is probably the one you mean.Adenovirus

© 2022 - 2024 — McMap. All rights reserved.