Generating App Store promo codes with itc.cli
If you are like me and have an app available in versions for iPad, iPhone, and Mac, you know how tedious it is to create promo codes for the whole suite of apps. There needed to be a better way to quickly create a promo code for each app than the endless clicking and waiting game in iTunes Connect.
Update May 26th, 2015: itc.cli does not work anymore. Please use codes from the fastlane toolchain instead.
itc.cli to the rescue! With the “iTunes Connect command line interface” it’s really easy to write a script that quickly generates a set of App Store promo codes.
Installing itc.cli
First, we need to install itc.cli. The installation instructions on itc.cli’s GitHub page didn’t really work for me. Here’s what I did:
Install pip and itc.cli:
# install Xcode command line tools (if necessary)
xcode-select --install
# install pip
sudo easy_install pip
# install itc.cli
sudo pip install itc.cli
If you later want to upgrade itc.cli, do this:
sudo pip install --upgrade itc.cli
Script to generate promo codes for three apps at once
Now, it’s very easy to write a script that downloads one promo code for each app. You just need to know your iTunes Connect login and the Apple IDs of your apps. itc.cli lists all apps and their Apple IDs when you log in. Here’s a (slightly modified) example output:
itc login -u <USERNAME>
Password:
INFO - Login: logged in. Session cookies are saved to <...>
INFO - Application found: "Textastic Code Editor for iPad" (383577124)
INFO - Application found: "Textastic Code Editor for iPhone" (550156166)
INFO - Application found: "Textastic" (572491815)
INFO - Nothing to do.
With this information, I could write this textastic_promo_all.command
script:
echo "Textastic for iPad: " >> promocodes.txt
itc promo 1 -a 383577124 -o promocodes.txt -u <USERNAME>
echo "Textastic for iPhone: " >> promocodes.txt
itc promo 1 -a 550156166 -o promocodes.txt -u <USERNAME>
echo "Textastic for Mac: " >> promocodes.txt
itc promo 1 -a 572491815 -o promocodes.txt -u <USERNAME>
Make script executable:
chmod +x textastic_promo_all.command
Now you can just double-click on the textastic_promo_all.command
file in Finder, enter your iTunes Connect password and it will automatically append three promo codes to a file called promocodes.txt
- ready to send in an email.