{"_id":"@croquiscom/itunesconnectanalytics","_rev":"31-c2f327828229d210993c24c51d585d66","name":"@croquiscom/itunesconnectanalytics","dist-tags":{"latest":"0.5.0"},"versions":{"0.5.0":{"name":"@croquiscom/itunesconnectanalytics","version":"0.5.0","keywords":["itunes","itunesconnect","apple","analytics","api","client"],"author":{"name":"Jan Halozan","email":"j.halozan.services@gmail.com"},"license":"CC-BY-4.0","_id":"@croquiscom/itunesconnectanalytics@0.5.0","maintainers":[{"name":"croquiscom-admin","email":"admin@croquis.com"},{"name":"neverlish","email":"neverlish@gmail.com"},{"name":"sixmen","email":"sixmen@gmail.com"},{"name":"luaneyed","email":"sangguk258@gmail.com"},{"name":"zao1214","email":"hexa1214@gmail.com"}],"contributors":[{"name":"Marko Cungl"}],"homepage":"https://github.com/croquiscom/iTunesConnectAnalytics#readme","bugs":{"url":"https://github.com/croquiscom/iTunesConnectAnalytics/issues"},"dist":{"shasum":"d3ab9589e594712855bf29bf040f4cb2f3292e6c","tarball":"https://registry.npmjs.org/@croquiscom/itunesconnectanalytics/-/itunesconnectanalytics-0.5.0.tgz","fileCount":5,"integrity":"sha512-h+T6RJUol7FW270I5z/Z79hGcnEF9nt1kBJqOWTd3nU8fmiTRc4X4c21hANpopL+mppsJY2W6R6VqoE8Axl0tw==","signatures":[{"sig":"MEQCIBbJB7yXZ9sTSjtifGojQpMnq8hJHtWJh+v4fkDGVcmFAiAt4lZW7UQg32Mhj6/h+JX+yVNglhy/2q81Uwm1pzRJow==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":42918,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh2DedCRA9TVsSAnZWagAA+FMP/i9DK9KIleOjiQC9qiP4\njOJQGAQ1i6aZ2bpBv3/cxSr+Ur8jxSi/paATdq8+KlYzPEDrDsTA512gWrB3\npvrwIwoGRERRajuvmMV4Hz6a52HLntMQBlqICA7iUohI1aUhofFLT6hJgYCQ\np8Gu1prMvEcxLLIilLiY8qtqdBnwwi98R1XymyFgkyMHQmqtOjodHPo93lRp\n+eyYYWo5QtLXuws7d9678G8bOm+EWVnGeMSSlvmrbnnevPFEtiMPsiViJTN1\nPXuPmgBONLMDS1TE0/fg3dsGkTmO1g3KyA7soVcYby2n27YyAsZc4LbPBvHE\nboaUgQgqjAh6RrxAIz2aD9JnDPpvOmXAXbYQhanYGDk0lxc6D0KOiMmFpgsY\nC+aD8Df3kljE5eztMfJSAWWcJyTJx/TrcsZIMKDuCgM5SiV0yXvY9lX0m6T7\neBxoOUrskvcK9XEZib0yBF8P3LsO90plb38A4c464F1P7EXeA+L9apEyAlVn\nXmEiAufGvtQ6fDvmmntNnJXKHNAvMEL2+OCQhux58PYeJ+gtdceZ8MrQeBWI\ntbjCK1UhElVqyoqiiOi80E38MUi0nXpQfZW6KOJacwiDY3bc6Kvjg7wTefzP\nKMv9U1wfRubI+WOWiMN0TV/voNpf2EWXBEN9M8NB9DRMvVvAp6scbFcrHl+p\neIDy\r\n=7/ck\r\n-----END PGP SIGNATURE-----\r\n"},"main":"src/analytics.js","gitHead":"3e38a43bcd39ca01d17aeaa85fd9b3293701c627","scripts":{"test":"./node_modules/nodeunit/bin/nodeunit ./test/itunesconnectanalytics.js","pretest":"npm install"},"_npmUser":{"name":"sixmen","email":"sixmen@gmail.com"},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.","repository":{"url":"git+https://github.com/croquiscom/iTunesConnectAnalytics.git","type":"git"},"_npmVersion":"6.14.8","description":"Apple iTunesConnect analytics API client.","directories":{},"_nodeVersion":"14.15.0","dependencies":{"async":"^3.1.0","moment":"^2.24.0","underscore":"^1.9.1","request-promise-native":"^1.0.8"},"_hasShrinkwrap":false,"devDependencies":{"nodeunit":"^0.11.3"},"_npmOperationalInternal":{"tmp":"tmp/itunesconnectanalytics_0.5.0_1615296691797_0.873344479847749","host":"s3://npm-registry-packages"}}},"time":{"created":"2021-03-09T13:31:31.619Z","modified":"2026-08-06T05:50:09.481Z","0.5.0":"2021-03-09T13:31:31.984Z"},"bugs":{"url":"https://github.com/croquiscom/iTunesConnectAnalytics/issues"},"author":{"name":"Jan Halozan","email":"j.halozan.services@gmail.com"},"license":"CC-BY-4.0","homepage":"https://github.com/croquiscom/iTunesConnectAnalytics#readme","keywords":["itunes","itunesconnect","apple","analytics","api","client"],"repository":{"url":"git+https://github.com/croquiscom/iTunesConnectAnalytics.git","type":"git"},"description":"Apple iTunesConnect analytics API client.","contributors":[{"name":"Marko Cungl"}],"maintainers":[{"email":"joo.inthezoo@kakaostyle.com","name":"joointhezoo"},{"email":"admin.dev@kakaostyle.com","name":"croquiscom-admin"},{"email":"sixmen@gmail.com","name":"sixmen"},{"email":"hexa1214@gmail.com","name":"zao1214"},{"email":"hbh2692@naver.com","name":"nabigraphics"},{"email":"colin.kwon@kakaostyle.com","name":"colin.kwon"},{"email":"pepper.ha@kakaostyle.com","name":"pepper.ha"},{"email":"sally.914@kakaostyle.com","name":"olive-sally"},{"email":"yoo2001818@gmail.com","name":"yoo2001818"},{"email":"tim.jlee@kakaostyle.com","name":"tim.jlee"},{"email":"dark.0@kakaostyle.com","name":"dark.0"},{"email":"gommpo111@gmail.com","name":"sungin"},{"email":"joe.725@kakaostyle.com","name":"joe.725"},{"email":"day.0709@kakaostyle.com","name":"day.0709"},{"email":"dan.psk@kakaostyle.com","name":"dan.psk"},{"email":"evan.oh@kakaostyle.com","name":"minhyung"}],"readme":"# iTunesConnectAnalytics\n\n[![CircleCI](https://circleci.com/gh/JanHalozan/iTunesConnectAnalytics/tree/master.svg?style=shield)](https://circleci.com/gh/JanHalozan/iTunesConnectAnalytics/tree/master)\n\nA nodejs module wrapping the AppStore (formerly iTunes) Connect Analytics API. Allows retrieving data available under the `App Analytics` section of AppStore Connect.\n\n_If you're building a dashboard for yourself or your company you might be better off with checking out [Databox](https://databox.com) where we provide a super easy to set up iTunesConnect integration as well as a Google Play Developer Console integration._\n\n## Installation\n\n`$ npm install itunesconnectanalytics`\n\n\n## Example usage\n\nThe usual boilerplate:\n\n```js\nvar itc = require('itunesconnectanalytics');\nvar Itunes = itc.Itunes;\nvar AnalyticsQuery = itc.AnalyticsQuery;\n\nvar username = 'UNAME';\nvar password = 'PASS';\nvar appId = '12345'; //Found in My Apps -> App -> Apple ID or read below on getting the app id.\n\nvar instance = new Itunes(username, password, {\n  errorCallback: function(e) {\n    console.log('Error logging in: ' + e);\n  },\n  successCallback: function(d) {\n    console.log('Logged in');\n  }\n});\n```\n\n### 2FA\n\nIf you have 2 factor authentication enabled you'll be asked to enter the code when you call login first. Enter the code without any spaces and press enter. Rest will work normally.\n\n### Changing providers\n\nIf you have multiple accounts linked to your Apple ID you can change them using the `changeProvider`. Example:\n\n```js\nconst providerId = 'YOUR_PROVIDER_ID';\ninstance.changeProvider('880281', function (error, data) {\n  //Done\n});\n```\n\n### Getting account information\n\nGetting available apps. Useful for getting app IDs needed for later queries. The field you're interested in is `adamId`.\n\n```js\ninstance.getApps(function(error, data) {\n  console.log(JSON.stringify(data, null, 2));\n});\n```\n\nGetting the time interval for which data is available. Use `dataEndDate` property of the `configuration` object to know which is the most recent date that iTunesConnect has data for (the last day or two usually become available with a certain delay). You can use this date when making requests to avoid getting 0 values for days which do not have data yet.\n\n```js\ninstance.getSettings(function(error, data) {\n  // To get end date:\n  // var end = data.configuration.dataEndDate;\n\n  console.log(JSON.stringify(data, null, 2));\n});\n```\n\nCreating an instance and getting app units for the specified time interval.\n\n```js\nvar query = AnalyticsQuery.metrics(appId, {\n  measures:  itc.measures.units,\n}).date('2016-04-10','2016-05-10');\n\ninstance.request(query, function(error, result) {\n  console.log(JSON.stringify(result, null, 2));\n});\n```\n\n### AnalyticsQuery\n\nThe `AnalyticsQuery` object is used to describe what kind of data should be retrieved. Each query must contain the following properties (they are set by default but you can customize them):\n\n- `start` - Date in format `YYYY-MM-DD`.\n- `end` - Date in format `YYYY-MM-DD`.\n- `frequency` - Day, week or month.\n- `measures` - metrics to be fetched.\n\nMetrics are specified under `measures` key in query options. They can also be an array `measures: [itc.measures.units, itc.measures.sales]`.\n\nAvailable metrics:\n\n- installs\n- sessions\n- pageViews\n- activeDevices\n- crashes\n- payingUsers\n- units\n- sales\n- iap (in app purchases)\n- impressions\n- impressionsUnique\n\n#### Query types\n\nThere are two query types. One is `metrics` and the other is `sources`.\n\n##### Metrics\n\nMetrics query is used to retrieve data under the __Metrics__ section in analytics.\n\nExample metrics query:\n\nFetches installs and crashes for the past day.\n\n```js\nvar query = new AnalyticsQuery.metrics(appId, {\n  measures: [itc.measures.installs, itc.measures.crashes]\n}).time(1, 'days');\n```\n\nThe full query can pretty much pull all data that can be accessed from the metrics tab of iTunes Analytics - \n\n```js\nvar query = new AnalyticsQuery.metrics(appId, {\n\tmeasures: [itc.measures.impressionsUnique /* First key required, Second key is optional for comparison */ , itc.measures.pageViewUnique],\n\tfrequency: itc.frequency.months,  /* Optional - default is days */\n\t/* Grouping is optional - you can leave it out if you don't want data grouped by anything. \n\tThis is same as selecting \"view by\" in Analytics */\n\tgroup: {\n\t\tmetric: itc.measures.impressionsUnique /* This is optional - it has to be one of the metric you add in\n\t\tmeasures above, else it will error. \n\t\t\t\t\t\t\t\t\t\t\t\t\n\t\tIf you leave it blank, we'll default it to the first measures, which is normally what you need. */, \n\t\tdimension: itc.dimension.territory,  /* this is the main thing you need to add when grouping */\n\t\trank: \"\", /* Optional - not really sure how it works, but else leave it alone and we will default it to blank. \n\t\tTODO: Find out what this actually does */\n\t\t\n\t\tlimit: 10 /* Optional - default is 200. TODO: Find out what this actually does */ \n\t},\n\t/* Filtering is optional - you can leave it out if you don't want data filtered by anything. This is same as \n\tselecting filtered by in Analytics */\n\t\n\t/* You can choose at most 2 filters if you don't use group by, and 1 filter if you use group by */\n\n\t/* NOTE: every metric cannot be grouped/filtered by every dimension/dimensionFilterKey - for e.g. for app\n\timpressions, app version is irrelevant - using incompatible dimensions with metrics will lead to errored responses.\n\tThis is currently not checked by this module and is your responsibility. When in doubt, try out the Analytics\n\tinterface and see what is allowed and what isn't. */\n\t\n\tdimensionFilters: [\n\t\t{dimensionKey: itc.dimensionFilterKey.device, optionKeys: [itc.platform.iPad]}\n\t]\n}).date('2016-05-01', '2016-06-30'); //can be date or time like above. \n```\n\n\n##### Sources\n\nSources query is used to retrieve data under the __Sources__ section in analytics.\n\nFrom sources you can retrieve top websites or top campaigns. This can be specified using the `dimension` setting in options.\n\nYou can also specify a limit which limits the number of results.\n\nExample sources query:\n\nGet app store views for the last day from Top websites.\n\n```js\nvar query = new AnalyticsQuery.sources(appId, {\n  measures: itc.measures.pageViews,\n  dimension: itc.dimension.websites,\n  limit 100\n}).time(1, 'days');\n```\n\n#### Some other examples\n\n```js\n// Get App Store Views for last 7 days by website sources\nvar query = AnalyticsQuery.sources('940584421', {\n  measures:  itc.measures.pageViews,\n  dimension: itc.dimension.websites\n}).time(7,itc.frequency.day);\n\ninstance.request(query, function(error, result) {\n  console.log(JSON.stringify(result, null, 2));\n});\n\n// Get installs for each day in date range 2016-04-10 to 2016-05-10\nvar query = AnalyticsQuery.metrics('940584421', {\n  measures:  itc.measures.installs,\n}).date('2016-04-10','2016-05-10');\n\ninstance.request(query, function(error, result) {\n  console.log(JSON.stringify(result, null, 2));\n});\n\n// Get sessions for each day in last month\nvar query = AnalyticsQuery.metrics('940584421', {\n  measures:  itc.measures.sessions,\n}).time(1,itc.frequency.month);\n\n\ninstance.request(query, function(error, result) {\n  console.log(JSON.stringify(result, null, 2));\n});\n\n// Get sessions for each day in last month, but filtered to only the region = \"US and Canada\"\nvar query = AnalyticsQuery.metrics('940584421', {\n  measures:  itc.measures.sessions,\n  dimensionFilters: [{ dimensionKey: itc.dimensionFilterKey.region,  optionKeys: [itc.region.usaCanada] }]\n}).time(1, itc.frequency.month);\n\n\ninstance.request(query, function(error, result) {\n  console.log(JSON.stringify(result, null, 2));\n});\n\n// Get sessions for each day in last month, but filtered to only the territory = \"Canada\"\nvar query = AnalyticsQuery.metrics('940584421', {\n  measures:  itc.measures.sessions,\n  dimensionFilters: [{ dimensionKey: itc.dimensionFilterKey.territory,  optionKeys: [itc.territory.canada] }]\n}).time(1, itc.frequency.month);\n\n\ninstance.request(query, function(error, result) {\n  console.log(JSON.stringify(result, null, 2));\n});\n\n//Make an arbitrary GET request to the itunes connect API\nvar url = 'https://appstoreconnect.apple.com/analytics/api/v1/settings/user-info'; //Get info about yourself :)\ninstance.getAPIURL(url, function(error, result) {\n  console.log(JSON.stringify(result, null, 2));\n});\n```\n\n## TODO\n\n- More examples\n- Tests\n\n## Authors\n\n- [JanHalozan](https://github.com/JanHalozan)\n","readmeFilename":"README.md"}