# Pure Kotlin SDK

**URL:** <https://community.parseplatform.org/t/pure-kotlin-sdk/977>\
**Category:** Android SDK\
**Tags:** discussion\
**Created:** [October 27, 2020, 5:37pm UTC](https://community.parseplatform.org/t/pure-kotlin-sdk/977 "2020-10-27T17:37:16Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![L3K0V](https://community.parseplatform.org/user_avatar/community.parseplatform.org/l3k0v/32/30_2.png) [@L3K0V](https://community.parseplatform.org/u/L3K0V)\
**Post date:** [October 27, 2020, 5:37pm UTC](https://community.parseplatform.org/t/pure-kotlin-sdk/977/1 "2020-10-27T17:37:16Z")

</div>

Hello guys, I saw you have reveal recently ParseSwift, great job done there! I was inspired to start a pure Kotlin SDK following the ParseSwift techniques because you guys are more into the core and how everything is structured, queries building etc. The documentation is not quite full on how to build all kind of queries so the JS SDK is a good friend there.

Unfortunately I’m pretty out of free time and decide to share with you my initial work in order to push it a little bit to a some working state. If there’s somebody interested giving feedback or even help me with the Kotlin SDK is more than welcome!

Current state is there’s basic auth, parse object and some queries. It uses coroutines and Kotlin Serialization for the ParseObject. I cannot decide what to do with the storage, but my idea is to provide some kind of interface/adapter and one or more implementations. As the same way of the ParseSwift I introduced encrypted storage for the user, installation and more later on…

[https://github.com/L3K0V/ParseKt](https://github.com/L3K0V/ParseKt)

Best regards,  
Asen

---

<div class="post-metadata">

**Author:** ![cbaker6](https://community.parseplatform.org/user_avatar/community.parseplatform.org/cbaker6/32/114_2.png) [@cbaker6](https://community.parseplatform.org/u/cbaker6)\
**Post date:** [October 27, 2020, 7:58pm UTC](https://community.parseplatform.org/t/pure-kotlin-sdk/977/2 "2020-10-27T19:58:50Z")

</div>

From skimming it, looks like a great start! I don’t know much about Kotlin, so I won’t be much help with coding directly. As far of where to start and what to work on next, I can assist there with the hurdles I’ve seen so far with Parse-Swift.

> [@L3K0V](#):
>
> The documentation is not quite full on how to build all kind of queries so the JS SDK is a good friend there.

The [documentation](http://parseplatform.org/Parse-Swift/api/index.html) has been updated recently, most of the basics are there and can help you in some areas. With respect to queries, the JS SDK can only do a couple more things (aggregate, distinct) that ParseSwift cannot. Of course, the JS SDK is more battle tested. All of these [functions](http://parseplatform.org/Parse-Swift/api/Functions.html) can be used as [QueryConstraints](http://parseplatform.org/Parse-Swift/api/Structs/QueryConstraint.html). With respect to overall functionality, the the JS and Objc-SDK definitely win there as there is a lot of heavy lifting that occurs on the SDK side that will take time to implement.

One thing I didn’t see in your SDK is CI (I may not know where to look), but if you don’t have them, I strongly encourage adding them next as you may end up having to rewrite a lot of code due to bugs. Also, this will help other contributors to program better when adding to the SDK, along with ensuring they don’t break code you know already works.

---

<div class="post-metadata">

**Author:** ![L3K0V](https://community.parseplatform.org/user_avatar/community.parseplatform.org/l3k0v/32/30_2.png) [@L3K0V](https://community.parseplatform.org/u/L3K0V)\
**Post date:** [October 28, 2020, 12:25pm UTC](https://community.parseplatform.org/t/pure-kotlin-sdk/977/3 "2020-10-28T12:25:31Z")

</div>

Thanks for the quick response!

Indeed, my idea is to setup CI as soon as possible once I finish the initial architecture let say and implement the basics. I’m wondering what approach you are taking for the local storage and working queries offline. I believe this is big pain for the Android SDK and I’m trying to find a good alternative or to address this in the Kotlin SDK.

I’m pretty sure you have discussed the pain points of the Parse mobile SDKs. Can you share how you address them in the Swift SDK.

Can you help me understanding how complex queries are build as a JSON for the request. I’m referring ‘or’, ‘nor’, ‘and’ etc.  
Is there somewhere a good explanation how the JSON structure of complex queries are build?  
Can we nest them? And all info around building them will help.

Thanks!

---

<div class="post-metadata">

**Author:** ![cbaker6](https://community.parseplatform.org/user_avatar/community.parseplatform.org/cbaker6/32/114_2.png) [@cbaker6](https://community.parseplatform.org/u/cbaker6)\
**Post date:** [October 28, 2020, 2:54pm UTC](https://community.parseplatform.org/t/pure-kotlin-sdk/977/4 "2020-10-28T14:54:18Z")

</div>

> Indeed, my idea is to setup CI as soon as possible once I finish the initial architecture let say and implement the basics. I’m wondering what approach you are taking for the local storage and working queries offline. I believe this is big pain for the Android SDK and I’m trying to find a good alternative or to address this in the Kotlin SDK.

The short answer from me is I’ve been avoiding local storage. Mainly because (this is my opinion) you have to have a way to sync data that isn’t dependent on a wall clock. Personally, when I need local storage with Parse, I usually add my own local storage (e.g. CoreData) and add a “Clock” Class to Parse that uses vector clocks to keep data in sync. Basically, I rely on 3rd party to sync local data with the Parse Server. We have had a couple of discussions about local storage:

- This PR stalled because of local storage - [remove some direct references to the Keychain by pranjalsatija · Pull Request #22 · parse-community/Parse-Swift · GitHub](https://github.com/parse-community/Parse-Swift/pull/22)
- Discussion about issues with local storage on Parse-Swift - [Evolution? · Issue #3 · parse-community/Parse-Swift · GitHub](https://github.com/parse-community/Parse-Swift/issues/3#issuecomment-657320279)

One of the other committers, pranjalsatija, is interested in implementing a protocol based local storage, but I’m not sure of his status on that part. I do believe a protocol can work and allows developers to choose their favorite option to sync data. I’ve focused my energy on other areas as I didn’t feel local storage is as important as the others (plus I personally don’t need the Parse SDK for local storage). When it comes to ParseUser.current and ParseInstallation.current, local storage is very important. So Parse-Swift stores this in the keychain and only persists updates to either if it can save them to the parse-server, otherwise the changes wait in memory (or are discarded). You can see details about this in the first link above (the updates in the PR weren’t merged because it would have broken this).

> Can you help me understanding how complex queries are build as a JSON for the request. I’m referring ‘or’, ‘nor’, ‘and’ etc.  
> Is there somewhere a good explanation how the JSON structure of complex queries are build?  
> Can we nest them? And all info around building them will help.

I didn’t find a good explanation, I took a lot of time to look through the Obj-c SDK code to figure these out (some were in the SDK before I started working on it and just needed some tweaking). The best way to figure this out (IMO) is to create the test cases and test on a local parse-server (I do this with swift playgrounds). The test cases to look at are:

- Query - [Parse-Swift/Tests/ParseSwiftTests/ParseQueryTests.swift at e382516bcf5997b5281dc734540fc89f58daad9e · parse-community/Parse-Swift · GitHub](https://github.com/parse-community/Parse-Swift/blob/e382516bcf5997b5281dc734540fc89f58daad9e/Tests/ParseSwiftTests/ParseQueryTests.swift#L162)
- When queries start to get complex (like geopoint) it’s best to test the JSON creation of the SDK directly. To find specific output, I looked at test cases in the Objective-c and JS SDK’s, [Parse-Swift/Tests/ParseSwiftTests/ParseQueryTests.swift at e382516bcf5997b5281dc734540fc89f58daad9e · parse-community/Parse-Swift · GitHub](https://github.com/parse-community/Parse-Swift/blob/e382516bcf5997b5281dc734540fc89f58daad9e/Tests/ParseSwiftTests/ParseQueryTests.swift#L561)

You should be able to rely on the expected JSON generation in the test file above as I pulled them from reliable SDKs and tested almost all of them on a local parse-server

---

<div class="post-metadata">

**Author:** ![L3K0V](https://community.parseplatform.org/user_avatar/community.parseplatform.org/l3k0v/32/30_2.png) [@L3K0V](https://community.parseplatform.org/u/L3K0V)\
**Post date:** [December 3, 2020, 8:22am UTC](https://community.parseplatform.org/t/pure-kotlin-sdk/977/5 "2020-12-03T08:22:50Z")

</div>

[cbaker6](https://community.parseplatform.org/u/cbaker6) thanks again for the guidelines.

Now I have tested all the queries and introduce some GitHub Actions building [KDoc](https://l3k0v.github.io/ParseKt/parse/) which currently is incomplete.

I have another question now, but lets describe the case first: I’m sticking with pointers, relations and mostly operations over the ParseObject.

```
@Serializable
    @ParseClassName("GameScore")
    class GameScore(var score: Int) : ParseClass() {
        lateinit var type: ParsePointer
        val types by ParseRelationDelegate()
        companion object : ParseClassCompanion()
    }

```

I go for ParsePointer to be a wrapped object where you can check if data is available and fetch if necessary. But for the relation I go for delegated property which unfortunately is not directly serializable . This delegated property is needed to pass the current ParseObject instance and handle add, remove operations over the relation. But we loose the typing and I’m starting to introduce wrapping objects 🙁

How do you handle this pointers relations and operations in Swift?  
I want to keep the types and the ParseObjects as POKOs as possible but it turns out that similar approach like used into the current Android SDK should be better with setter and getters by key.

---

<div class="post-metadata">

**Author:** ![cbaker6](https://community.parseplatform.org/user_avatar/community.parseplatform.org/cbaker6/32/114_2.png) [@cbaker6](https://community.parseplatform.org/u/cbaker6)\
**Post date:** [December 4, 2020, 1:34pm UTC](https://community.parseplatform.org/t/pure-kotlin-sdk/977/6 "2020-12-04T13:34:40Z")

</div>

Parse-Swift doesn’t support Relations yet and I haven’t looked much into how to implement it.

For Pointers in ParseSwift, they can be decoded as their original types since all Pointers contain an `objectId` and `className`. The part that was tricky to implement is ensuring child objects are saved before their patients and creating pointers to the children. The iOS and JS SDKs both have a process for doing this, but I took a different since Swift is strongly typed and I couldn’t come up with a way to directly translate either of those implementations, I leveraged the fact that Parse-Swift has a custom JSONEncoder (ParseEncoder). As long the whole `ParseObject` always conforms to the `Encodable` protocol it can always be sent to the parse-server. As long as child objects always conform to `Objectable` they can be turned into Pointers and still represent their respective `ParseObject`.

1. [Checking/Saving child objects](https://github.com/parse-community/Parse-Swift/blob/5497d561f9972cce092d233d3eaaf0eee88e2e0d/Sources/ParseSwift/Object%20Protocols/ParseObject.swift#L309)
2. [Checking/replacing child objects with Pointers inside the custom encoder](https://github.com/parse-community/Parse-Swift/blob/1818cbc7885f5649f3bb54811d62377ebe5024b0/Sources/ParseSwift/Coding/ParseEncoder.swift#L226)

---

<div class="post-metadata">

**Author:** ![danipralea](https://community.parseplatform.org/user_avatar/community.parseplatform.org/danipralea/32/1208_2.png) [@danipralea](https://community.parseplatform.org/u/danipralea)\
**Post date:** [July 12, 2023, 6:01pm UTC](https://community.parseplatform.org/t/pure-kotlin-sdk/977/7 "2023-07-12T18:01:56Z")

</div>

Looks like this was left out, and the repo has also been archived.  
Does anyone know of any progress on this?

---

<div class="post-metadata">

**Author:** ![mathieulb](https://community.parseplatform.org/letter_avatar_proxy/v4/letter/m/a88e57/32.png) [@mathieulb](https://community.parseplatform.org/u/mathieulb)\
**Post date:** [October 11, 2025, 7:47am UTC](https://community.parseplatform.org/t/pure-kotlin-sdk/977/8 "2025-10-11T07:47:27Z")

</div>

The GitHub URL above no longer works. Seems like the author changed their username. Here is the new link. [https://github.com/Nikhil-z/ParseKt](https://github.com/Nikhil-z/ParseKt)

But the last changes were in nov 2021.

I was wondering whether I could adapt an Android Kotlin app to use Kotlin Multiplatform instead, but the lack of Parse for Kotlin Multiplatform would be holding me back, if there isn’t more than a proof-of-concept used by possibly nobody.
