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 17:04:01 +01:00
Tokens expire after 20 minutes at most. For longer-lived clients, pass a token provider instead, which is called on every request:
` ``swift
BearerAuthMiddleware {
try await tokenStore.validToken()
}
` ``
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:_:)`.
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``
### Generated Types
- ``Components``
- ``Operations``
- ``Servers` `