No description
Find a file
Konstantin 929b5cac75
Merge pull request #82 from TootSDK/detect-flavour-automatically
Detect instance flavour automatically
2023-02-11 13:25:11 +01:00
.github/workflows chore: skip build when only docs update 2023-02-10 03:31:21 +01:00
architecture/decisions Update - Documentation ahead of first release 2023-01-28 15:47:06 +13:00
docs docs: regenerate docs 2023-02-10 03:27:32 +01:00
Examples feat: update CLI example with a new command get-flavour 2023-02-10 03:25:57 +01:00
media docs: add diagram source 2022-12-16 11:07:57 +01:00
multipart-kit-tootsdk fix(#53): copy multipart-kit into TootSDK so it doesn't conflict with parent dependencies 2023-02-04 00:38:07 +01:00
Scripts docs: renerate docs, updating copyright notice so it doesn't include a last updated date 2023-02-09 07:32:57 +01:00
Sources feat: create a TootClient initializer that automatically connects 2023-02-10 03:24:26 +01:00
Tests/TootSDKTests chore: do not publish reject lists in unit test files, better mastodon example 2023-02-10 03:50:12 +01:00
.adr-dir feat: initial commit 2022-12-14 19:52:45 +01:00
.gitignore feat: initial commit 2022-12-14 19:52:45 +01:00
.swiftlint.yml Fix - Update swiftlint to ignore our copy of MultiPartKit 2023-02-05 14:57:21 +13:00
CODE_OF_CONDUCT.md feat: initial commit 2022-12-14 19:52:45 +01:00
CONTRIBUTING.md Update - Documentation ahead of first release 2023-01-28 15:47:06 +13:00
LICENSE.md docs: renerate docs, updating copyright notice so it doesn't include a last updated date 2023-02-09 07:32:57 +01:00
Package.resolved Fix - Moving package for MultipartKitTootSDK to a separate target with dependency in TootSDK 2023-02-05 13:39:38 +13:00
Package.swift feat: detect instance flavour 2023-02-10 02:54:24 +01:00
README.md docs: update README to use async initializer for flavour detection 2023-02-10 03:39:41 +01:00
ROADMAP.md Update - Documentation ahead of first release 2023-01-28 15:47:06 +13:00

TootSDK

Cross-platform Swift library for the Mastodon API

Swift 5.7 Platforms BSD 3-clause Build Status

TootSDK is a framework for Mastodon and the Fediverse, for iOS. It provides a toolkit for authorizing a user with an instance, and interacting with their posts.

TootSDK is a community developed SDK for Mastodon and the Fediverse. It is designed to work with all major servers (Mastodon, Pleroma, PixelFed etc).

You can use TootSDK to build a client for Apple operating systems, or Linux with Vapor.

overview of how TootSDK integrates with fedi platforms

Why make TootSDK?

When app developers build apps for Mastodon and the Fediverse, every developer ends up having to solved the same set of problems when it comes to the API and data model.

Konstantin and Dave decided to share this effort. TootSDK is a shared Swift Package that any client app can be built on.

Key Principles ⚙️

  • Async/Await based. All asynchronous functions are defined as Async ones that you can use with Async/Await code
  • Internal consistency and standardization of model property names
  • Standardization across all supported Fediverse APIs
  • Platform agnostic (TootSDK shouldn't care if it's on iOS, macOS or Linux!)

Project Status 📈

  • Mastodon - In progress
  • Pleroma - In progress
  • Pixelfed - To do
  • Writefreely - To do

Our roadmap shows where we want to take TootSDK. Our project board shows our current backlog of work, and what is in flight.

Please don't hesitate to open an issue or create a PR for features you need 🙏

Quick start 🏁

It's easy to get started with TootSDK.

  • Add TootSDK to your project via Swift Package Manager: https://github.com/TootSDK/TootSDK

  • Instantiate with an instanceURL and accessToken:

  let instanceURL = URL(string: "social.yourinstance.com")
  let client = try await TootClient(connect: instanceURL, accessToken: "USERACCESSTOKEN")

Signing in (for macOS and iOS):

  • Instantiate your client without a token:
let client = try await TootClient(connect: url)
let client = try await TootClient(connect: url)

guard let accessToken = try await client.presentSignIn(callbackURI: callbackURI) else {
    // handle failed sign in
    return
}

That's it 🎉!

We recommend keeping the accessToken somewhere secure, for example the Keychain.

Signing in (all platforms):

  • Instantiate your client without a token:
let client = try await TootClient(connect: instanceURL)
  • Retrieve an authorization URL to present to the user (so they can sign in)
let authURL = client.createAuthorizeURL(callbackURI: "myapp://someurl")
  • Present the the authorization URL as a web page
  • Let the user sign in, and wait for the callbackURI to be called
  • When that callbackURI is called, give it back to the client to collect the token
let accessToken = client.collectToken(returnUrl: url, callbackURI: callbackURI)

We recommend keeping the accessToken somewhere secure, for example the Keychain.

Accessing a user's home feedfeed

let posts = try await client.data.stream(.timeLineHome)

Further Documentation 📖

  • Reference documentation is available here
  • Example apps:
    • swiftui-toot - a SwiftUI app that shows authorization, a user's feed, posting and account operations
    • swiftyadmin - a command line utility to interact with and control a server using TootSDK
    • vaportoot - a web app in Vapor, that shows how to sign in and view a user's feed

Contributing

Code of Conduct and Contributing rules 🧑‍⚖️

  • Our guide to contributing is available here: CONTRIBUTING.md.
  • All contributions, pull requests, and issues are expected to adhere to our community code of conduct: CODE_OF_CONDUCT.md.

Key contributors

License 📃

TootSDK is licensed with the BSD-3-Clause license, more information here: LICENSE.MD

This is a permissive license which allows for any type of use, provided the copyright notice is included.

Acknowledgements 🙏