Making REST calls in Kotlin Android using OKHTTP and Coroutines

B/O Trading Blog
9 min readDec 26, 2021

Photo by Pineapple Supply Company on Unsplash

Here a quick Kickstart Tutorial for making REST calls with OkHttp and Kotlin Coroutines in your Android app.

This tutorial will provide step-by-step instructions on:

  1. Configuring your app for making REST calls
  2. Using OkHttp to make a Get call
  3. Launch a Get request from a background thread
  4. Use ViewModel and LiveData to update the UI.

Please ‘follow me’ on Medium if you like this post.

1. Versions used

  • Android Studio 4.1.1
  • Android API 29
  • OkHttp 4.9.0
  • view model and livedata 2.2.0
  • klaxon 5.0.1

2. Creating a project

First, let’s create a new project using the ‘Basic Activity’ template. In Android Studio, select the ‘File’ menu, ‘New Project’ menu item.

Select ‘Next’.

--

--

B/O Trading Blog

Blogging about algorithmic trading, Python utilities and passive income opportunities.