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>(""))<Order>(""), order, /* optional headers */ mapOf( "x-header1" to "value1", "x-header2" to "value2" ) )
where ResponseType is any data class or Dynamic or supported TypeMutableList (see


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 = "")
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.