Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jellyfin/jellyfin-sdk-swift
Swift SDK for Jellyfin
https://github.com/jellyfin/jellyfin-sdk-swift
jellyfin spm swift swiftpackage
Last synced: 15 days ago
JSON representation
Swift SDK for Jellyfin
- Host: GitHub
- URL: https://github.com/jellyfin/jellyfin-sdk-swift
- Owner: jellyfin
- Created: 2021-06-02T17:04:18.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-10-29T00:15:43.000Z (23 days ago)
- Last Synced: 2024-10-30T00:00:38.645Z (22 days ago)
- Topics: jellyfin, spm, swift, swiftpackage
- Language: Swift
- Homepage: https://jellyfin.org
- Size: 4.27 MB
- Stars: 47
- Watchers: 9
- Forks: 17
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Swift SDK Jellyfin
Swift SDK to work with Jellyfin servers.
> Generated using [CreateAPI](https://github.com/CreateAPI/CreateAPI)
## Documentation
Documentation is available on [Swift Package Index](https://swiftpackageindex.com/jellyfin/jellyfin-sdk-swift/main/documentation/jellyfinapi).
## Usage
`JellyfinClient` uses an underlying [Get APIClient](https://github.com/kean/Get) to provide basic functionality for interfacing with a Jellyfin server:
- inject required `Authorization` header for every request
- encoding/decoding of expected `Date` values
- `signIn` for generating a session access token
- `signOut` for revoking the current access token```swift
// Create client instance
let jellyfinClient = JellyfinClient(configuration: configuration)// Sign in user with credentials
let response = jellyfinClient.signIn(username: "jelly", password: "fin")
```Alternatively, you can use your own network stack with the generated **Entities** and **Paths**.
## Quick Connect
The `QuickConnect` object has been provided to perform the Quick Connect authorization flow.
```swift
/// Create a QuickConnect object with a JellyfinClient
let quickConnect = QuickConnect(client: client)let quickConnectState = Task {
/// Listen to QuickConnect states with async/await or Combine
for await state in quickConnect.$state.values {
switch state {
/// Other cases ommitted
case let .polling(code: code):
print(code)
case let .authenticated(secret: secret):
/// Sign in with the Quick Connect secret
client.signIn(quickConnectSecret: secret)
}
}
}/// Start the Quick Connect authorization flow
quickConnect.start()
```## Generation
```bash
# Download latest spec and run CreateAPI
$ make update
```Alternatively, you can generate your own Swift Jellyfin SDK using [CreateAPI](https://github.com/CreateAPI/CreateAPI) or any other OpenAPI generator.