You can’t…
Not unless MikroTik implement this feature request or something similar.
Right now, you can only look from terminal, and write that same thing… But that’s doing it manually. Programmatically, the only possibility is to analyze SSH output, which can be somewhat error prone, not to mention not trivial.