Official Kotlin/Android client for BigDataCloud free APIs — reverse geocoding and roaming detection.
No API key required. Uses api.bigdatacloud.net.
Looking for full-featured server-side Kotlin SDK with all BigDataCloud APIs? Use the Java SDK which is fully Kotlin-compatible.
Add to your app's build.gradle.kts:
dependencies {
implementation("com.bigdatacloud:bigdatacloud-client:1.0.0")
}Add to your AndroidManifest.xml:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />And request permissions at runtime before calling reverseGeocode().
val client = BigDataCloudClient(context)
// In a coroutine or ViewModel:
lifecycleScope.launch {
val result = client.reverseGeocode()
println("${result.response.city}, ${result.response.countryName}")
println("Accuracy: ${result.accuracy}") // FINE, COARSE, or IP_BASED
}The client follows a strict three-tier location priority:
- FINE (GPS) —
PRIORITY_HIGH_ACCURACYvia FusedLocationProviderClient. Always requested first. - COARSE (network/cell) —
PRIORITY_BALANCED_POWER_ACCURACY. Used when FINE is unavailable. - IP_BASED — No coordinates. Server uses caller's IP. Only when all location is denied.
Always show the user what accuracy level is in use:
val result = client.reverseGeocode()
val label = when (result.accuracy) {
AccuracyLevel.FINE -> "GPS location"
AccuracyLevel.COARSE -> "Approximate location"
AccuracyLevel.IP_BASED -> "IP-based — enable location for better accuracy"
}val roaming = client.amIRoaming()
if (roaming.isRoaming == true) {
println("Roaming in ${roaming.roamingCountryName}")
println("Home: ${roaming.simRegisteredCountryName}")
}This library uses api.bigdatacloud.net, governed by BigDataCloud's Free Client-Side API Fair Use Policy.
Key rules:
- Client-side only. Requests must originate from the device whose location is being resolved.
- Real-time coordinates only. Only the current, live location of the calling device is permitted. Pre-stored, cached, or externally-sourced coordinates are not allowed.
- User consent required. Coordinates must be obtained via platform geolocation APIs (GPS/WiFi) with the user's permission.
Violations result in a 402 error and IP ban.
If your use case doesn't fit — for example you already have coordinates from another source — use the server-side reverse geocoding API instead. It includes 50,000 free queries per month with an API key.
- Android API 21+
- Kotlin coroutines
- Google Play Services Location
MIT — see LICENSE.