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()
if(api.FF.instanceBlock()) {
api.instanceBlock()
}
api.getSupportedEntries<SortType>()
Installation
implementation("it.vercruysse.lemmyapi:lemmy-api:VERSION")
It is currently in beta.
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.
Extra features
- JVM datatypes implement
Serializable
- Android datatypes implement
Parcelable and Serializable
Backwards Compatibility Strategy
The API is backwards compatible by using the following strategy:
- API route gets added.
Add a function that returns if this feature is supported.
Older versions implement this route by throwing an error (nonSupported).
- API route gets removed.
newer versions implement this route by throwing an error (nonSupported).
Is added to the interface
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: