Skip to content
This repository was archived by the owner on Mar 24, 2026. It is now read-only.

julianbaker/audiusKit

Repository files navigation

AudiusKit v2

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).

Highlights

  • 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, optional ASWebAuthenticationSession helper (iOS / macOS / visionOS).

Quick Start (Typed)

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.

Raw Escape Hatch

let raw = try await client.users.getUser(pathParameters: ["id": "123"])
let json = try raw.decodeJSON()

Log in with Audius (PKCE)

AudiusKit does not render login UI. Typical flow:

  1. let pkce = try client.auth.makePKCE() and let state = try client.auth.generateState().
  2. Build the authorize URL with client.auth.buildOAuthAuthorizeURL(request: AudiusOAuthRequest(..., codeChallenge: pkce.codeChallenge, ...)).
  3. Open the URL in ASWebAuthenticationSession (see AudiusOAuthPresentationSession on supported platforms) or your own browser.
  4. let code = try client.auth.parseOAuthCallback(url: callbackURL, expectedState: state).
  5. try await client.auth.completeOAuthLogin(code: code, codeVerifier: pkce.codeVerifier, redirectURI: "...", scope: .write).
  6. Use auth.mode = .sessionBearer; the stored session’s access token is sent as Bearer.

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.

Optional Legacy Shim

AudiusAPIClient.shared exists as a deprecated migration bridge.

let shared = AudiusAPIClient.shared
let client = shared.client

Use AudiusClient(configuration:) for all new code.

Codegen

Regenerate typed surface:

ruby Scripts/generate_typed_surface.rb ./swagger.yaml

Regenerate operation manifest fixture:

ruby Scripts/generate_operation_manifest.rb ./swagger.yaml Tests/AudiusKitTests/Fixtures/operation_manifest.json

Run codegen parity check:

Scripts/check_codegen.sh ./swagger.yaml

Documentation

  • documentation/Getting-Started.md
  • documentation/Architecture.md
  • documentation/Usage-Guide.md
  • documentation/API-Reference.md
  • documentation/Troubleshooting.md
  • documentation/Migration-v1-to-v2.md

About

A modern Swift package for integrating Audius music content into your iOS, macOS, tvOS, or watchOS app. AudiusKit provides a type-safe, async/await-based read-only API for accessing and streaming content from the Audius Music catalogue.

Topics

Resources

License

Stars

Watchers

Forks

Contributors