Skip to main content
The official Kotlin library for the CoinPaprika API provides a set of Retrofit interfaces and data models to access cryptocurrency market data. This allows for easy integration into any Android or Kotlin project that uses Retrofit for networking. This library provides the building blocks, not a pre-configured client. You are responsible for creating and configuring your own Retrofit instance.

Installation

Add the library dependency to your module’s build.gradle or build.gradle.kts file.
You will also need to add dependencies for Retrofit, a JSON converter like Moshi, and an HTTP client like OkHttp if you haven’t already.
Finally, ensure you have the INTERNET permission in your AndroidManifest.xml.

Quick Start

1. Create a Retrofit Instance

First, configure and build a Retrofit instance. You must provide the base URL and a converter factory.

2. Create a Service

Use your Retrofit instance to create an implementation of one of the library’s service interfaces, such as TickersService.

3. Make an API Call

Now you can use the service within a coroutine to make API calls.

Authenticating with a paid plan

Paid plans (Starter / Pro / Business / Ultimate / Enterprise) live on a separate hostname, https://api-pro.coinpaprika.com/v1/, and require an API key in the Authorization header. The library doesn’t provide a Pro-aware base URL constant; configure it on your Retrofit builder along with an OkHttp Interceptor that injects the key on every request.
Free-tier callers don’t need any of this. Keep the RetrofitClient from Quick Start pointed at COINPAPRIKA_BASE_URL without an interceptor.

Available Services

This library provides the following Retrofit service interfaces.

CoinsService

Used to fetch coin details and history.

ExchangesService

Used to fetch data about exchanges.

GlobalStatsService

Used to get global market data.

PeopleService

Used to get information about people in the crypto space.

SearchService

Used to perform searches.
  • search(...): Searches for coins, exchanges, people, and more.

TagsService

Used to get information about tags.

TickersService

Used to fetch ticker price and market data.

FAQs

Add an OkHttp Interceptor that adds the Authorization header (bare key, no Bearer prefix) and point your Retrofit builder at https://api-pro.coinpaprika.com/v1/. See the “Authenticating with a paid plan” section above.
Use the Coverage Checker to discover canonical IDs (e.g., btc-bitcoin).
Historical OHLCV requires a paid plan. Use the ProRetrofitClient from the Pro authentication section, then call CoinsService.getHistoricalCoinOHLCV(…) with start/end in ISO date format and a quote like “usd”.

Error Handling

When using this library, you should wrap your API calls in a try-catch block to handle potential exceptions, such as HttpException from Retrofit for non-2xx responses or IOException for network failures.

Requirements

  • Kotlin-enabled project (Android or pure Kotlin)
  • retrofit2
  • moshi (or another JSON converter)
  • okhttp3

License

This library is available under the MIT license. See the LICENSE file for more info.