CotEditor supports AppleScript and JXA (JavaScript for Automation). It has own AppleScript dictionary so that you can look up the classes or commands available with CotEditor. To open the dictionary:
Choose Help > CotEditor Scripting Manual > AppleScript Dictionary.
Details and examples of AppleScript classes or commands can be found in the documentation: Help > CotEditor Scripting Manual > Scripting with AppleScript.