In this recipe, we are going to explore how to employ coroutines to interact with remote endpoints using REST APIs. We are going to implement a REST client using the Retrofit library, allowing us to communicate over HTTP with the GitHub API asynchronously. Finally, we will use it in practice to fetch GitHub repositories search results for a given search query.
Building a REST API client with Retrofit and a coroutines adapter
Getting ready
The first step to start working with Kotlin Coroutines is to add a core framework dependency:
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:0.23.3'
In order to make use of the Retrofit library with the coroutines adapter plugin, we also need to add the following...