MV-GH / LemmyBackwardsCompatibleAPI

Kotlin multiplatform Backward compatible Lemmy API
GNU Affero General Public License v3.0
4 stars 1 forks source link
api api-client kotlin kotlin-library kotlin-multiplatform lemmy
![Sonatype Nexus (Snapshots)](https://img.shields.io/nexus/s/it.vercruysse.lemmyapi/lemmy-api?server=https%3A%2F%2Fs01.oss.sonatype.org) ![badge][badge-js] ![badge][badge-jvm] ![badge][badge-android] ![badge][badge-linux] ![badge][badge-windows] ![badge][badge-mac] ![badge][badge-ios] ![badge][badge-watchos] ![badge][badge-tvos] ![example workflow](https://github.com//mv-gh/lemmybackwardsCompatibleAPi/actions/workflows/ci.yml/badge.svg) [![License: AGPL v3](https://img.shields.io/badge/License-AGPL_v3-blue.svg)](https://www.gnu.org/licenses/agpl-3.0) ![GitHub stars](https://img.shields.io/github/stars/mv-gh/lemmybackwardsCompatibleAPi?style=social)

LemmyBackwardsCompatibleAPI

A backwards compatible API for Lemmy made with Kotlin Multiplatform. Supports Lemmy 0.18+

Usage

val api =  LemmyApi.getLemmyApi("voyager.lemmy.ml", auth)

api.getSite()

// Some features are version dependent, so we can check if they are supported
if(api.FF.instanceBlock()) {
    api.instanceBlock()
}

// These enums can be different depending on the version of the API
api.getSupportedEntries<SortType>()

Installation

implementation("it.vercruysse.lemmyapi:lemmy-api:VERSION")

It is currently in beta, so only snapshots are available.

Add the following repository

maven { url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots") }

Goals

The intention is to provide an easy-to-use API that supports a wide range of Lemmy instances. The backwards compatibility is achieved by transforming the requests and responses to a "universal" type. And by allowing you to check if a feature is supported by the instance. That way you can change the behavior of your app depending on the instance's version.

It is a non-goal to provide a stable API. The API can change with every iteration without warning nor deprecation.

Backwards Compatibility Strategy

The API is backwards compatible by using the following strategy:

AutoGenerated Code

To minimize the maintenance burden, many aspects have been automated.

This is done through kotlinscripts which are located in the GeneratorScripts submodule

There is 3 main scripts:

Extra features