External API Calls

To call any API endpoint you can use methods get, put, post or delete of object api, e.g.api.get<DynamicMutableList>(api.target("https://server.com/path/to/someObjects")) api.post<Order>(api.target("https://server.com/orders"), order, /* optional headers */ mapOf( "x-header1" to "value1", "x-header2" to "value2" ) )

where ResponseType is any data class or Dynamic or supported TypeMutableList (see https://promethist.ai/apidoc/core-api/com.promethist.core.type/index.html)

Examples

api.get<StringMutableList>(api.target("https://repository.promethist.ai/data/animals.json"))

DialogueScript has several 3rd party API integration preconfigured so you don’t need to specify URLs, headers (e.g. API keys):

Pre-integrated APIs

Words API

to get list of words use method api.words(word, type)

to get all results for word (or response of dynamic structure)api.words<ResponseType>(word, type = "")

where

Examples

Getting list of antonyms api.words("good", "antonyms")

Processing all available resultsapi.words<Dynamic>("hatchback")<List<PropertyMap>>("results") { value.forEach { println("partOfSpeech = " + it["partOfSpeech"]) if (it.containsKey("synonyms")) { println("synonyms:") (it["synonyms"] as List<String>).forEach { println("- $it") } } } }

Response caching can be implemented in the future to prevent repeated API requests using the same input data.

Last updated