/lemgram_count returns a mapping of lemgram strings to counts. The data is on the top level of the response, beside time and ERROR.
This is a little annoying to handle in TypeScript. For other API endpoints, the following code successfully identifies an error response:
if ("ERROR" in data) {
throw new KorpBackendError(data.ERROR.type, data.ERROR.value)
}
But when using this for /lemgram_count, this is invalid, as TypeScript believes data.ERROR could be a number (as if "ERROR" was a lemgram in a successful response).
It can easily be worked around, but I would suggest pushing the counts mapping down under a member called counts or so, to separate the dynamic data from the predictable members:
{
"counts": {
"katt..nn.1": 5
},
"time": 0.123
}