NAME

Apple::AppStoreConnect - Apple App Store Connect API client

VERSION

Version 0.12

SYNOPSIS

use Apple::AppStoreConnect;

my $asc = Apple::AppStoreConnect->new(
    issuer => $API_key_issuer,  # API key issuer ID
    key_id => $key_id,          # App Store Connect API key ID
    key    => $private_key      # Encrypted private key (PEM)
);

# Custom API request
my $res = $asc->get(url => $url);

# List apps / details convenience function
$res = $asc->get_apps();                                          # List of apps
$res = $asc->get_apps(id => $app_id);                             # App details
$res = $asc->get_apps(id => $app_id, path => 'customerReviews');  # App reviews

DESCRIPTION

Apple::AppStoreConnect provides basic access to the Apple App Store Connect API.

Please see the official API documentation for usage and all possible requests.

You can also use it with the "Apple Store Server API".

CONSTRUCTOR

new

  my $asc = Apple::AppStoreConnect->new(
      key_id      => $key_id,
      key         => $private_key?,
      key_file    => $private_key_pem?,
      issuer      => "57246542-96fe-1a63-e053-0824d011072a",
      scope       => \@scope?,
      timeout     => $timeout_sec?,
      expiration  => $expire_secs?,
      ua          => $lwp_ua?,
      curl        => $use_curl?,
      jwt_payload => {%extra_payload}
  );

Required parameters:

Optional parameters:

METHODS

get

my $res = $asc->get(
    url    => $url,
    raw    => $raw?,
    params => \%query_params?
);

Fetches the requested API url, by default, it will use JSON to decode it directly to a Perl hash, unless you request raw result as a string.

Requires LWP::UserAgent, unless the curl option was set.

If the request is not successful, it will die throwing the HTTP::Response->status_line.

get_response

my $res = $asc->get_response(
    url    => $url,
    raw    => $raw?,
    params => \%query_params?
);

Same as get except it returns the full HTTP::Response from the API (so you can handle bad requests yourself).

CONVENIENCE METHODS

jwt

my $jwt = $asc->jwt(
    iat => $iat?,
    exp => $exp?
);

Returns the JSON Web Token string in case you need it. Will return a cached one if it has more than 5 minutes until expiration and you don't explicitly pass an exp argument.

get_apps

my $res = $asc->get_apps(
    id     => $app_id?,
    path   => $path?,
    params => \%query_params?
);

Without arguments it is similar to get(url=>"apps", fetching the list of apps, but does some extra processing to return a Perl hash with app IDs as keys and the app attributes as values.

There are optional arguments to get details of a specific app or app resource:

NOTES

Apple Store Server API

You can use this module with the Apple Store Server API by passing your app's bundle ID to the JWT payload. So there is just one addition to the constructor call:

my $assa = Apple::AppStoreConnect->new(
    issuer      => $API_key_issuer,
    key_id      => $key_id,
    key         => $private_key,
    jwt_payload => {bid => $bundle_id}
);

You can then pass custon Store Server API requests:

my $res = $assa->get(url => "https://api.storekit.itunes.apple.com/inApps/v2/history/$transactionId");

POST/PATCH/DELETE requests

Note that currently only GET requests are implemented, as that is what I needed. However, POST/PATCH/DELETE can be added upon request.

403 Unauthorized etc errors

If you suddenly start getting unauthorized errors with a token that should be valid, log onto App Store Connect and see if you have any documents pending approval (e.g tax documents, new terms etc).

AUTHOR

Dimitrios Kechagias, <dkechag at cpan.org>

BUGS

Please report any bugs or feature requests either on GitHub (preferred), or on RT (via the email bug-Apple-AppStoreConnect at rt.cpan.org or web interface).

I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

GIT

https://github.com/dkechag/Apple-AppStoreConnect

LICENSE AND COPYRIGHT

This software is copyright (c) 2023 by Dimitrios Kechagias.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.