Skip to content

putdotio/putio-sdk-swift

Repository files navigation

put.io boncuk

putio-sdk-swift

Swift SDK for the put.io API

Swift Package: PutioSDK · CocoaPods package: PutioSDK

CI CocoaPods version license

Installation

Install with Swift Package Manager in Xcode using:

https://github.com/putdotio/putio-sdk-swift.git

Or add it to Package.swift:

dependencies: [
    .package(url: "https://github.com/putdotio/putio-sdk-swift.git", from: "1.0.0")
]

Then depend on the PutioSDK product.

Import it as:

import PutioSDK

If you use CocoaPods today, install with:

pod 'PutioSDK'

Quick Start

import PutioSDK

let sdk = PutioSDK(
    config: PutioSDKConfig(
        clientID: "<your-client-id>",
        token: "<your-access-token>"
    )
)

Task {
    do {
        let account = try await sdk.getAccountInfo()
        print(account.username)
    } catch let error as PutioSDKError {
        print(error.message)
        print(error.recoverySuggestion ?? "")
    }
}

The SDK exposes an async-first async throws surface with native URLSession transport and no third-party networking dependency. It no longer ships completion-handler compatibility wrappers or raw JSON response APIs.

Apps that need a custom transport for tests, fixtures, or specialized session configuration can pass their own URLSession:

let configuration = URLSessionConfiguration.ephemeral
configuration.protocolClasses = [MockURLProtocol.self]

let sdk = PutioSDK(
    config: PutioSDKConfig(clientID: "<your-client-id>"),
    urlSession: URLSession(configuration: configuration)
)

Error Handling

Thrown SDK errors are PutioSDKError values that conform to LocalizedError and expose small classification helpers for app code:

do {
    _ = try await sdk.getFile(fileID: 42)
} catch let error as PutioSDKError {
    if error.isAuthenticationFailure {
        // refresh credentials or send the user through sign-in
    } else if error.isRetryable {
        // schedule a retry with backoff
    } else if error.matches(statusCode: 404) {
        // refresh stale local state
    }
}

Development

For local development, the repo exposes one verification command:

make verify

Use Contributing for setup, deterministic verification, live API checks, and release expectations.

Authentication Example

The example app shows a minimal ASWebAuthenticationSession flow and a follow-up account fetch:

Docs

  • Example app for the example app and smoke-test workspace
  • Architecture for the current async transport and decoding direction
  • Testing for deterministic and live verification
  • Readiness for the current verification confidence
  • Security for private vulnerability reporting

Repo Internals

Contributing

Start with Contributing so local setup, verification, and release expectations stay aligned with CI

License

This project is available under the MIT License

About

Swift SDK for the put.io API

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Contributors

Languages