KTweet – A Kotlin Twitter Library

open source
Open Source
Open Source

KTweet is an open-source library built on the Twitter API v1/v2. I wanted to use Kotlin and dive into the open-source world. After doing some research, I found that Twitter did not have a Kotlin library supporting it. So, I decided to build this from the bottom up. The best way to learn is by jumping into the fire!

Building an open-source project wasn’t a clear path, in my opinion. However, I hope my experience building my first open-source project helps those looking to get started. For a great starting point, visit OSS Guide.

GitHub

First, I hosted my project, KTweet, on GitHub. This was the most straightforward direction for me and overall felt it had more support. Here I started with the essentials, following the guide to add a license, a README, a contribution guide, and a code of conduct. There is a lot of information around each of these, and I will only hit on the points I believe were a struggle. Use the links to read more.

Don’t Over Think

Next, one biggest hurdles I had to overcome was figuring out when things were in a good enough state to publish. The answer is never. You may never feel like it’s good enough. No matter how much time and effort is put in. Don’t take this wrong. In short, it is good enough, but it may feel not good enough. There is always something to do with one more feature or some code cleanup. So before you start coding and building a project, write it down.

Now, there are tons of tools to help you write it down. Next, build a roadmap to avoid the pitfalls of always building or adding. For KTweet, I wrote it down in a notepad and kept most of my notes offline. The question I used was, what would be the minimum to allow users to use the library, including myself?

I defined the minimum as being able to post on Twitter. The bigger picture required me to dig into Twitter’s API Documentation. First, I created their authentication methods, the main one being OAuth 1.0 user context. Once completed, I could make the API call for posting to Twitter. Now that I can post to Twitter using their API, I must ensure my code is working. Creating unit tests or integration tests helps ensure nothing breaks as you build and add more features to your library.

The Starting Point

At last, my first version of KTweet was ready! The final question was, how do I put this into a location where everyone can obtain it? The solution here was to use Maven Central. I found the JetBrains guide to be the most helpful. You can look at my build.gradle.kts and gradle-publish.yml. Gradle also has a well-detailed guide for publishing your artifacts.

I can’t begin to explain the level of knowledge I gained from building this. Even after ten years of professional development, publishing something I built never felt so good. My only wish was that I had started this sooner. So don’t wait; start now!


Follow & Subscribe