Automating IAP creation in iTunes Connect

Adding in app purchases via the iTunes Connect dashboard can be a pain. I happened to have to add 45 IAPs to a game recently, and I used this method to do it in 10 minutes.

You’ll need:

  1. Ruby installed
  2. A csv with all your IAPs – like this iaps.csv
  3. The ruby script bellow
#!/usr/bin/env ruby
require 'io/console'
require "spaceship"
require 'csv'
 
puts "Enter password"
pass = STDIN.noecho(&:gets)
Spaceship::Tunes.login("<your-username>", pass)
app = Spaceship::Tunes::Application.find("<your-app-id>")
 
CSV.foreach("/Users/<user>/iaps.csv", quote_char: '"', col_sep: ',', row_sep: :auto, headers: true) do |row|
	productType = row['Type (consumable -1, non-consumable -2)'] == "1" ? Spaceship::Tunes::IAPType::CONSUMABLE : Spaceship::Tunes::IAPType::NON_CONSUMABLE
	productName = row['Reference Name']
	productDescription = row['IAP description-EN']
	productIdentifier = row['Product ID']
	productTier = row['IAP Price-TIER'].to_i
	puts "Processing product '%s', it's a '%s' %s of tier %d" % [productIdentifier, productName, productType, productTier]
	app.in_app_purchases.create!(
		type: productType, 
		versions: {
		  "en-US" => {
		    name: productName,
		    description: productDescription
		  }
		},
		reference_name: productName,
		product_id: productIdentifier,
		cleared_for_sale: true,
		review_notes: "",
		review_screenshot: "/Users/<username>/Downloads/default.jpg", 
		pricing_intervals: 
		  [
		    {
		      country: "WW",
		      begin_date: nil,
		      end_date: nil,
		      tier: productTier
		    }
		  ] 
		)
end

If you still can’t get it to work, or want to know more, check out:

  1. Creating In-app purchase records on iTunes Connect programmatically
  2. Automatically create in-apps in iTunesConnect with iMacros
  3. How to parse CSV data with Ruby

3 Replies to “Automating IAP creation in iTunes Connect”

  1. hi,

    I´m trying to reproduce what you did but >> Spaceship::Tunes.login(“”, pass), returns an error:

    rescue in itc_service_key’: Could not receive latest API key from App Store Connect, this might be a server issue. (Spaceship::AppleTimeoutError)

    It´s seens that login method has changed. I tried to find information on the web but people use fastlane to generate build, not to create products.
    Have you been using this code? Dou you have a solution?

    Thanks

  2. Hey Andre,

    I’ve never seen it, but I also haven’t ran this code in a couple of years.
    Theoretically it should still work, however, to login with Spaceship it seems like login has changed a bit and:

    `Spaceship.login`

    Is enough, I assume it will prompt for the authentication.

    https://spaceship.airforce/

Leave a Reply

Your email address will not be published. Required fields are marked *