2025-10-05 23:16:54 +00:00
# ``ASConnectService``
2026-10-25 17:18:52 +01:00
A type-safe Swift client for the App Store Connect API.
2025-10-05 23:16:54 +00:00
## Overview
2026-10-25 17:18:52 +01:00
ASConnectService exposes every endpoint of Apple's App Store Connect API as a Swift method with typed requests and responses. It's generated from the official OpenAPI specification with [Swift OpenAPI Generator ](https://github.com/apple/swift-openapi-generator ).
2026-03-26 01:07:23 +00:00
### Creating a Client
2026-10-25 17:18:52 +01:00
Create a ``Client`` with a server URL, a transport, and a ``BearerAuthMiddleware`` that authenticates each request with a JSON Web Token (JWT):
2026-03-26 01:07:23 +00:00
` ``swift
import ASConnectService
import OpenAPIURLSession
let client = Client(
2026-10-25 17:05:15 +01:00
serverURL: try Servers.Server1.url(),
2026-03-26 01:07:23 +00:00
transport: URLSessionTransport(),
middlewares: [
BearerAuthMiddleware(token: yourJWTToken)
]
)
` ``
2026-10-25 18:11:51 +01:00
Tokens expire after 20 minutes at most. For longer-lived clients, use ``APIKeyTokenProvider``, which signs new ones with your API key as needed:
2026-10-25 17:04:01 +01:00
` ``swift
2026-10-25 18:11:51 +01:00
let tokenProvider = try APIKeyTokenProvider(
issuerID: yourIssuerID,
keyID: yourKeyID,
privateKey: yourP8FileContents
)
2026-10-25 17:04:01 +01:00
BearerAuthMiddleware {
2026-10-25 18:11:51 +01:00
try await tokenProvider.token()
2026-10-25 17:04:01 +01:00
}
` ``
2026-03-26 01:07:23 +00:00
### Making API Calls
2026-10-25 17:18:52 +01:00
Each endpoint is a method on ``Client``, declared by ``APIProtocol``. It returns an ` Output` enum with a case for each documented response:
2026-03-26 01:07:23 +00:00
` ``swift
2026-10-25 17:18:52 +01:00
let response = try await client.appsGetCollection(query: .init(limit: 10))
let apps = try response.ok.body.json.data
2026-03-26 01:07:23 +00:00
` ``
2025-10-05 23:16:54 +00:00
2026-10-25 17:18:52 +01:00
The ` ok` property throws for any other response. To handle those, switch over the ` Output` cases, such as ` .unauthorized` or ` .undocumented(statusCode:_:)`.
2026-10-25 17:37:05 +01:00
### Fetching More Pages
Lists are paged. Pass a page's ``Components/Schemas/PagedDocumentLinks/nextCursor`` as the ` cursor` of the next request:
` ``swift
var apps: [Components.Schemas.App] = []
var cursor: String?
repeat {
let page = try await client.appsGetCollection(query: .init(limit: 200, cursor: cursor)).ok.body.json
apps += page.data
cursor = page.links.nextCursor
} while cursor != nil
` ``
2025-10-05 23:16:54 +00:00
## Topics
2026-03-26 01:07:23 +00:00
### API Client
2025-10-05 23:16:54 +00:00
2026-03-26 01:07:23 +00:00
- ``Client``
- ``APIProtocol``
### Authentication
- ``BearerAuthMiddleware``
2026-10-25 18:11:51 +01:00
- ``APIKeyTokenProvider``
2026-03-26 01:07:23 +00:00
### Generated Types
- ``Components``
- ``Operations``
- ``Servers` `