Skip to content

aviationexam/apple-app-store-connect-api

Repository files navigation

Build Status NuGet feedz.io

Apple AppStoreConnect

Install

<ItemGroup>
    <PackageReference Include="Aviationexam.Apple.AppStoreConnect" Version="" />
</ItemGroup>

Note: Version is composed as <Major>.<Minor>.<Patch>.<OpenApiMajor:00><OpenApiMinor:00><OpenApiPatch:00>[-<nightly[0-9]{4}>] e.g. 0.1.13.030500-nightly0008 means: source code version 0.1.13, 8th nightly build, AppStoreConnect version 3.5.0

Disclaimer

This library make some minor changes to the document, mainly to fix definition issues. You can examine the difference after restoring the project comparing openapi.original.json openapi.json located in the src/Apple.AppStoreConnect/app-store-connect-openapi-specification.

How to configure library

Add library to the dependency container

using Aviationexam.Apple.AppStoreConnect.DependencyInjection;

IServiceCollection serviceCollection;

// you may need to add these dependencies
serviceCollection.AddMemoryCache();
using System;
serviceCollection.TryAddSingleton<TimeProvider>(TimeProvider.System);

// configure AppStoreConnect services
serviceCollection.AddAppleAppStoreConnect(optionsBuilder => optionsBuilder
  .Configure()
  .ValidateDataAnnotations()
);
// OR
serviceCollection.AddAppleAppStoreConnect(optionsBuilder => optionsBuilder
  .Bind(builder.Configuration.GetSection(MyConfigOptions.MyConfig))
  .ValidateDataAnnotations()
);
// OR
serviceCollection.AddAppleAppStoreConnect(
  optionsBuilder => optionsBuilder.Configure()
);

How to use library

You can access all clients using the AppStoreConnectApiClient, e.g.:

var apiClient = serviceProvider.GetRequiredService<Apple.AppStoreConnect.Client.AppStoreConnectApiClient>();

var territoriesResponse = await apiClient.V1.Territories.GetAsync(
    requestConfiguration: x =>
    {
        x.QueryParameters.Fieldsterritories =
        [
            GetFieldsTerritoriesQueryParameterType.Currency,
        ];
        x.QueryParameters.Limit = PageSize;
    },
    cancellationToken
);

string appleAppId = "<id>";
var inAppPurchases = await apiClient.V1.Apps[appleAppId].InAppPurchasesV2.GetAsync(
    x => x.QueryParameters.Limit = PageSize,
    cancellationToken
);