OKR Dashboard with Kotlin Client

In this tutorial, we’ll build a small Kotlin command-line program that interacts with the Peoplelogic.dev API to manage OKRs (Objectives and Key Results) using pure HTTP calls. We’ll cover the following steps:

  1. Authentication: Using a JWT API key as a Bearer token for authorization.

  2. Create an Objective: Making a REST call to create a top-level OKR (Objective).

  3. Add Key Results: Creating child objectives (key results) under the main objective.

  4. Add Tasks: Attaching action-item tasks to the OKRs.

  5. Fetch & Display: Retrieving all OKRs and printing them in a hierarchical, dashboard-like view in the console.

We’ll use Gradle to set up a Kotlin project (JVM) with OkHttp for HTTP requests and a simple JSON library for parsing. The style here is hands-on and explanatory (in the spirit of CrewAI and Spring AI tutorials), with plenty of comments and clarity for a backend engineer with moderate Kotlin experience.

Note: Replace placeholders (like <YOUR_ORG_ID> and <YOUR_API_KEY>) with your actual Peoplelogic organization ID and API key. You can obtain these from your Peoplelogic account. The API key is a JWT token that includes your org credentials and must be included as a Bearer token in each request.

Project Setup

Let's start by setting up a new Kotlin project with Gradle. We will need the Kotlin JVM plugin, and dependencies for OkHttp (for HTTP calls) and org.json (for JSON handling).

Gradle Build Script (build.gradle.kts): This configures the project and dependencies.

plugins {
    kotlin("jvm") version "1.8.20"
    application
}
group = "com.example"
version = "1.0-SNAPSHOT"

repositories {
    mavenCentral()
}

dependencies {
    implementation("com.squareup.okhttp3:okhttp:4.10.0")
    implementation("org.json:json:20211205")
}

application {
    mainClass.set("com.example.MainKt")
}

A few notes on the setup:

  • We apply the Kotlin JVM plugin and set a Kotlin version (1.8.20 here).

  • Dependencies include OkHttp 4.x for HTTP requests and org.json for simple JSON parsing. Both will be pulled from Maven Central.

  • We use the Gradle Application plugin to easily run the program (with MainKt as the entry point).

Our project structure will look like this:

The complete source code is provided in the attached ZIP file at the end of this tutorial.

Authenticating with a JWT Bearer Token

The Peoplelogic API expects each request to be authenticated with a JWT token in the Authorization header. In our code, we’ll store the Org ID and API key (JWT) as constants and include them in every request.

The base URL for the Peoplelogic API is https://api.peoplelogic.dev/api/v1. All our endpoint paths will be relative to this (e.g. /objective for OKRs). The JWT token provided by Peoplelogic should be included as a Bearer token in the HTTP Authorization header.

We’ll set up some constants and an OkHttp client in our Main.kt:

Here we set API_KEY to your JWT token string. We’ll use this in the header of every request like so:

This ensures the Peoplelogic API recognizes our calls as authorized.

1. Creating a Top-Level Objective

An Objective in Peoplelogic represents a high-level goal (for example, “Increase Q3 Sales by 20%”). We’ll create a new objective via an HTTP POST request to the /objective endpoint.

Endpoint: POST /objective (requires auth) – Creates a new objective in your organization. The request body is JSON with the objective details.

2. Adding Key Results (Child Objectives)

With the main objective in place, we’ll add a couple of Key Results. In Peoplelogic, key results are objectives that have a parentId linking them to a top-level objective.

3. Adding Tasks to the OKRs

Next, we’ll add tasks to each key result via the POST /entity/{entityId}/task endpoint.

4. Fetching and Displaying the OKR Dashboard

Finally, retrieve all objectives with child objectives and tasks via:

Then print a neat CLI dashboard:

Expected Console Output:

That’s it! You’ve built a full CLI dashboard for OKRs using only the Peoplelogic.dev REST API and basic Kotlin libraries.

Last updated

Was this helpful?