Fetch production app versions from Google Play Store and Apple App Store.
npm install @perdieminc/mobile-app-versionsconst MobileAppVersions = require('@perdieminc/mobile-app-versions');
const client = new MobileAppVersions({
gcpKey: process.env.GCP_KEY // Required for Android lookups
});
// Get iOS version
const iosVersion = await client.getIosVersion('com.example.app');
console.log(iosVersion); // "1.2.3"
// Get Android version
const androidVersion = await client.getAndroidVersion('com.example.app');
console.log(androidVersion); // "1.2.3"
// Get both versions
const versions = await client.getVersions('com.example.app');
console.log(versions);
// { ios: "1.2.3", android: "1.2.3" }const client = new MobileAppVersions(options);| Option | Type | Description | Default |
|---|---|---|---|
gcpKey |
string |
Base64-encoded GCP service account JSON key | process.env.GCP_KEY |
googleAuthUrl |
string |
Google OAuth token URL | https://oauth2.googleapis.com/token |
itunesUrl |
string |
iTunes lookup API URL | https://itunes.apple.com/lookup |
androidPublisherUrl |
string |
Android Publisher API URL | https://androidpublisher.googleapis.com/androidpublisher/v3/applications |
Fetches the production version of an iOS app from the App Store.
const version = await client.getIosVersion('com.example.app');
// Returns: "1.2.3"Fetches the production version of an Android app from Google Play.
const version = await client.getAndroidVersion('com.example.app');
// Returns: "1.2.3"Fetches both iOS and Android versions for a single bundle ID.
const result = await client.getVersions('com.example.app');
// Returns: { ios: "1.2.3", android: "1.2.3" }
// If one fails: { ios: "1.2.3", android: null, errors: { android: "error message" } }Fetches versions for multiple bundle IDs.
const results = await client.getVersionsForMultipleBundles([
'com.app.one',
'com.app.two'
]);
// Returns:
// {
// "com.app.one": { ios: "1.0.0", android: "1.0.0" },
// "com.app.two": { ios: "2.0.0", android: "2.0.0" }
// }// Shorthand for getIosVersion
await client.ios('com.example.app');
// Shorthand for getAndroidVersion
await client.android('com.example.app');const { createClient } = require('@perdieminc/mobile-app-versions');
const client = createClient({ gcpKey: '...' });You can configure the module using environment variables instead of constructor options:
| Variable | Description |
|---|---|
GCP_KEY |
Base64-encoded GCP service account JSON key |
GOOGLE_AUTH_URL |
Google OAuth token URL |
ITUNES_URL |
iTunes lookup API URL |
ANDROID_PUBLISHER_URL |
Android Publisher API URL |
To fetch Android app versions, you need a Google Cloud Platform service account with access to the Google Play Developer API:
- Go to the Google Cloud Console
- Create or select a project
- Enable the Google Play Android Developer API
- Create a service account with appropriate permissions
- Download the JSON key file
- Base64 encode the JSON key:
base64 -i service-account.json
- Set the encoded string as
GCP_KEY
The service account must also be linked to your Google Play Console:
- Go to Google Play Console
- Navigate to Settings > API access
- Link your Google Cloud project
- Grant the service account access to your apps
The module throws descriptive errors for common issues:
try {
const version = await client.getIosVersion('invalid.bundle.id');
} catch (error) {
console.error(error.message);
// "No iOS app found for bundleId: invalid.bundle.id"
}When using getVersions(), errors are captured in the response instead of throwing:
const result = await client.getVersions('com.example.app');
if (result.errors?.ios) {
console.error('iOS lookup failed:', result.errors.ios);
}
if (result.errors?.android) {
console.error('Android lookup failed:', result.errors.android);
}# Run unit tests
npm test
# Run integration tests (requires network access)
npm run test:integrationBuilt for Node 22.x but can work on node 18.x
When pushing a git tag it will trigger a Github action that will deploy the package to NPM
ISC