Add programmatic API

Detail are in the doc. 

@arikon @scf2k 
Ок