The API you mentioned is what is referred to as "webapi" (I think, that's how I refer to it anyway). The widgets and external code can "call" these to execute things in HG. I use these webapi URL's to link my Amazon Echo to IFTTT to turn on lights:
http://<IP>/api/HomeAutomation.X10/A1/Control.On
http://<IP>/api/HomeAutomation.ZWave/16/Control.Off
Depending how a given module is coded, it can return a value (to the web browser) like:
result: {"ResponseValue":"OK"}
To turn a module off you could do (examples are not tested so not 100% sure accurate):
Modules.WithName("Light 1").On();
Modules.InGroup("Living Room").WithName("Lamp").Off();
Modules.WithAddress("A1").On();
var sirenModules = Modules.WithFeature("HomeGenie.SecurityAlarm").OfDeviceType("Siren");
sirenModules.On();
//if you are inside an if statement to match name, group, features etc, then
module.Off();