AudiusKit v2 is a typed Swift SDK for the Audius/Open Audio Protocol API, generated from:
swagger.yaml (or a path you provide at generation time)
API base and OAuth follow current Audius guidance: https://api.audius.co/v1 and Log in with Audius (authorization code + PKCE).
- Full operation coverage (
157) with typed wrappers. - Typed domain models (
Track,User,Playlist,Comment,Coin, etc.). - Generic response envelopes (
AudiusEnvelope,AudiusListEnvelope,AudiusOptionalEnvelope). - Raw API escape hatch preserved.
- Bearer-first write execution with optional proxy fallback.
- Log in with Audius: PKCE,
/v1/oauth/*, access + refresh tokens, optionalASWebAuthenticationSessionhelper (iOS / macOS / visionOS).
import AudiusKit
let client = AudiusClient(
configuration: AudiusClientConfiguration(
appName: "MyiOSApp",
apiKey: "YOUR_DEVELOPER_APP_API_KEY",
auth: AudiusAuthConfiguration(mode: .sessionBearer),
sessionStore: KeychainSessionStore()
)
)
let user = try await client.typed.users.getUser(.init(id: "123"))
print(user.data.name)Set apiKey to your developer app key when you want x-api-key on REST calls and OAuth (client_id / api_key query). It is optional for anonymous reads if your use case allows it.
let raw = try await client.users.getUser(pathParameters: ["id": "123"])
let json = try raw.decodeJSON()AudiusKit does not render login UI. Typical flow:
let pkce = try client.auth.makePKCE()andlet state = try client.auth.generateState().- Build the authorize URL with
client.auth.buildOAuthAuthorizeURL(request: AudiusOAuthRequest(..., codeChallenge: pkce.codeChallenge, ...)). - Open the URL in
ASWebAuthenticationSession(seeAudiusOAuthPresentationSessionon supported platforms) or your own browser. let code = try client.auth.parseOAuthCallback(url: callbackURL, expectedState: state).try await client.auth.completeOAuthLogin(code: code, codeVerifier: pkce.codeVerifier, redirectURI: "...", scope: .write).- Use
auth.mode = .sessionBearer; the stored session’s access token is sent asBearer.
Refresh: try await client.auth.refreshSession(). Sign out: try await client.auth.revokeSession() (revokes refresh token, then clears the store).
Legacy GET /v1/users/verify_token remains available as client.auth.verifyToken(_:) for older token shapes; PKCE login uses GET /v1/oauth/me internally.
AudiusAPIClient.shared exists as a deprecated migration bridge.
let shared = AudiusAPIClient.shared
let client = shared.clientUse AudiusClient(configuration:) for all new code.
Regenerate typed surface:
ruby Scripts/generate_typed_surface.rb ./swagger.yamlRegenerate operation manifest fixture:
ruby Scripts/generate_operation_manifest.rb ./swagger.yaml Tests/AudiusKitTests/Fixtures/operation_manifest.jsonRun codegen parity check:
Scripts/check_codegen.sh ./swagger.yamldocumentation/Getting-Started.mddocumentation/Architecture.mddocumentation/Usage-Guide.mddocumentation/API-Reference.mddocumentation/Troubleshooting.mddocumentation/Migration-v1-to-v2.md