# Pricing A Swift command-line tool to download subscription pricing from App Store Connect. ## Prerequisites - Swift 5.9+ - An App Store Connect API key (`.p8` file) with access to your app's subscription data ## Setup Export your App Store Connect API credentials as environment variables: ```bash export AS_ISSUER_ID="your-issuer-id" export AS_KEY_ID="your-key-id" export AS_PRIVATE_KEY_PATH="/path/to/AuthKey_XXXX.p8" ``` You can add these to your shell profile (`~/.zshrc`, `~/.bashrc`) to persist them. ## Usage ``` swift run pricing [product-id] [options] swift run pricing --group [--csv ] ``` ### Arguments | Argument | Description | |---|---| | `app-id` | Numeric Apple ID from App Store Connect (e.g. `6737844884`) | | `product-id` | Subscription product ID string (e.g. `com.example.app.monthly`) | ### Options | Option | Description | |---|---| | `--group ` | Fetch all subscriptions in a named subscription group | | `--csv ` | Export results to CSV files (one per subscription) in the given directory | ## Examples ### Default: fetch all subscriptions in a group and export to CSV ```bash swift run pricing 6737844884 --group subscriptions --csv ./export ``` This fetches every subscription in the "subscriptions" group, prints a price table for each one, and writes individual CSV files to `./export/` (e.g. `Core_Monthly.csv`, `Pro_Annual.csv`). ### Fetch a single subscription ```bash swift run pricing 6737844884 com.pixycad.core.monthly ``` ### Fetch a single subscription and export to CSV ```bash swift run pricing 6737844884 com.pixycad.core.monthly --csv ./export ``` ### Fetch all subscriptions in a group (console only) ```bash swift run pricing 6737844884 --group subscriptions ``` ## Output ### Console ``` [Core Monthly] (state: APPROVED) Subscription Prices for: com.pixycad.core.monthly ──────────────────────────────────────────────────────────────────────── Territory Curr Price Proceeds ──────────────────────────────────────────────────────────────────────── USA USD 4.99 4.24 GBR GBP 4.99 4.24 ... ──────────────────────────────────────────────────────────────────────── Total territories: 175 ``` ### CSV Each CSV file contains: ``` Product ID,Territory,Currency,Customer Price,Proceeds com.pixycad.core.monthly,USA,USD,4.99,4.24 com.pixycad.core.monthly,GBR,GBP,4.99,4.24 ... ``` Opens directly in Excel, Numbers, or Google Sheets. ## Notes - Only the **current active price** per territory is returned (future scheduled prices and historical prices are filtered out) - The tool automatically retries on timeouts and rate limits (up to 3 attempts with backoff) - Group name matching is case-insensitive; if no match is found, available group names are printed