Dasha API - Kotlin
Dasha API with Kotlin 🟠
Integrate Dasha API into your Kotlin application.
Installation
This example needs no package: it uses the java.net.http client from JDK 11 and later, for Kotlin on the JVM. Android has no java.net.http; Android apps use the Android client listed on SDKs.
Example Code
import java.net.URI
import java.net.http.HttpClient
import java.net.http.HttpRequest
import java.net.http.HttpResponse
fun main() {
val body = """
{
"datetime": "1990-06-15T10:30:00",
"latitude": 18.5204,
"longitude": 73.8567,
"timezone": "Asia/Kolkata"
}
""".trimIndent()
val request = HttpRequest.newBuilder()
.uri(URI.create("https://api.vedika.io/v2/astrology/dasha"))
.header("Authorization", "Bearer YOUR_API_KEY")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(body))
.build()
val response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString())
println(response.statusCode())
println(response.body())
}Anything compiled into a shipped app can be extracted, including the API key. For consumer apps, call the Vedika API from your own backend and keep the key on the server.